CastPlayer returns wrong currentMediaItemIndex when cast is stopped
@tonihei is already working on this.
Since May 16, 2024.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
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
- open demo-cast app
- add three first media samples to the playlist
- click the play button
- click the next button
- start casting
- seek to the middle of the current media
- start casting
so far everything is correct, media starts to play from the correct position (playlist index is also correct)
- stop casting
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
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.