我正在尝试创建一个应用程序,用户可以在其中播放应用内视频(已打包在应用程序中的视频)。否SDCard
或在线流媒体正在进行。
但无论我使用什么策略,我都无法.mp4
在我的应用程序中运行简单的视频。我试过将视频放在assests
文件夹中,但没有运气。我试过将视频放在res/raw
文件夹中,再次没有运气。
每次我运行应用程序时都会显示 - 无法播放此视频。
之前我只是VideoView
用来运行视频,现在我正在使用MediaController
错误VideoView
消息不断出现
请帮忙,因为它困扰了很长一段时间,无论我使用什么解决方案,我仍然无法运行简单的视频。
我的活动代码:
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MediaController mediac;
VideoView video1;
mediac = new MediaController(this);
video1 = (VideoView) findViewById(R.id.vv01);
video1.setMediaController(mediac);
mediac.setAnchorView(video1);
video1.setVideoURI(Uri.parse("android.resource://com.example.test/raw/aa"));
video1.start();
}
我的 xml 文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<VideoView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/vv01"
android:contentDescription="@string/app_name"
/>
</LinearLayout>
我尝试运行应用程序时的日志猫:
08-26 13:27:31.023: I/dalvikvm(624): threadid=3: reacting to signal 3
08-26 13:27:31.593: I/dalvikvm(624): Wrote stack traces to '/data/anr/traces.txt'
08-26 13:27:31.643: I/dalvikvm(624): threadid=3: reacting to signal 3
08-26 13:27:31.913: I/dalvikvm(624): Wrote stack traces to '/data/anr/traces.txt'
08-26 13:27:31.923: D/dalvikvm(624): GC_CONCURRENT freed 147K, 3% free 9345K/9607K, paused 7ms+7ms
08-26 13:27:32.053: I/dalvikvm(624): threadid=3: reacting to signal 3
08-26 13:27:32.083: I/dalvikvm(624): Wrote stack traces to '/data/anr/traces.txt'
08-26 13:27:32.533: I/dalvikvm(624): threadid=3: reacting to signal 3
08-26 13:27:32.564: I/dalvikvm(624): Wrote stack traces to '/data/anr/traces.txt'
08-26 13:27:33.033: I/dalvikvm(624): threadid=3: reacting to signal 3
08-26 13:27:33.063: I/dalvikvm(624): Wrote stack traces to '/data/anr/traces.txt'
08-26 13:27:33.613: D/MediaPlayer(624): getMetadata
08-26 13:27:33.973: E/MediaPlayer(624): error (1, -2147483648)
08-26 13:27:34.093: E/MediaPlayer(624): Error (1,-2147483648)
08-26 13:27:34.093: D/VideoView(624): Error: 1,-2147483648