views:

26

answers:

1

I need to play a youtube video from my bb application. Does anyone know how to do that? Can I have a youtube video player directly inside my app or can I at least have a link to open youtube video in the browser?

+1  A: 

What you want to do is get the rtsp streaming URL for the video. When I browse to YouTube on a BlackBerry with the native browser, it serves a page with links to this format. If you know exactly which video to play at build-time, great. If it's going to be picked by your users, you'll have to figure that out.

Then, with that URL, you can create a Player like this:

Player p = Manager.createPlayer("rtsp://SOME_YOUTUBE_VIDEO_ID_HERE/video.3gp");
p.realize();
VideoControl vc = (VideoControl)p.getControl("javax.microedition.media.control.VideoControl");
Field f = (Field)vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field" );

The Field f can be added to your screen. And you can start the video with

p.start();

References: http://docs.blackberry.com/en/developers/deliverables/11942/Create_BB_app_that_plays_streaming_media_739691_11.jsp

http://docs.blackberry.com/en/developers/deliverables/11942/Create_BB_app_that_plays_a_video_in_a_UI_field_739692_11.jsp

spacemanaki