从应用程序缓存目录播放视频
谁能解释为什么从我的应用程序缓存目录下载/播放视频不起作用,但从我的 SD卡下载/播放相同的视频却起作用?
注:该视频正在下载中。我在调用 VideoView.setVideoPath(...)
之前保存到内存。
// Works
File file = new File(Environment.getExternalStorageDirectory(), "vid-test.3gp");
// Does not work
File file = new File(getCacheDir(), "vid-test.3gp");
在每种情况下,相关文件确实存在。
如果我尝试调用 VideoView.setVideoURI(...)
并将视频“流式传输”到我的 VideoView
,则无论是否有效,都可能会失败。
谁能解释这种行为?
Can anyone explain why downloading/playing a video from my applications cache directory does not work, but downloading/playing the same video from my sdcard does work?
Note: this video is being downloaded. I am saving to memory before calling VideoView.setVideoPath(...)
.
// Works
File file = new File(Environment.getExternalStorageDirectory(), "vid-test.3gp");
// Does not work
File file = new File(getCacheDir(), "vid-test.3gp");
In each case the file in question does exist.
If I attempt to call VideoView.setVideoURI(...)
and "stream" the video to my VideoView
, it is hit and miss whether or not it will work.
Can anyone explain this behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是一个权限问题。这是一个工作片段:
It's probably a permission issue. Here is a working snipped: