Video Playback error

When I try to play a video using the following code, error occurs



[java]package mygame;



import com.jme3.app.SimpleApplication;

import com.jme3.audio.AudioNode;

import com.jme3.system.AppSettings;

import com.jme3.texture.Image;

import com.jme3.ui.Picture;

import com.jme3.video.Clock;

import com.jme3.video.VFrame;

import com.jme3.video.VQueue;

import com.jme3.video.plugins.jheora.AVThread;

import java.io.FileInputStream;

import java.io.IOException;



public class Main extends SimpleApplication {



private Picture picture;

private AVThread decoder;

private Thread videoThread;

private VQueue videoQueue;



private long lastFrameTime = 0;

private Clock masterClock;

private AudioNode source;



private float waitTime = 0;

private VFrame frameToDraw = null;



public static void main(String[] args){

Main app = new Main();

AppSettings settings = new AppSettings(true);

settings.setFrameRate(60);

app.setSettings(settings);

app.start();

}



private void createVideo(){

try {

FileInputStream fis = new FileInputStream("E:\x.ogv");



videoQueue = new VQueue(5);

decoder = new AVThread(fis, videoQueue);

videoThread = new Thread(decoder, "Jheora Video Decoder");

videoThread.setDaemon(true);

videoThread.start();

masterClock = decoder.getMasterClock();

} catch (IOException ex) {

}

}



public void simpleInitApp() {

picture = new Picture("VideoPicture", true);

picture.setPosition(0, 0);

picture.setWidth(settings.getWidth());

picture.setHeight(settings.getHeight());

//picture.setImage(assetManager, "Interface/Logo/Monkey.jpg", false);



// attach geometry to orthoNode

rootNode.attachChild(picture);



// start video playback

createVideo();

}



private void drawFrame(VFrame frame){

Image image = frame.getImage();

frame.setImage(image);

picture.setTexture(assetManager, frame, false);



// note: this forces renderer to upload frame immediately,

// since it is going to be returned to the video queue pool

// it could be used again.

renderer.setTexture(0, frame);

videoQueue.returnFrame(frame);

lastFrameTime = frame.getTime();

}



private void waitNanos(long time){

long millis = (long) (time / Clock.MILLIS_TO_NANOS);

int nanos = (int) (time - (millis * Clock.MILLIS_TO_NANOS));



try {

Thread.sleep(millis, nanos);

}catch (InterruptedException ex){

stop();

return;

}

}



@Override

public void simpleUpdate(float tpf){

if (source == null){

if (decoder.getAudioStream() != null){

source = new AudioNode(decoder.getAudioStream(), null);

source.setPositional(false);

source.setReverbEnabled(false);

audioRenderer.playSource(source);

}else{

// uncomment this statement to be able to play videos

// without audio.

return;

}

}



if (waitTime > 0){

waitTime -= tpf;

if (waitTime > 0)

return;

else{

waitTime = 0;

drawFrame(frameToDraw);

frameToDraw = null;

}

}else{

VFrame frame;

try {

frame = videoQueue.take();

} catch (InterruptedException ex){

stop();

return;

}

if (frame.getTime() < lastFrameTime){

videoQueue.returnFrame(frame);

return;

}



if (frame.getTime() == -2){

// end of stream

System.out.println("End of stream");

stop();

return;

}



long AV_SYNC_THRESHOLD = 1 * Clock.MILLIS_TO_NANOS;



long delay = frame.getTime() - lastFrameTime;

// delay -= tpf * Clock.SECONDS_TO_NANOS;

long diff = frame.getTime() - masterClock.getTime();

long syncThresh = delay > AV_SYNC_THRESHOLD ? delay : AV_SYNC_THRESHOLD;



// if difference is more than 1 second, synchronize.

if (Math.abs(diff) < Clock.SECONDS_TO_NANOS){

if(diff <= -syncThresh) {

delay = 0;

} else if(diff >= syncThresh) {

delay = 2 * delay;

}

}

// delay = diff;



System.out.println("M: "+decoder.getSystemClock().getTimeSeconds()+

", V: "+decoder.getVideoClock().getTimeSeconds()+

", A: "+decoder.getAudioClock().getTimeSeconds());



if (delay > 0){

waitNanos(delay);

drawFrame(frame);

// waitTime = (float) ((double) delay / Clock.SECONDS_TO_NANOS);

// frameToDraw = frame;

}else{

videoQueue.returnFrame(frame);

lastFrameTime = frame.getTime();

}

}

}



}

[/java]



error:

Mar 26, 2011 1:52:56 PM com.jme3.app.Application handleError

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.NoClassDefFoundError: com/fluendo/jheora/Info

at com.jme3.video.plugins.jheora.VDecoder.(VDecoder.java:66)

at com.jme3.video.plugins.jheora.AVThread.(AVThread.java:87)

at mygame.Main.createVideo(Main.java:46)

at mygame.Main.simpleInitApp(Main.java:66)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:219)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:117)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:188)

at java.lang.Thread.run(Thread.java:619)

Caused by: java.lang.ClassNotFoundException: com.fluendo.jheora.Info

at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:252)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

… 8 more

BUILD SUCCESSFUL (total time: 10 seconds)



what is wrong here?

Can anyone suggest anything?

Do not use video, it is deprecated … Sorry.

:S well…is it absolutely impossible to play video?



I need to show some slide show type video…say, sequence of pictures…one is fading away after another…should I use Nifty gui? If yes, how I am going to control the fading in-out effect?

Thats a very basic thing in nifty and easily doable. Just set an effect onLoad

ok i will let you know about my progress.

Does the features of importing video will be soon implemented since i really need to do precalculate ?

normen said:
Thats a very basic thing in nifty and easily doable. Just set an effect onLoad


@normen I dont know what to write here :(

[xml] <effect>
<onLoad what_to_write_here/>
</effect>[/xml]