从阅读Android上的资产音频文件 [英] Read audio file from assets on Android

查看:130
本文介绍了从阅读Android上的资产音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想播放存储在资产目录中的音频文件,但在此之前我甚至读取一个文件,我得到的错误出错java.io.FileNotFoundException:track.mp3。以下是我读它:

I am trying to play audio files stored in the assets directory, but before I even read a file I get the error "error occured java.io.FileNotFoundException: track.mp3". Here's how I read it:

AssetFileDescriptor afd = getAssets().openFd("track.mp3");

我读了很多在互联网上的描述,但没有成功。

I read a lot of descriptions on the internet, but no success.

推荐答案

右键单击track.mp3的文件,与重构>运行命令,你的文件移动到另一个目录(如水库 )。与此相同的命令,将其移回到你的资产目录。对我来说,它的工作原理。

Right-click your "track.mp3" file, with the "Refactor" > "Move" command, move your file to another directory (e.g. "res"). With this same command, move it back to your "assets" directory. For me, it works.

这篇关于从阅读Android上的资产音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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