Skip to content

Migration

Please follow the installation page to load the new SDK

The new SDK has an improved handshake mechanism and the .init() function is not necessary anymore.

In order to offer an API closer to the JavaScript standards, we rename the following methods:

  • .bind() is now .addEventListener()
  • .unbind() is now .removeEventListener()
// BEFORE
sdk.bind('timeupdate', (newTime) => {
console.log('new time', newTime);
});
//AFTER
sdk.addEventListener('timeupdate', (newTime) => {
console.log('new time', newTime);
});

In order to offer a better API, we replaced the .command() function with the following:

  • .command('play') is now .play()
  • .command('pause') is now .pause()
  • .command('destroy') is now .destroy()
// BEFORE
sdk.command('play');
//AFTER
sdk.play();

In order to offer a better API, we replaced the .get() function with the following:

  • .get('currentTime') is now .getCurrentTime()
  • .get('volume') is now .getVolume()
  • .get('paused') is now .isPaused()
  • .get('duration') is now .getDuration()
  • .get('liveState') is now .getLiveState()
  • .get('liveEndTime') is now .getLiveEndTime()
  • .get('liveStartTime') is now .getLiveStartTime()

Those new methods return a promise instead of requiring a callback.

// BEFORE
sdk.get('volume', (newVolume) => {
console.log('new volume', newVolume);
});
//AFTER
sdk.getVolume().then((newVolume) => console.log('new volume', newVolume));

In order to offer a better API, we replaced the .get() function with the following:

  • .set('currentTime', value) is now .setCurrentTime(value)
  • .set('volume', value) is now .setVolume(value)
// BEFORE
sdk.set('volume', 0.5);
//AFTER
sdk.setVolume(0.5);