黑莓上的视频流

时间:2009-09-19 14:32:56

标签: blackberry streaming video-streaming

有没有办法从服务器流式传输和播放视频文件?

黑莓是否提供任何可以播放流式视频的内置视频播放器?

2 个答案:

答案 0 :(得分:7)

是的,你可以。有两种方法可以在bb设备上流式传输视频:

  • 使用jsr-135
  • 中的javax.microedition.media.Player
  • 使用标准媒体应用

请参阅How To - Play video within a BlackBerry smartphone application

您可以在http://m.youtube.com上通过BlackBerry浏览器进行测试 How to watch YouTube Videos on BlackBerry Bold 9000

您必须使用WAP或WiFi协议进行RTSP:
Media application will switch to WAP for streaming media

Media types supported on the BlackBerry smartphone

答案 1 :(得分:1)

我正在使用此代码打开内置播放器(包括远程和本地视频):

private void handleVideo(String url) {
    try {
        Invocation inv = new Invocation();

        if (url.startsWith("local")) {
            url = url.substring(url.lastIndexOf('/'));
            InputStream is = getClass().getResourceAsStream("/res" + url);
            if (is == null)
                return;
            // move resource to device memory so that we get an url which
            // can be passed to Invocation
            url = "file:///store/home/user/videos" + url;
            FileConnection dest = (FileConnection) Connector.open(url);
            if (!dest.exists())
                dest.create();
            dest.setWritable(true);
            OutputStream o = dest.openOutputStream();
            byte[] buf = new byte[8192];
            int length = -1;
            while ((length = is.read(buf)) > 0)
                o.write(buf, 0, length);
            o.close();
            is.close();
            dest.close();
        }

        inv.setID(BlackBerryContentHandler.ID_MEDIA_CONTENT_HANDLER);
        inv.setArgs(new String[] { BlackBerryContentHandler.MEDIA_ARGUMENT_VIEW_MEDIA });
        inv.setURL(url);
        Registry reg = Registry.getRegistry(getClass().getName());
        reg.invoke(inv);
    } catch (Throwable e) {
        UiApplication.getUiApplication().invokeAndWait(new RunnableDialog(e.getMessage()));
    }
}