Skip to main content

Problem with LWUIT media componant

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
khotrizwan
Offline
Joined: 2010-12-30

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;

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 viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07

There are lots of reasons this can fail, its an MMAPI question that's not related to LWUIT though. The file might be too large or the codec might not be supported by the device etc.