我尝试使用预构建的库,但无法执行,我在-FFmpegMediaPlayer mp = new FFmpegMediaPlayer();上出错

或者有人可以推荐优质的Android MediaPlayer(minSdkVersion> = 9)库来播放流音频吗?

最佳答案

GIT URL for FFmpegMediaPlayer

有示例代码:

    FFmpegMediaPlayer mp = new FFmpegMediaPlayer();
mp.setOnPreparedListener(new FFmpegMediaPlayer.OnPreparedListener() {

    @Override
    public void onPrepared(FFmpegMediaPlayer mp) {
        mp.start();
    }
});
mp.setOnErrorListener(new FFmpegMediaPlayer.OnErrorListener() {

    @Override
    public boolean onError(FFmpegMediaPlayer mp, int what, int extra) {
        mp.release();
        return false;
    }
});

try {
    mp.setDataSource("<some path or URL>");
    mp.prepareAsync();
} catch (IllegalArgumentException e) {
    e.printStackTrace();
} catch (SecurityException e) {
    e.printStackTrace();
} catch (IllegalStateException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

10-04 19:38