Android7.1.2 "SoundPool: Unable to load sample"

0

I can not play mp3 file in my demo after I update my android system to 7.1.2.

I got the following error when soundpool start to load file.

02-08 11:04:49.413 12317-12336/? E/ACodec: Unable to instantiate a decoder for type 'audio/mpeg' with err 0xfffffffe.
02-08 11:04:49.413 12317-12336/? E/ACodec: signalError(omxError 0xfffffffe, internalError -2)
02-08 11:04:49.413 12317-12336/? E/MediaCodec: Codec reported err 0xfffffffe, actionCode 0, while in state 1
02-08 11:04:49.414 12317-12335/? E/SoundPool: Unable to load sample

here is my code in my demo:

private SoundPool soundPool;
private int soundId = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    SoundPool.Builder sBuilder = new SoundPool.Builder();
    //传入音频数量
    sBuilder.setMaxStreams(1);
    //AudioAttributes是一个封装音频各种属性的方法
    AudioAttributes.Builder attrBuilder = new AudioAttributes.Builder();
    //设置音频流的合适的属性
    attrBuilder.setLegacyStreamType(AudioManager.STREAM_SYSTEM);
    //加载一个AudioAttributes
    sBuilder.setAudioAttributes(attrBuilder.build());

    soundPool= sBuilder.build();
    soundId = soundPool.load(this,R.raw.music2,1);
    soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
        @Override
        public void onLoadComplete(SoundPool soundPool, int i, int i1) {
            Log.d("dvlee", "onLoadComplete");
            soundPool.play(soundId,1, 1, 1, 0, 1);
        }
    });
}


public void onBtn1(View view){
    Log.d("dvlee", "onBtn1:"+soundId);
    soundPool.play(soundId,1, 1, 1, 0, 1);
}
android
soundpool
asked on Stack Overflow Feb 8, 2018 by Lee David

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0