Skip to main content

API playback changes

ยท 2 min read
Stefan Benicke

We've made changes to the playbacks API that you need to be aware of!

tl;dr
  • play_id is generated if omitted
  • playback_update sequence has changed
  • replacement_id takes userId, not clientId
  • EyesonJS (< 1.9.0) react to playback_update if _src: 'actioncable'
  • Update EyesonJS to v1.9.0 (npm or yarn)

playback_update eventโ€‹

The playback_update event has changed. It still has the playing list, but this list from now on contains all playbacks that are currently playing. Before the update, it only had the playback that started by request and not more.

Furthermore, there is always a play_id for each playback. If you leave this parameter empty at the request, a play_id will be automatically created. This is important since you can use this parameter to stop the playback.

// start playback A
{
type: 'playback_update',
playing: [
{ play_id: 'playback-A', url: 'https://...' }
]
}

// start playback B
{
type: 'playback_update',
playing: [
{ play_id: 'playback-A', url: 'https://...' },
{ play_id: 'playback-B', url: 'https://...' }
]
}

// playback A ends, B continues to play
{
type: 'playback_update',
playing: [
{ play_id: 'playback-B', url: 'https://...' }
]
}

// all playbacks end
{
type: 'playback_update',
playing: []
}

Simplified example of new playback_update sequence.

replacement_idโ€‹

Playback with replacement_id now takes the userId as already recorded in the documentation. If you have used the replacement_id with user's clientId before, then be aware that the playback_update event now returns the userId as replacement_id.

UserId and clientId are usually the same, except if you have explicitly set a user[id] in the join request or id in the register guest user request.

EyesonJS playback_update end eventโ€‹

If you're using EyesonJS you have already noticed a playback_update event with an empty playing list as soon as the playback ends.

With the API playback changes, this event is triggered twice! In order to avoid the redundant playback end event, please react only to the playback_update event with _src: 'actioncable' on versions < 1.9.0.

{
type: 'playback_update',
playing: [],
_src: 'actioncable'
}

playback_update event in EyesonJS triggered from API

info

Update EyesonJS to version 1.9.0 for a clear event handling!