我想使用以下代码从android缓存文件夹播放视频文件:
String cacheDir = getApplicationContext().getCacheDir().getAbsolutePath();
File outFile = new File(cacheDir, "intro.mp4");
vvIntro.setVideoPath(cacheDir+"/intro");
vvIntro.start();
但我收到了错误:
07-05 20:14:21.896: E/MediaPlayer(1251): error (1, -2147483648)
07-05 20:14:21.928: I/Choreographer(1251): Skipped 79 frames! The application may be doing too much work on its main thread.
07-05 20:14:22.186: D/gralloc_goldfish(1251): Emulator without GPU emulation detected.
07-05 20:14:22.496: E/MediaPlayer(1251): Error (1,-2147483648)
07-05 20:14:22.496: D/VideoView(1251): Error: 1,-2147483648
文件已存在且所需的柿子如下所示:
答案 0 :(得分:2)
您创建一个指向MP4文件的File
对象,然后完全忽略该File
个对象,并提供vvIntro
的无效路径。相反,尝试:
File outFile = new File(getCacheDir(), "yourVideoName.mp4");
vvIntro.setVideoPath(outFile.getAbsolutePath());
vvIntro.start();
看看是否有帮助。
答案 1 :(得分:1)
您可以使用我的简单库AndroidVideoCache。它允许同时传输流和缓存视频。
答案 2 :(得分:0)
您可以设置Uri:
Uri uri = Uri.parse(getApplicationContext().getCacheDir()+"/video.mp4") ;
videoView.setVideoURI(uri);
videoView.start();