播放MP4我试图得到一个MP4从SD卡播放。这是我的第二天。昨天它不会在所有的工作,今天是播放视频的第一秒出错的应用程序崩溃之前:android.view.WindowManager $ BadToxenException:无法添加窗口 - 令牌无效无效;你的活动正在运行?Android应用程序不会从SD卡
我在布局文件夹中的文件playvideo.xml这样:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<VideoView
android:id="@+id/myvideoview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
,并在Java代码中 - 只有短短的几行:
path = Environment.getExternalStorageDirectory() + "/videos/video.mp4";
Log.i("path", path);
setContentView(R.layout.playvideo);
VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview);
myVideoView.setVideoPath(path);
myVideoView.setMediaController(new MediaController(getBaseContext()));
myVideoView.requestFocus();
myVideoView.start();
就像我说的,视频播放一秒钟,然后应用程序崩溃。
任何想法?
谢谢。
对于这个错误,我们需要一个完整的活动代码。该代码 – user370305 2012-02-22 11:48:12
没有提供您的完整活动代码。 – 2012-02-22 12:02:15