MediaPlayer的不能从程序数据文件夹播放音频文件? [英] MediaPlayer cant play audio files from program data folder?
问题描述
当我录制来自MIC我的音乐和存储文件/数据/数据/ .....为什么 的MediaPlayer无法播放此文件?如果我改变目的地/ SD卡/ ..... - 所有的伟大工程。我做错了什么?我没有发现 限制对MediaPlayer的。设备 - 三星T959(银河S) 谢谢,我希望有人知道的解决方案......
When i record my audio from MIC and store file in /data/data/..... why MediaPlayer can't play this file ? If i change destination to / sdcard/..... - all works great. I do something wrong ? I not found limitation for MediaPlayer. Device - Samsung T959 (Galaxy S) Thanks, i hope anybody know solution....
推荐答案
我有同样的问题...每当我使用的setDataSource与文件路径,这是行不通的;继续得到IOException异常。
i had the same issues... whenever i used setDataSource with filepaths, it would not work; kept getting IOException.
改变我的code使用的setDataSource(的FileDescriptor)做的工作......而有了这个,我没有将文件复制到SD卡之类的东西。
changing my code to use setDataSource(FileDescriptor) does work... and with this i don't have to copy the files to SDCard or anything like that.
所以,用一个简单的文件对象,创建一个新的FileInputStream,并通过实际的文件描述符作为数据源,如下所示:
So, with a simple File object, create a new FileInputStream and pass the actual file descriptor as data source as in:
setDataSource((new FileInputStream(myFileInstance)).getFD());
创建输入流拉文件数据到内存中,从而地址/数据/数据访问冲突。
creating an input stream pulls the file data into memory and thereby addresses /data/data access violations.
这篇关于MediaPlayer的不能从程序数据文件夹播放音频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!