public class LiveVideoPlayerActivity extends Activity {
VideoView videoView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String httpLiveUrl = "http://aj.lsops.net/live/aljazeer_en_high.sdp/playlist.m3u8";
videoView = (VideoView) findViewById(R.id.myVideoView);
videoView.setVideoURI(Uri.parse(httpLiveUrl));
videoView.setMediaController(new MediaController(this));
videoView.requestFocus();
videoView.start();
}
}
运行代码时,会出现强制关闭窗口。我正在使用Vitamio lib for Media。有什么帮助吗?
03-22 11:23:04.723: D/AndroidRuntime(275): Shutting down VM
03-22 11:23:04.723: W/dalvikvm(275): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-22 11:23:04.753: E/AndroidRuntime(275): FATAL EXCEPTION: main
03-22 11:23:04.753: E/AndroidRuntime(275): java.lang.RuntimeException: Unable to start activity ComponentInfo{android.liveplayer/android.liveplayer.LiveVideoPlayerActivity}: java.lang.ClassCastException: android.widget.VideoView
03-22 11:23:04.753: E/AndroidRuntime(275): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-22 11:23:04.753: E/AndroidRuntime(275): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-22 11:23:04.753: E/AndroidRuntime(275): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-22 11:23:04.753: E/AndroidRuntime(275): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-22 11:23:04.753: E/AndroidRuntime(275): at android.os.Handler.dispatchMessage(Handler.java:99)
03-22 11:23:04.753: E/AndroidRuntime(275): at android.os.Looper.loop(Looper.java:123)
03-22 11:23:04.753: E/AndroidRuntime(275): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-22 11:23:04.753: E/AndroidRuntime(275): at java.lang.reflect.Method.invokeNative(Native Method)
03-22 11:23:04.753: E/AndroidRuntime(275): at java.lang.reflect.Method.invoke(Method.java:521)
03-22 11:23:04.753: E/AndroidRuntime(275): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-22 11:23:04.753: E/AndroidRuntime(275): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-22 11:23:04.753: E/AndroidRuntime(275): at dalvik.system.NativeStart.main(Native Method)
03-22 11:23:04.753: E/AndroidRuntime(275): Caused by: java.lang.ClassCastException: android.widget.VideoView
03-22 11:23:04.753: E/AndroidRuntime(275): at android.liveplayer.LiveVideoPlayerActivity.onCreate(LiveVideoPlayerActivity.java:20)
03-22 11:23:04.753: E/AndroidRuntime(275): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-22 11:23:04.753: E/AndroidRuntime(275): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-22 11:23:04.753: E/AndroidRuntime(275): ... 11 more
答案 0 :(得分:3)
你需要在xml中更改你的VideoView以使用Vitamio视频视图,所以你的xml应该是
<io.vov.vitamio.widget.VideoView
android:id="@+id/videoView"
/>
请注意“io.vov.vitamio.widget.VideoView”而不仅仅是VideoView。那是因为你使用Vitamio的自定义版而不是普通的Android版。
答案 1 :(得分:1)
你确定吗?
<{1>}中的,您有main.xml
或任何其他Videoview
,
你有View
并发布您的<VideoView android:id="@+id/myVideoView"/>
并检查此内容以获取参考... http://r00tsecurity.org/forums/topic/12059-android-videoview-example/
或http://android-coding.blogspot.in/2011/03/simple-example-using-videoview-to-play.html
答案 2 :(得分:0)
Vitamio io.vov.vitamio.widget.VideoView
代替Android android.widget.VideoView
。另外,在OnCreate()
:
if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this))
return;