开发者

Programmatically how to play youtube video url in my blackberry default player?

开发者 https://www.devze.com 2022-12-19 10:14 出处:网络
I m trying to play a video in my blackberry default player but my code doesnt work. Here is my code: HttpConnection connection = (HttpConnection) Connector.open(url+\"; deviceside=t开发者_JAVA百科rue

I m trying to play a video in my blackberry default player but my code doesnt work. Here is my code:

HttpConnection connection = (HttpConnection) Connector.open(url+"; deviceside=t开发者_JAVA百科rue",Connector.READ_WRITE, true);
               if (connection != null) {
               InputStream input = null;
                try {
                    input = connection.openInputStream();

                    player = Manager.createPlayer(input,"video/3gpp");               

                    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");

                    //Set the video control to be visible.
                    videoControl.setVisible(true);


                } catch (IOException e) {
                    System.out.println("IOException: " + e);
                } finally {
                if (input != null) {
                    try {
                        input.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                  }//end if
                }          
              }//end if

Thanks and Regards Mintu Nandi


Give this code to invoke the default player. Just you need to pass the youtube URL to it.

Browser.getDefaultSession().displayPage(videoUrl);


We've got an open source sample on this topic here: https://github.com/blackberry/Samples-for-Java/tree/master/YouTube%20Client


It might help to explain more about what exactly is not working. But to start off with here are a few thoughts based on your code:

  • get rid of the space after the semicolon in your Connector.open() call
  • since you're using Direct TCP, you'll need to make sure the APN is set in your device settings if you're on a GSM carrier (CDMA carriers and simulators are fine without an APN)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号