目录存储在Android的音频文件音频文件、目录、Android

2023-09-04 10:05:00 作者:不走回头路,不做多情人

我是新开发的机器人,和我周围的盘算我的路。

I am new to developing for Android, and am figuring my way around.

我想根据一个按钮的点击播放音频文件。我已经定义了 onClickListener()方法和布局文件。当我添加的WAV文件的 RES / 目录中,我得到以下生成错误:

I want to play an audio file based on the click of a button. I have defined the onClickListener() method and the layout file. When I add the wav files to the res/ directory, I get the following build error:

invalid resource directory name temp.wav /hello/res line 1  Android AAPT Problem

我的问题是: 1.我需要存储的音频文件目录是什么?目前,他们在res /文件夹。 2.另外, mp.setDataSource(/ RES / temp.wav)来调用媒体播放器的正确方法?

My question is as follows: 1. What directory do I need to store audio files in? Currently they are in the res/ folder. 2. Also, mp.setDataSource("/res/temp.wav") the correct way to invoke the media player?

谢谢, 斯利拉姆

推荐答案

不要把媒体文件里面 RES /

把你的文件(temp.wav)一个名为/ SD卡/音频文件夹中(如果您使用的是仿真器)。

Put your files(temp.wav) in a folder named /sdcard/audio(if you are using an emulator).

和做到这一点:

mp.setDataSource("/sdcard/audio/temp.wav");