如何使用已加密的ExoPlayer播放在线视频?

时间:2019-05-17 07:18:36

标签: android encryption exoplayer exoplayer2.x

我想使用ExoPlayer播放加密的视频我对ExoPlayer还是陌生的,对此我不太了解。我找到了一些链接[https://stackoverflow.com/a/54247524/9789670],但这些链接无法正常工作。我需要一些帮助来解决此问题

1 个答案:

答案 0 :(得分:0)

Use this code for play video
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(null);
            TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
            SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(mContxt, trackSelector);

            DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(mContxt, 
 Util.getUserAgent(mContxt, "CloudExoplayer"));
            Uri videoUri = Uri.parse(url);
            MediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
                    .createMediaSource(videoUri);
            player.prepare(videoSource);
            player.setRepeatMode(Player.REPEAT_MODE_ALL);
            exoplayer.setPlayer(player);
            exoplayer.requestFocus();
            exoplayer.setPlayWhenReady(true);