0

I want to play a 10 seconds long video in BlackBerry. On video playing completion I want go to another screen. For this I want know the current status of player (e.g. playing, stopped, paused etc.).

Here is the code I am using now. Need help on this issue.

InputStream is = getClass().getResourceAsStream("/video/battery_tip.mp4");
player = Manager.createPlayer(is, "video/mp4");
player.prefetch();
player.realize(); 
VideoControl vc = (VideoControl) player.getControl("VideoControl");
Field fld = (Field) vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
vc.setDisplayFullScreen(true);
vc.setVisible(true);
add(fld);
player.start();
Rupak
  • 3,674
  • 15
  • 23
jaleel
  • 1,169
  • 8
  • 22
  • 46

1 Answers1

1

Check the interface PlayerListener.

PlayerListener is the interface for receiving asynchronous events generated by Players. Applications may implement this interface and register their implementations with the addPlayerListener method in Player.

To get current status of a Player, add an instance of PlayerListener to it.

player.addPlayerListener(new MyPlayerListener());


A demo implementation of PlayerListener

class MyPlayerListener implements PlayerListener {
    public void playerUpdate(Player player, String eventType, Object eventData) {
        try {
            if (eventType == PlayerListener.END_OF_MEDIA) {
                // go to next screen
            } else if (eventType == PlayerListener.CLOSED) {
                // go to next screen
            } else if (eventType == PlayerListener.ERROR) {
                // go to next screen
            } else if (eventType == PlayerListener.STOPPED) {
                // go to next screen
            }
        } catch (Exception e) {
        }
    }
}
Rupak
  • 3,674
  • 15
  • 23