有没有办法从服务器流式传输和播放视频文件?
黑莓是否提供任何可以播放流式视频的内置视频播放器?
答案 0 :(得分:7)
是的,你可以。有两种方法可以在bb设备上流式传输视频:
请参阅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
答案 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()));
}
}