Swift API Updates
The Ooyala Player API is largely unchanged with the release of our new player (Swift) and we have made every effort to maintain complete backwards compatibility. Most implementations will not require any changes. For completeness and reference, we list any updates introduced below.
New Events
There is a new event called "apiReady". Going forward, this new event should be used in favor of the "loadComplete" event. The difference between apiReady and loadComplete is that apiReady will be dispatched every time the embed code changes (including the first time the player starts), whereas loadComplete is only dispatched once, the first time the player is loaded.
Updates to event sequence
The order of events has been updated under certain scenarios in the new player. Outlined below are examples with the differences highlighted.
When loading a video
Key differences:
- In the new player, the apiReady and loadComplete events are dispatched after the video has finished loading and is ready to play.
- The new player dispatches an embedCodeChanged event when the player initially loads its first embed code, whereas the old player does not.
- The new player does not dispatch an initial playheadTimeChanged event with a value of 0, as the old player does.
Show example
Sample event order dispatched by the player:
Old player
loadComplete
totalTimeChanged
playheadTimeChanged (playheadTime=0)
New player
stateChanged (state=paused)
embedCodeChanged
totalTimeChanged
loadComplete
apiReady
When playing a video
Key differences:
- The new player skips the "paused" state between "buffering" and "playing" when playing a video.
Show example
Sample event order dispatched by the player:
Old player
loadComplete
...
stateChanged (state=buffering)
stateChanged (state=paused)
playheadTimeChanged (playheadTime=0.04)
stateChanged (state=playing)
playheadTimeChanged (playheadTime=0.46)
playheadTimeChanged (playheadTime=1.50)
New player
loadComplete
...
stateChanged (state=buffering)
stateChanged (state=playing)
playheadTimeChanged (playheadTime=0.12)
playheadTimeChanged (playheadTime=0.50)
When loading a channel
Key differences:
- The new player dispatches a currentItemEmbedCodeChanged when it begins playing the first item in the channel, whereas the old player does not.
Show example
Sample event order dispatched by the player:
Old player
loadComplete
totalTimeChanged
New player
embedCodeChanged
currentItemEmbedCodeChanged
totalTimeChanged
loadComplete
apiReady
When seeking in a video that is currently playing
Key differences:
- The new player does not enter the paused state when it begins seeking.
Show example
Sample event order dispatched by the player:
Old player
playheadTimeChanged (playheadTime=2.96)
(At this point, the user clicks on the video scrubber to seek into the video)
stateChanged (state=paused)
stateChanged (state=buffering)
stateChanged (state=playing)
playheadTimeChanged (playheadTime=33.74)
playheadTimeChanged (playheadTime=34.11)
New player
playheadTimeChanged (playheadTime=2.96)
(At this point, the user clicks on the video scrubber to seek into the video)
stateChanged (state=buffering)
stateChanged (state=playing)
playheadTimeChanged (playheadTime=33.74)
playheadTimeChanged (playheadTime=34.11)
...
When completing one video in a channel and playing the next video in the channel
Key differences:
- The old player dispatches a totalTimeChanged event twice when the item in the channel changes: once with a value of "0", and then once again for the video's total time. The new player instead dispatches a single totalTimeChanged event with the length of the video.
Show example
Sample event order dispatched by the player:
Old player
...
playheadTimeChanged (playheadTime=29.50)
playheadTimeChanged (playheadTime=30.00)
(At this point, the current video in the channel finishes playing and the next video in the channel begins)
totalTimeChanged (totalTime=0)
currentItemEmbedCodeChanged
stateChanged (state=paused)
totalTimeChanged (totalTime=35.43)
stateChanged (state=buffering)
playComplete
stateChanged (state=playing)
playheadTimeChanged (playheadTime=0.2)
...
New player:
...
playheadTimeChanged (playheadTime=29.50)
playheadTimeChanged (playheadTime=30.00)
(At this point, the current video in the channel finishes playing and the next video in the channel begins)
stateChanged (state=paused)
playComplete
stateChanged (state=buffering)
currentItemEmbedCodeChanged
totalTimeChanged (totalTime=35.43)
stateChanged (state=buffering)
stateChanged (state=playing)
playheadTimeChanged (playheadTime=0.2)
...