播放位于资源文件夹中的媒体文件 [英] Play media file located in assets folder

查看:77
本文介绍了播放位于资源文件夹中的媒体文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在android项目的原始文件夹中有一组媒体文件,这些文件快速加载并在点击按钮上播放。我需要添加这些文件的更多变体并将它们分类到文件夹中,但显然原始文件夹不支持文件夹。我是否能够从资源文件夹中快速加载这些文件并在按钮单击时播放它们?如果是这样,如何?

解决方案

确实。

'资产'文件夹将与APK一起发布,其中包含所有应用程序所需的原始文件,例如:文本文件(.txt),非Android XML文件(.xml),音频文件(.wav,.mp3,.mid)......;那些不能像往常一样放入'res'文件夹。



参见文档 [ ^ ]



请参阅访问资产文件夹下文件的示例。

http://www.javacodegeeks.com/2012/02/android- read-file-from-assets.html [ ^ ]

http://stackoverflow.com/questions/12387637/how-to-access-file-under-assets-folder-in-android [ ^ ]



-KR

I currently have a set of media files in the raw folder of the android project that are loaded quickly and played on button clicked. I need to add more variations of these files and categorize them into folders, but apparently the raw folder does not support folders. Would I be able to quickly load these files from the assets folder and play them on button click? If so, how?

解决方案

Yes, indeed.
‘Assets’ folder will be distributed along with the APK, which contains all the raw files you need for application, such as: text files (.txt), non-Android XML files (.xml), Audio files (.wav, .mp3, .mid)…; those cannot be put into ‘res‘ folder as usual.

See the documentation[^] in developer.android.com

See the examples for accessing a file which is under assets folder.
http://www.javacodegeeks.com/2012/02/android-read-file-from-assets.html[^]
http://stackoverflow.com/questions/12387637/how-to-access-file-under-assets-folder-in-android[^]

-KR


这篇关于播放位于资源文件夹中的媒体文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆