2009-09-19 88 views
2

有什麼方法可以從服務器上流式傳輸和播放視頻文件?Blackberry上的視頻流

Blackberry是否提供任何內置視頻播放器,以便播放流式視頻?

回答

7

是的,你可以。有兩種方法以流BB設備上的視頻:使用標準的媒介應用

  • 使用的javax.microedition.media.Player從JSR-135

How To - Play video within a BlackBerry smartphone application

你可以在黑莓瀏覽器上測試它http://m.youtube.com
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

我使用此代碼,打開內置的播放器(無論是遠程和本地視頻):

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())); 
    } 
} 
+0

我認爲這隻適用於OS 6? – Ajibola 2013-06-03 00:32:22