{"id":1456,"date":"2022-08-30T15:16:41","date_gmt":"2022-08-30T15:16:41","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/19\/playing-an-inputstream-video-in-blackberry-jde-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:16:41","modified_gmt":"2022-08-30T15:16:41","slug":"playing-an-inputstream-video-in-blackberry-jde-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/playing-an-inputstream-video-in-blackberry-jde-collection-of-common-programming-errors\/","title":{"rendered":"Playing an InputStream video in Blackberry JDE-Collection of common programming errors"},"content":{"rendered":"<p>I think I&#8217;m using InputStream incorrectly with a Blackberry 9000 simulator:<\/p>\n<p>I found some sample code,<\/p>\n<p>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&#038;vernum=0<\/p>\n<p>that lets you play video from within a Blackberry App. The code claims it can handle HTTP, but it&#8217;s taken some fandangling to get it to actually approach doing so:<\/p>\n<p>http:\/\/pastie.org\/609491<\/p>\n<p>Specifically, I&#8217;m doing:<\/p>\n<pre><code> StreamConnection s = null;\n            s = (StreamConnection)Connector.open(\"http:\/\/10.252.9.15\/eggs.3gp\");\n            HttpConnection c = (HttpConnection)s;                        \n           InputStream i = c.openInputStream();\n            System.out.println(\"~~~~~I have a connection?~~~~~~\" + c);\n            System.out.println(\"~~~~~I have a URL?~~~~\" + c.getURL());\n            System.out.println(\"~~~~~I have a type?~~~~\" + c.getType());\n            System.out.println(\"~~~~~I have a status?~~~~~~\" + c.getResponseCode());\n\n            System.out.println(\"~~~~~I have a stream?~~~~~~\" + i);\n             player = Manager.createPlayer(i, c.getType());\n<\/code><\/pre>\n<p>I&#8217;ve found that this is the only way I can get an InputStream from an HTTPConnection without causing a: &#8220;JUM Error 104: Uncaught NullPointer Exception&#8221;. (That is, the casting as a StreamConnection, and THEN as an HttpConnection stops it from crashing).<\/p>\n<p>However, I&#8217;m still not streaming video. Before, a stream wasn&#8217;t able to be created (it would crash with the null pointer exception). Now, a stream is being made, the debugger claims it&#8217;s begining to stream video from it&#8230;and nothing happens. No video plays.<\/p>\n<p>The app doesn&#8217;t freeze, or crash or anything. I can &#8216;pause&#8217; and &#8216;play&#8217; freely, and get appropriate debug messages for both. But no video shows up.<\/p>\n<p>If I&#8217;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&#8221;m just wondering if maybe I have something wrong with my stream?<\/p>\n<p>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&#8217;s valid? It existing is further than I&#8217;ve gotten before.<\/p>\n<p>-Jenny<\/p>\n<p>Edit: I&#8217;m on a Blackberry Bold simulator (9000). I&#8217;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).<\/p>\n<p>Edit: Also, I have a physical blackberry Bold, as well, but it can&#8217;t stream either (I&#8217;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?<\/p>\n<ol>\n<li>\n<p>So, after a very long time I have determined that the Blackberry Bold 9000 does NOT do http streaming. I ended up having to (or rather a coworker of mine having to) write custom methods for progressive download to simulate it. Oh, well.<\/p>\n<\/li>\n<li>\n<p>You should be able to stream actually. Firstly, you must make sure you are appending the correct connection parameters to your URL (ie. &#8220;;interface=wifi&#8221; for a wifi connection). Secondly, you have to make sure the file you are streaming is not too large. If it is too large, you will get an HTTP error stating &#8220;file too large&#8221;. In order to fix this, you need to buffer things (Check out the DataSource APIs). You should limit what you request to about 1-2MB. After you have pulled that &#8220;chunk&#8221; you need to keep requesting sequential chunks (with separate http connections) to continue to fill you buffer. I hope this helps<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-19 13:17:41. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I think I&#8217;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&#038;vernum=0 that lets you play video from within a Blackberry App. The code claims it can handle HTTP, but it&#8217;s taken some fandangling to get it to actually approach doing so: http:\/\/pastie.org\/609491 Specifically, I&#8217;m doing: StreamConnection s = null; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1456","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1456","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1456"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1456\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}