Embed player & seek function


I am trying to build something with twitch embed video player.

In short player.seek is not working as expected. Player does not seek where I tell him to, but it seeks to some time before that.

This is simple code snippet that illustrates the problem.

var player = new Twitch.Player(playerElementId, {
  video: videoId,
  controls: false,
  autoplay: false

// after 'ready' event
player.getCurrentTime();    // 30.89 as expected

// 0.5 seconds later
player.getCurrentTime();    // 27.5

I suspect that this is some weird problem with flash player in chrome so I added html5: true to options. I am using Chrome version 50.0.x.
When I added html5 option, player was no longer loading with this error in console.

Another weird thing is that flash player is working in Safari and seek is working as expected. Even html5 player is loading (probably because Safari is not strict with 'Access-Control-Allow-Origin` header), but error is shown in console.

I tried on Firefox Developer edition. Nothing works there :slight_smile: not even seeking on twitch progress bar and time is not updating.

Any help or feedback is appreciated.

The origin mismatch error is because you’re loading an HTTPS stream on an HTTP page. There was a similar thread yesterday: Twitch Chat Embed Error (HTTP vs HTTPS)

Where in your code are you calling the seek/getCurrentTime? If you’re calling it immediately after the ready event, the player may not register the call.

(At least the public version of) the experimental html5 player doesn’t support VOD playback at all in a normal secure browser environment. The VOD segments are “served for” secure.twitch.tv (Access-Control-Allow-Origin) but the player’s origin is player.twitch.tv so the browser quietly yells about it and doesn’t accept the segments. The native HLS players in Safari and Edge ignore it.

Thanks for reply, it does light things up a bit about html5 player. Any idea when will html5 player support VOD playback?

I created simple plnkr with seek flash player bug/problem.
When you press seek button you will see difference between time you want to seek to and time player actually seeks to.
Any idea why is player not seeking to exact time I pass to him?

I spoke with the dev team about the seeking behavior that you’re seeing. It’s to do with the way Flash does segmenting of video. When you seek to a time that isn’t on a boundary, the seek value will round to the closest segment boundary earlier in the VOD and that can be up to 4s of difference. Sorry for the confusion about that! I’ve added that on my list of things to add in the documentation. :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.