Exoplayer不显示mp4视频

时间:2018-10-15 19:30:08

标签: exoplayer

嗨,我是android的初学者...我正在尝试在Exoplayer中显示mp4视频,但未显示任何内容

private void initializePlayer(Uri mediaUri){

    if (mExoplayer == null) {
        // Create a default TrackSelector
        DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

        // Create the player
        mExoplayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector);

        // Bind the player to the view.
        mPlayerView.setPlayer(mExoplayer);
        // Measures bandwidth during playback. Can be null if not required.
        // Produces DataSource instances through which media data is loaded.
        com.google.android.exoplayer2.upstream.DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getContext(), Util.getUserAgent(getContext(), "BakingApp"), bandwidthMeter);
        // This is the MediaSource representing the media to be played.
        MediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(mediaUri);
        // Prepare the player with the source.
        mExoplayer.prepare(videoSource);
        mExoplayer.setPlayWhenReady(true);
    }

}

0 个答案:

没有答案