在 Blackberry JDE 中播放 InputStream 视频

发布于 2024-08-03 23:37:55 字数 2075 浏览 1 评论 0原文

我认为我在 Blackberry 9000 模拟器中错误地使用了 InputStream:

我找到了一些示例代码,

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/1089414/How_To_- _Play_video_within_a_BlackBerry_smartphone_application.html?nodeid=1383173&vernum=0

可让您在 Blackberry 应用程序中播放视频。该代码声称它可以处理 HTTP,但需要一些技巧才能使其真正实现这一点:

http://pastie。 org/609491

具体来说,我正在做:

 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());

我发现这是我可以从 HTTPConnection 获取 InputStream 而不会导致“JUM Error 104:Uncaught NullPointer Exception”的唯一方法。 (也就是说,转换为 StreamConnection,然后转换为 HttpConnection 可防止崩溃)。

但是,我仍然没有流式传输视频。之前,无法创建流(它会因空指针异常而崩溃)。现在,正在创建一个流,调试器声称它开始从中传输视频......但什么也没有发生。没有视频播放。

该应用程序不会冻结、崩溃或任何其他情况。我可以自由地“暂停”和“播放”,并为两者获取适当的调试消息。但没有视频显示。

的流是否有问题?

如果我正在播放黑莓本地存储的视频,一切都很好(它实际上播放了视频),所以我知道播放器本身工作正常,我只是想知道我 API 说播放器可以接受它需要的特定类型?我如何查询我的输入流是否有效?

-Jenny

编辑:我正在使用 。 Blackberry Bold 模拟器(9000)。我听说某些版本的手机不通过 HTTP 传输视频,但是当我上网并指向黑莓时,我还没有看到这样的例子。可播放的视频,它尝试流式传输,然后要求我物理下载该文件(然后在下载后播放正常)

编辑:另外,我也有一个物理黑莓 Bold,但它也无法流式传输(我) 。已访问 m.youtube.com,只是收到服务器/内容未找到错误)。我需要做一些特殊的事情来流式传输 RTSP 内容吗?

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_To_-_Play_video_within_a_BlackBerry_smartphone_application.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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

樱&纷飞 2024-08-10 23:37:55

因此,经过很长一段时间,我确定 Blackberry Bold 9000 不支持 http 流媒体。我最终不得不(或者更确切地说,我的同事不得不)编写渐进式下载的自定义方法来模拟它。那好吧。

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.

孤凫 2024-08-10 23:37:55

您实际上应该能够进行流式传输。首先,您必须确保将正确的连接参数附加到您的 URL(即“;interface=wifi”表示 wifi 连接)。其次,您必须确保正在流式传输的文件不会太大。如果太大,您将收到一条 HTTP 错误,指出“文件太大”。为了解决这个问题,您需要缓冲(查看 DataSource API)。您应该将请求的大小限制在 1-2MB 左右。拉出该“块”后,您需要继续请求顺序块(具有单独的http连接)以继续填充缓冲区。我希望这有帮助

You should be able to stream actually. Firstly, you must make sure you are appending the correct connection parameters to your URL (ie. ";interface=wifi" 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 "file too large". 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 "chunk" you need to keep requesting sequential chunks (with separate http connections) to continue to fill you buffer. I hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文