androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
Apache License 2.0
1.38k stars 324 forks source link

CastPlayer returns wrong currentMediaItemIndex when cast is stopped #1361

Open ziem opened 2 months ago

ziem commented 2 months ago

Version

Media3 release branch

More version details

1.3.1

Devices that reproduce the issue

Samsung Z Fold 4 (Android 14)

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

so far everything is correct, media starts to play from the correct position (playlist index is also correct)

media starts to play from the beginning which is incorrect

Expected result

Switching between local and cast players should correctly restore the current index and position.

Actual result

Currently, it works fine when switching from local player to cast player, but the position is reset when switching from cast player to local player.

I'm not sure why, but when the cast is disconnected, CastPlayer loses the current media index. getCurrentMediaItemIndex() starts to return 0.

I saw some kind of index checking in the demo app https://github.com/androidx/media/blob/release/demos/cast/src/main/java/androidx/media3/demo/cast/PlayerManager.java#L285-L299, but this workaround seems to be not good enough. I can observe the same behavior in my codebase.

Media

HLS (adaptive): Apple 4x3 basic stream HLS (adaptive): Apple 16x9 basic HLS (1280x720): Designing For Google Cast

Bug Report

tonihei commented 1 month ago

Thanks for reporting. I'll mark it as a bug, but we are not likely to get around to look into soon. If you see an easy fix to solve it and want to send a PR, feel free to do so.