Migration
Migration from v2.0 to v3.0
Load the new SDK
Please follow the installation page to load the new SDK
.init()
is removed
The new SDK has an improved handshake mechanism and the .init()
function is not necessary anymore.
Changes to .bind()
and .unbind()
In order to offer an API closer to the JavaScript standards, we rename the following methods:
.bind()
is now.addEventListener()
.unbind()
is now.removeEventListener()
// BEFOREsdk.bind('timeupdate', (newTime) => { console.log('new time', newTime);});
//AFTERsdk.addEventListener('timeupdate', (newTime) => { console.log('new time', newTime);});
Changes to .command()
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()
// BEFOREsdk.command('play');
//AFTERsdk.play();
Changes to .get()
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.
// BEFOREsdk.get('volume', (newVolume) => { console.log('new volume', newVolume);});
//AFTERsdk.getVolume().then((newVolume) => console.log('new volume', newVolume));
Changes to .set()
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)
// BEFOREsdk.set('volume', 0.5);
//AFTERsdk.setVolume(0.5);