Home » Android » java – Exoplayer: Blank video playing on android version 9 and greater when using custom view-Exceptionshub

java – Exoplayer: Blank video playing on android version 9 and greater when using custom view-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment

Questions:

Exoplayer version:

implementation 'com.google.android.exoplayer:exoplayer:2.11.2'

when i am using exoplayer on custom slider, it is playing sound only.
However, on older versions (android 8 and less) it is playing perfectly.

LoadControl loadControl = new DefaultLoadControl();
        dataSourceFactory = buildDataSourceFactory();

        DefaultBandwidthMeter.Builder bandwidthMeter = new DefaultBandwidthMeter.Builder(getActivity());
        TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS,
                DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS,DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_MS,DEFAULT_BANDWIDTH_FRACTION);
        TrackSelector trackSelector = new DefaultTrackSelector(getActivity(),videoTrackSelectionFactory);


        RenderersFactory renderersFactory = ((ABCApplication) getActivity().getApplication())
                .buildRenderersFactory(true);

        // 2. Create the player
        player = ExoPlayerFactory.newSimpleInstance(getActivity(),renderersFactory, trackSelector, loadControl);
        playerView.setPlayer(player);

        playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
        playerView.setControllerAutoShow(true);
        playerView.setControllerHideOnTouch(true);
        playerView.setControllerShowTimeoutMs(1500);

        // This is the MediaSource representing the media to be played.
        MediaSource videoS = buildMediaSource(video.getUri());

        // Prepare the player with the source.
        player.prepare(videoS);
        player.setVolume(0f);
        player.addListener(this);
        player.setPlayWhenReady(false);
        player.addListener(this);
How to&Answers: