0

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

Naveen Kumar M
  • 7,497
  • 7
  • 60
  • 74
Chris Maverick
  • 928
  • 1
  • 8
  • 18

1 Answers1

0

"Most likely, the tap sound got a AUDIO_OUTPUT_FLAG_FAST in order to use low-latency playback if possible, but the AudioTrack class considered the track settings to be incompatible with the low-latency audio output, so the flag got removed and the track got treated as if the flag hadn't been set to begin with. So I wouldn't consider this to be something to worry about.

As for the reason why the flag got denied; I'd still say that the most probable reason is a sample rate mismatch. The log in the question you linked to appears to have been added in this commit to the AOSP. But if we look at the master branch of the code base used on many Qualcomm-based devices we see that it still has the "AUDIO_OUTPUT_FLAG_FAST denied by client" log in the case were there was a sample rate mismatch. Which logs you get depends on the exact implemetation running on your device (i.e. which device and Android version you're running)."

Answer was taken from here. Credits to Michael

This most like is caused by mismatch on the sample rate and it should not affect the program runtime IF it is running on an actual device. Ref:

Community
  • 1
  • 1
MetaSnarf
  • 5,857
  • 3
  • 25
  • 41