我用下面的代碼從MJPG纜加載視頻:使用MediaPlayer的加載遠程視頻
Uri uri = Uri.parse("my server url");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
如果我使用Opera瀏覽器,打開遠程URL這僅適用。 現在我要玩相同的視頻我的手機上:
Uri uri = Uri.parse("url");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://url/?action=stream"), "multipart/x- mixed-replace;boundary=boundarydonotcross");
startActivity(intent);
我面臨着以下問題:
07-24 10:34:13.750: E/AndroidRuntime(27778): FATAL EXCEPTION: main
07-24 10:34:13.750: E/AndroidRuntime(27778): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.media/com.example.media.MainActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://xxxxxxx.xxx/ typ=multipart/x-mixed-replace;boundary=boundarydonotcross }
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.os.Handler.dispatchMessage(Handler.java:99)
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.os.Looper.loop(Looper.java:130)
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.app.ActivityThread.main(ActivityThread.java:3687)
07-24 10:34:13.750: E/AndroidRuntime(27778): at java.lang.reflect.Method.invokeNative(Native Method)
07-24 10:34:13.750: E/AndroidRuntime(27778): at java.lang.reflect.Method.invoke(Method.java:507)
07-24 10:34:13.750: E/AndroidRuntime(27778): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
07-24 10:34:13.750: E/AndroidRuntime(27778): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
07-24 10:34:13.750: E/AndroidRuntime(27778): at dalvik.system.NativeStart.main(Native Method)
07-24 10:34:13.750: E/AndroidRuntime(27778): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://xxxxxxx.xxx/ typ=multipart/x-mixed-replace;boundary=boundarydonotcross }
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.app.Activity.startActivityForResult(Activity.java:2827)
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.app.Activity.startActivity(Activity.java:2933)
07-24 10:34:13.750: E/AndroidRuntime(27778): at com.example.media.MainActivity.onCreate(MainActivity.java:26)
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-24 10:34:13.750: E/AndroidRuntime(27778): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
07-24 10:34:13.750: E/AndroidRuntime(27778): ... 11 more
我一直在使用MediaPLayer.create(this,myuri)
也嘗試過,但它一直告訴我不能在打開文件客戶端。
檢查這 - http://www.hrupin.com/2011/09/sample-streaming-video-mediaplayer-or-how-to-stream-視頻從-URL功能於機器人。您可以從這裏下載完整的源碼 – AkashG 2012-07-24 05:21:44
視頻本身不是一個完整的文件。它本身是從網絡攝像頭流式傳輸的。 – user1179510 2012-07-24 05:37:35