2010-02-09 81 views
0

我试图在我的黑莓默认播放器中播放视频,但我的代码不起作用。 这里是我的代码:编程方式如何在我的黑莓默认播放器中播放YouTube视频网址?

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难敌

+0

当一个有用的答案给出,考虑点击旁边的'V'它接受它。如果你不这样做,人们不会回答你的问题,因为他们认为你不欣赏他们 – Harmen 2010-02-09 11:42:59

回答

0

这可能有助于解释更多关于究竟是行不通的。但要在这里开始是基于代码的一些想法:

  • 得到您的Connector.open分号后摆脱了空间的()调用
  • 由于您使用直接TCP,你”如果您使用的是GSM运营商(CDMA运营商和模拟器没有APN,那么您需要确保APN已设置在您的设备设置中)
+0

是否有没有APN设置和没有直接的TCP不会依赖于运营商也播放此YouTube网址????? 如果你有任何这样的代码发布该代码请。 谢谢 – 2010-02-10 04:36:23

+0

如果设备具有Wi-Fi,那么您也可以使用该传输。但并非所有设备都支持Wi-Fi,即使不是所有设备都连接到Wi-Fi网络。请参阅http://supportforums.blackberry.com/t5/Java-Development/Connecting-your-BlackBerry-http-and-socket-connections-to-the/td-p/206242,了解关于网络连接的所有信息和黑莓平台上的HTTP。 – 2010-02-10 05:22:00

1

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

Browser.getDefaultSession().displayPage(videoUrl); 
相关问题