Player.md - is there something like getTime() or isEnded() ? Would be nice with list of functions available that can be accessed with JS

I want to know when a video is ended.

I have tried addEventListener() with “ended”, “videoEnded” and also tried to find functions like getTime() or similar.

Can anyone help? The documentation on github seems a bit outdated. For instance videoSeek() is not documented.

https://github.com/justintv/Twitch-API/blob/master/player.md

You can use onlineStatus to determine if video is playing, or the eventsCallback flashvar to get a variety of events, including offline.

I use this for Vods not live broadcast.

onlineStatus() returns unknown for vods.

What are the events? Is there a list?

Edit:
I have managed to set up the eventsCallback properly. However the only events called are playerInit, videoLoaded and videoPlaying. There are no events triggered for play/pause/ended/etc. Is there something I am missing or is this simply not implemented?

Available events are: offline, online, adCompanionRendered, loginRequest, mouseScroll, playerInit, popout, tosViolation, viewerCount, seekFailed, videoLoading, videoPlaying, adFeedbackShow, adUnfilledStart, and adUnfilledEnd.

So no, there seems to be no videoEnded event. Sorry.

Hm. Well that was a bit disappointing.

I really need to figure out when a vod has ended. I just tried testing if isPaused() == true when the video has ended, but it is false.

I was toying with the idea of using an incrementing number and comparing it with vod length, but this doesn’t work if you seek and I doubt it works if there is buffering.

Any ideas?

There is a method called getVideoTime(), which I assume you could test for in relation to vod length?
There are several undocumented methods regarding the player. It is unclear if this is intended or not.

I love you <3

That was exactly what I was looking for.

I’m setting the event listeners in js in my UIWebview for online,offline,ended,pause,and play.
I don’t get events fired for when the broadcaster comes online/offline or ended when they end the stream, but I do get events for pause and play.
Does online/offline/ended work?

Since the old player was removed from Twitch’s API documentation and is now unsupported, it might be broken. Twitch only offers their new HTML5 iframe player, which does not yet have a public API. To get notification when the channel goes online or offline, you may need to resort to polling Twitch’s API.

There is an interactive embed for the new player available.