安卓:视频是从画廊可玩的,但是当我使用Intent.ACTION_VIEW类型的视频玩它,不能玩 [英] Android: Video is playable from gallery but when I play it using Intent.ACTION_VIEW type video, cannot play
问题描述
<一个href=\"http://stackoverflow.com/questions/14133140/intent-action-view-video-external-storage-video-sorry-this-video-cannot-be-pl/\">Here是我原来的问题
我已经实现了答案存在,但仍是问题仍然存在。
I've implemented the answer there but still the problem persist.
下面是要点:
所以,我打从外部存储器(SD卡)的视频,我在播放视频时的一个问题,这是我的code:
Here is the gist: 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/*");
提示抱歉,该视频无法播放,但在画廊,这是可玩。我打印的网址,这是我的了:
It prompts "Sorry, this video cannot be played", but in the gallery, 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
该文件从我得到的答案存在。但仍是问题仍然存在,我不知道哪里出了问题。
The file exist from the answer that I got. But still the problem persist, and I have no idea what went wrong.
任何有识之士为AP preciated。谢谢
Any insight is appreciated. Thanks
编辑:对于那些谁没有看到的第一个问题的答案。我已经实现了这个:
To those who didn't see the answer in the first question. I've already implemented this:
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);
该文件存在,因为我已经签了。我不知道是否有与该文件命名约定的一个问题。
The file exist since I've checked it. I'm wondering if there is a problem with the file naming convention.
另外,我从我的设备,三星Galaxy王牌,Android的2.3.6,4.2 SDK编译调试。
Also I'm debugging from my device, Samsung Galaxy Ace, Android 2.3.6, compiling with 4.2 sdk.
编辑2:
我试着重新命名视频成简单的一个,现在的影视作品,我的猜测是,该文件有文件名长度的限制或命名约定。
Edit 2: I've tried renaming the video into simpler one and now the video works, my guess is that the the file has a filename length limitation or an naming convention.
推荐答案
我已经尝试了不同的解决方案。但我想的发生是因为命名约定的问题。我曾尝试重命名文件到一个简单的格式和它的作品。还用我的原文件名的问题是,我有一个 - ,在文件名
I've tried different solution. But I guess the problem occurred because of naming convention. I have tried renaming the file into a simpler format and it works. Also the problem with my original file name is that I have a "--" in the file name.
这篇关于安卓:视频是从画廊可玩的,但是当我使用Intent.ACTION_VIEW类型的视频玩它,不能玩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!