androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.75k stars 418 forks source link

Exoplayer cannot play some videos on ChromeOS devices. #1263

Open BrLudington opened 7 months ago

BrLudington commented 7 months ago

Version

Media3 1.3.1

More version details

No response

Devices that reproduce the issue

Google Corsola Chromebook ChromeOS Version 123.0.6312.94 (Official Build) (64-bit)

Devices that do not reproduce the issue

Smart phones and tablets in general.

Reproducible in the demo app?

Not tested

Reproduction steps

Try to play the attached file through Exoplayer on a Chromebook.

The code used:

Uri video = Uri.parse(videoUrl);
MediaItem mediaItem = MediaItem.fromUri(video);
 player = new ExoPlayer.Builder(getContext()).build();

playerView.setPlayer(player);
player.setMediaItem(mediaItem);
player.setSeekParameters(SeekParameters.EXACT);

player.addListener(new Player.Listener() {
            @Override
            public void onIsPlayingChanged(boolean isPlaying) {
                updatePlayButtonState(true);
                scrubberView.updateProgressBar();
            }

 @Override
            public void onIsLoadingChanged(boolean isLoading) {
                scrubberView.updateProgressBar();
            }

@Override
            public void onPlaybackStateChanged(@Player.State int state) {
                if (state == Player.STATE_READY) {
                    // update positions of time stamps and maximum value of rotary scrubber
                    if (!mScrubbersReady) {
                        scrubberView.setUpScrubbers();
                        mScrubbersReady = true;
                    }
                }
                else if (state == Player.STATE_ENDED) {
                    pauseVideoPlayer();
                }
                else if (state == Player.STATE_BUFFERING) {
                    //Log.d("BUFFERING", "position: " + player.getCurrentPosition());
                }
            }

            @Override
            public void onSurfaceSizeChanged(int width, int height) {
                // ToDo: figure out what to do with the size of the draw view.
                setupView();
            }
        });

        player.setPlaybackSpeed(SettingsManager.getPlaybackSpeedFloat(getContext()));
        player.setPlayWhenReady(viewModel.getPlayWhenReady());
        player.seekTo(currentItem, playbackPosition);
        player.prepare();

        scrubberView.setPosition(playbackPosition);

Expected result

Like with Android smartphones and tablets, it should play just fine. For example using the Google Pixel Tablet, Galaxy Note 5, Pixel 4a, Pixel 7 pro, etc. all work.

Actual result

The screen remains black, the video never plays, even though it finds the video file. The duration it finds is also incorrect (saying it is 8 seconds long when the video is actually 13 seconds). There is no crash log or stacktrace.

EDIT: On some occasions it does call Exoplayer's onPlayerError. The PlaybackExceptionError reads

androidx.media3.exoplayer.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.640032, -1, null, [1080, 2340, 61.20777, ColorInfo(BT709, Limited range, SDR SMPTE 170M, false, 8bit Luma, 8bit Chroma)], [-1, -1]), format_supported=NO_EXCEEDS_CAPABILITIES

Media

https://github.com/androidx/media/assets/166638079/66b4aa73-9033-47b4-8130-5a12a4820aa6

This is just a video I had downloaded off of Youtube for testing purposes. There's other videos that end up having the same issue.

Bug Report

marcbaechinger commented 7 months ago

Looks like the media is not playable on that device: 1080, 2340, 61.20777 which is not supported by the device format_supported=NO_EXCEEDS_CAPABILITIES.

ExoPlayer actually ignores this hint and still tries to play content that is reported as exceeding capabilities. The result is undefined if you seem to confirm.

I'm not sure we can really help with this from the library side I'm afraid.

BrLudington commented 7 months ago

Well that sucks. Do you know of any way I can get Exoplayer to detect if it can't play a video more reliably? I would use the onPlayerError method, but that only seems to get called if I place a breakpoint when debugging and let a few seconds pass.