如何使用exo播放器播放mp3

时间:2015-11-27 06:42:31

标签: android mp3 exoplayer

请帮帮我,以下代码无效:

    // 1. Instantiate the player.
    mPlayer = ExoPlayer.Factory.newInstance(1);
    // 2. Construct renderer.
    Allocator allocator = new DefaultAllocator(1024);
    DataSource dataSource = new DefaultUriDataSource(self, null, "userAgent");
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(Uri.parse(mSongObj.getUrl()), dataSource, allocator, 1 * 1024);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);

    // 3. Inject the renderer through prepare.
    mPlayer.prepare(audioRenderer);

    // 4. Start playback.
    mPlayer.setPlayWhenReady(true);

    // Don’t forget to release when done!
    mPlayer.release();

非常感谢

0 个答案:

没有答案