Blackberry 如何以编程方式在我的黑莓默认播放器中播放youtube视频url?

Blackberry 如何以编程方式在我的黑莓默认播放器中播放youtube视频url?,blackberry,Blackberry,我试图在我的黑莓默认播放器中播放视频,但我的代码不起作用。 这是我的密码: HttpConnection connection = (HttpConnection) Connector.open(url+"; deviceside=true",Connector.READ_WRITE, true); if (connection != null) { InputStream input = null; t

我试图在我的黑莓默认播放器中播放视频,但我的代码不起作用。 这是我的密码:

HttpConnection connection = (HttpConnection) Connector.open(url+"; deviceside=true",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
谢谢和问候
Mintu Nandi

这可能有助于进一步解释到底是什么不起作用。但首先,以下是基于您的代码的一些想法:

  • 去掉Connector.open()调用中分号后面的空格
  • 由于您使用的是直接TCP,如果您使用的是GSM运营商,则需要确保在设备设置中设置了APN(CDMA运营商和模拟器没有APN都可以)

给出此代码以调用默认播放器。只需将youtube URL传递给它即可

Browser.getDefaultSession().displayPage(videoUrl);

我们在这里有一个开源的例子:

当给出一个有用的答案时,考虑通过点击它旁边的<代码> v<代码>来接受它。如果你不这样做,人们不会回答你的问题,因为他们认为你不欣赏他们。不管怎样,在没有apn设置和不依赖运营商的直接TCP的情况下播放这个youtube url有什么好处?????如果您有任何此类代码,请发布该代码。谢谢如果设备有Wi-Fi,那么你也可以使用这种传输方式。但并非所有设备都支持Wi-Fi,即使如此,也并非所有设备都连接到Wi-Fi网络。有关BlackBerry平台上的网络和HTTP的所有信息,请参阅。