I'm trying to play music from a ListView (which takes data from a file path). But everytime i click, it gets an error like this:
09-14 09:58:42.996 1229-1276/? W/AudioTrack﹕ AUDIO_OUTPUT_FLAG_FAST denied by client
Even I use file path directly, it still doesn't work. Here is my code:
private MediaPlayer mMediaPlayer;
private File dir = new File(Environment.getExternalStorageDirectory() + "/MyOwnMusicFolder");
private File[] files;
public void playSong(int position){ //position of the item in the ListView
if(mMediaPlayer !=null) {
if(mMediaPlayer.isPlaying()){
mMediaPlayer.pause();
}
try {
mMediaPlayer.setDataSource(dir + File.separator + files[position].getName());
mMediaPlayer.prepare();
mMediaPlayer.start();
}
catch (IOException e){
//something...
}
}
}
Edit: I'm using Android Studio + Android Studio Emulator
Edit 2: my mp3 files are completely normal