如何在Simplaexoplayer中播放M3U8?

时间:2019-12-08 10:08:28

标签: android streaming android-mediaplayer exoplayer2.x

我正在做媒体播放器,我的网址是.m3u8。我想在simpleexoplayer中玩,但不工作 其他没有扩展名m3u8的网址也可以正常工作。

请帮助我

DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(
                this,
                null,
                DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF);
        TrackSelector trackSelector = new DefaultTrackSelector();
        simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(
                renderersFactory,
                trackSelector);
        String userAgent = Util.getUserAgent(this, "Play Audio");
        ExtractorMediaSource mediaSource = new ExtractorMediaSource(
                Uri.parse(url), // file audio ada di folder assets
                new DefaultDataSourceFactory(this, userAgent),
                new DefaultExtractorsFactory(),
                null,
                null);



        simpleExoPlayer.prepare(mediaSource);
        simpleExoPlayer.setPlayWhenReady(true);

0 个答案:

没有答案