播放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