tags:

views:

262

answers:

1

Hi friends!

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=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

Thanks and Regards Mintu Nandi

A: 

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)
Marc Novakowski
IS there anyway to play this youtube url without apn setting and without direct TCP which will not depend on carriers also?????Please if you have any such code post that code.Thanks
RockOn
If the device has Wi-Fi then you could use that transport, too. But not all devices are Wi-Fi enabled and even then not all are connected to Wi-Fi networks. See http://supportforums.blackberry.com/t5/Java-Development/Connecting-your-BlackBerry-http-and-socket-connections-to-the/td-p/206242 for everything you could ever want to know about networking and HTTP on the BlackBerry platform.
Marc Novakowski