0

目标:

从远程服务器播放黑莓设备中的视频。

电流输出

空白屏幕和此消息:“按空格键开始/停止/恢复播放。”

我的代码

public class MyApp extends UiApplication
{
    private Player player;
    private VideoControl videoControl; 

    public static void main(String[] args)
    {
        MyApp theApp = new MyApp();       
        theApp.enterEventDispatcher();
    }

    public MyApp()
    {
            MainScreen ms = new MainScreen();

            public boolean onClose()
            {

                player.close();
                videoControl.setVisible(false);
                close();
                return true;
            }

            protected boolean keyChar(char c, int status, int time)
            {
                boolean retVal = false;
                if (c == Characters.SPACE)
                {
                    if (player.getState() == Player.STARTED)
                    {
                        //Stop playback.
                        try
                        {
                            player.stop();
                        }
                        catch (Exception ex)
                        {
                            System.out.println("Exception: " + ex.toString());
                        }
                    }
                    else
                    {
                        //Start playback.
                        try
                        {
                            player.start();
                        }
                        catch (Exception ex)
                        {
                            System.out.println("Exception: " + ex.toString());
                        }
                    }
                    retVal = true;
                }
                return retVal;
            }
        };

        ms.setTitle(new LabelField("Let's play some video..."));
        LabelField lf = new LabelField("Press space to start/stop/resume playback.");
        ms.add(lf);
        pushScreen(ms);

        try
        {

            player = Manager.createPlayer("http://224.1.2.3:12344:8082/ACSATraffic/blackberry.3gp");
            player.realize();

            //Create a new VideoControl.
            videoControl = (VideoControl)player.getControl("VideoControl");
            //Initialize the video mode using a Field.
            videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");


            videoControl.setVisible(true);
        }
        catch (Exception ex)
        {
            System.out.println(ex.toString());
        }
    }
}

}

我在这里做错了什么?

或者是否有任何从本地和服务器播放视频的示例?一个链接将不胜感激。

4

0 回答 0