21 API LEVEL下的EXOPlayer中的HLS问题

时间:2019-01-08 18:52:11

标签: streaming live hls exoplayer

我正在尝试在我的项目中实现EXO Player,使用api 21和下一个api一切都很好...但是使用较低的API则无法正常工作...没有声音,没有视频。我的HLS来源可能有问题吗?与另一个HLS链接在Android 4.1-4.4.4中一切正常,但对于我的不是。请帮助。预先感谢。

SimpleExoPlayerView exoPlayerView;
SimpleExoPlayer exoPlayer;

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

        exoPlayerView = findViewById (R.id.exo_player_view);
        try {
            BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter ();
            TrackSelector trackSelector = new DefaultTrackSelector (new AdaptiveTrackSelection.Factory (bandwidthMeter));
            exoPlayer = ExoPlayerFactory.newSimpleInstance (this, trackSelector);

            String videoURL = "https://edge.hls.hitbox.tv/hls/jurnalfm/index.m3u8?st=ebud8l2g3zFPAw04yvXQUg;ci=mJDMqSzYIK6s3Nru_cbaBw";
            Uri videoURI = Uri.parse (videoURL);

            DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory ("exoplayer_video");
            MediaSource mediaSource;
            mediaSource = new HlsMediaSource.Factory (dataSourceFactory).createMediaSource (videoURI);

            exoPlayerView.setPlayer (exoPlayer);
            exoPlayer.prepare (mediaSource);
            exoPlayer.setPlayWhenReady (true);
        } catch (Exception e) {
            Log.e ("MainAcvtivity", " exoplayer error " + e.toString ());
        }
}

0 个答案:

没有答案