Playing an InputStream video in Blackberry JDE.

Posted by Jenny on Stack Overflow See other posts from Stack Overflow or by Jenny
Published on 2009-09-08T12:36:50Z Indexed on 2010/03/27 10:03 UTC
Read the original article Hit count: 774

I think I'm using InputStream incorrectly with a Blackberry 9000 simulator:

I found some sample code,

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/1089414/How%5FTo%5F-%5FPlay%5Fvideo%5Fwithin%5Fa%5FBlackBerry%5Fsmartphone%5Fapplication.html?nodeid=1383173&vernum=0

that lets you play video from within a Blackberry App. The code claims it can handle HTTP, but it's taken some fandangling to get it to actually approach doing so:

http://pastie.org/609491

Specifically, I'm doing:

 StreamConnection s = null;
            s = (StreamConnection)Connector.open("http://10.252.9.15/eggs.3gp");
            HttpConnection c = (HttpConnection)s;                        
           InputStream i = c.openInputStream();
            System.out.println("~~~~~I have a connection?~~~~~~" + c);
            System.out.println("~~~~~I have a URL?~~~~" + c.getURL());
            System.out.println("~~~~~I have a type?~~~~" + c.getType());
            System.out.println("~~~~~I have a status?~~~~~~" + c.getResponseCode());

            System.out.println("~~~~~I have a stream?~~~~~~" + i);
             player = Manager.createPlayer(i, c.getType());

I've found that this is the only way I can get an InputStream from an HTTPConnection without causing a: "JUM Error 104: Uncaught NullPointer Exception". (That is, the casting as a StreamConnection, and THEN as an HttpConnection stops it from crashing).

However, I'm still not streaming video. Before, a stream wasn't able to be created (it would crash with the null pointer exception). Now, a stream is being made, the debugger claims it's begining to stream video from it...and nothing happens. No video plays.

The app doesn't freeze, or crash or anything. I can 'pause' and 'play' freely, and get appropriate debug messages for both. But no video shows up.

If I'm playing a video stored locally on the blackberry, everything is fine (it actually plays the video), so I know the Player itself is working fine, I"m just wondering if maybe I have something wrong with my stream?

The API says the player can take in an InputStream. Is there a specific kind it needs? How can I query my inputstream to know if it's valid? It existing is further than I've gotten before.

-Jenny

Edit: I'm on a Blackberry Bold simulator (9000). I've heard that some versions of phones do NOT stream video via HTTP, however, the Bold does. I have yet to see examples of this though. When I go to the internet and point at a blackberry playable video, it attempts to stream, and then asks me to physically download the file (and then plays fine once I download).

Edit: Also, I have a physical blackberry Bold, as well, but it can't stream either (I've gone to m.youtube.com, only to get a server/content not found error). Is there something special I need to do to stream RTSP content?

© Stack Overflow or respective owner

Related posts about blackberry

Related posts about rim-4.6