Intent.ACTION_VIEW视频:外部存储视频和QUOT;抱歉,该视频无法播放"但是在标准Android播放器,它是可玩 [英] Intent.ACTION_VIEW video: external storage video "Sorry, this video cannot be played", but in regular android player, it is playable
问题描述
所以,我打从外部存储器(SD卡)的视频,我在播放视频时的一个问题,这是我的code:
So I'm playing a video from external storage(sdcard), I'm having a problem with playing the video and this is my code:
Uri uri = Uri.parse(url);
intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "video/*");
提示抱歉,该视频无法播放,但在标准Android播放器,它是可玩的。我打印的网址,这是我的了:
It prompts "Sorry, this video cannot be played", but in regular android player, it is playable. I printed the url and this is what I got:
VideoPlayer url: file:///mnt/sdcard/foldername/video-2012-12-26-21-26--44.mp4
时它与URI的问题吗?如果没有,你可以点我到正确的方向。另外,如果我尝试有一个点一个文件夹名()。我将有一个问题?
Is it a problem with the uri? If no, can you point me to the right direction. Also if I try a foldername that have a dot(.) will I have a problem?
url = file:///mnt/sdcard/Android/data/com.example.project/video-2012-12-26-21-26--44.mp4
感谢。
编辑:由于我的真正的问题不解决,没有人希望再回答,我打开了一个新的问题:
<一href=\"http://stackoverflow.com/questions/14138130/android-video-is-playable-from-gallery-but-when-i-play-it-using-intent-action-v\">Android:视频从画廊可玩的,但是当我使用Intent.ACTION_VIEW类型的视频玩它,不能发挥
Since my real problem was not solve, and nobody want to answer anymore, I open up a new question: Android: Video is playable from gallery but when I play it using Intent.ACTION_VIEW type video, cannot play
部分回答我的问题:
出现问题的原因命名约定。我认为球员不接受,其文件名称 - 在里面。于是我通过更改文件名格式解决了这个问题。
The problem occurs because of naming convention. I think the player doesn't accept file names that have "--" in it. So I solved this problem by changing the file name format.
//声明:我没有一个完整的解释和来源,但这些信息只是从我的解决方法推导出
//Disclaimer: I don't have a full explanation and source but this info is just deduced from my workaround.
推荐答案
请确保您传递正确的SD卡路径意图。最好的办法是使用<一个href=\"http://developer.android.com/reference/android/os/Environment.html\">Environment.getExternalStorageDirectory()获取SDCARD路径而不是静态传递字符串:
make sure you are passing right sdcard path with Intent. best way is use Environment.getExternalStorageDirectory() for getting SDCARD path instead of passing static string :
intent = new Intent(Intent.ACTION_VIEW);
File sdCard = Environment.getExternalStorageDirectory();
File file = new File(sdCard, "/foldername/video-2012-12-26-21-26-44.mp4");
intent.setDataAndType(Uri.fromFile(file), "video/*");
startActivity(intent);
这篇关于Intent.ACTION_VIEW视频:外部存储视频和QUOT;抱歉,该视频无法播放&QUOT;但是在标准Android播放器,它是可玩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!