-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Anybody found an event to detect when a track has ended playing? #71
Comments
You are on the right track with You can see a bunch of example code in the tests directory for this plugin (eg. tests_auto.js). For detecting when a track has ended, this is what I used (simplified from the tests_auto.js): media.addUpdateListener(function listener (isAlive) {
if (media.playerState === chrome.cast.media.PlayerState.IDLE) {
if (media.idleReason === chrome.cast.media.IdleReason.FINISHED) {
// The current media has finished playing by reaching the end
}
if (media.idleReason === chrome.cast.media.IdleReason.CANCELLED) {
// The current media has been stopped (media.stop)
}
if (media.idleReason === chrome.cast.media.IdleReason.INTERRUPTED) {
// The current media has ended because new media has been loaded (media.queueJumpToItem)
}
}
}); Here is some of the relevant documentation: |
That is great, thank you again. |
Ahh, yep, easy mistake to make! |
Not an issue, but a question:
The only post I could find is this one https://stackoverflow.com/questions/19645972/chromecast-sdk-android-is-there-a-way-to-check-whether-the-media-playing-on but I wonder if any of you have used a different approach, it looks much for what it is.
The documentation has https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media#addUpdateListener but does not provide such a action.
Thanks!
The text was updated successfully, but these errors were encountered: