首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >MediaPlayer setDataSource,最好使用path还是FileDescriptor?

MediaPlayer setDataSource,最好使用path还是FileDescriptor?
EN

Stack Overflow用户
提问于 2012-03-09 05:59:33
回答 2查看 32.6K关注 0票数 21

假设我有一个文件的完整路径。将该文件加载到MediaPlayer中,哪种方法更好?

String filePath = "somepath/somefile.mp3";
mediaPlayer.setDataSource(filePath);

String filePath = "somepath/somefile.mp3";
File file = new File(filePath);
FileInputStream inputStream = new FileInputStream(file);
mediaPlayer.setDataSource(inputStream.getFD());
inputStream.close();

有关系吗?简单地使用路径似乎更容易,但是有理由为了使用FileDescriptor而做额外的工作吗?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9625680

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档