I am trying to play the video in LWUIT
It gives Error :
javax.microedition.media.MediaException: Prefetch error: -6
code :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.viral.mobiedu;
import com.sun.lwuit.Form;
import com.sun.lwuit.MediaComponent;
import java.io.IOException;
import java.io.InputStream;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.media.PlayerListener;
import javax.microedition.media.control.VideoControl;
/**
*
* @author Kamal Kumar Saboo
*/
public class VideoPlayer extends Form implements PlayerListener, Runnable{
MediaComponent mc;
Player player;
public VideoPlayer() {
this.setTitle("Video player");
this.show();
Thread t = new Thread(this);
t.start();
}
public void playerUpdate(Player player, String event, Object eventData) {
}
public void run() {
try {
InputStream is = getClass().getResourceAsStream("/mv.3gp");
player = Manager.createPlayer(is, "video/mpeg");
player.prefetch();
player.realize();
player.addPlayerListener(this);
VideoControl videoControl = (VideoControl) player.getControl("VideoControl");
mc = new MediaComponent(player);
mc.setPreferredH(300);
mc.setPreferredW(300);
this.addComponent(mc);
mc.start();
this.addComponent(mc);
} catch (IOException ex) {
ex.printStackTrace();
} catch (MediaException ex) {
ex.printStackTrace();
}
}
}
Please reply the Error in code or working Sample Code,
Thank You'
Regards
Rizwan khot

Reply With Quote

