Please correct the errors below.

Events in the Soundslice JavaScript API

The Soundslice player dispatches several events, which you can listen for in the parent page using addEventListener(). In each case, the message contents are serialized JSON, with a method key. The methods are:

Example usage:

window.addEventListener('message', function(event) {
var cmd = JSON.parse(event.data);
switch (cmd.method) {
    case 'ssPlayerReady':
        console.log('Player is ready.');
        break;
    case 'ssPlay':
        console.log('Play has started.');
        break;
    case 'ssPause':
        console.log('Play has stopped.');
        break;
    case 'ssAudioEnd':
        console.log('Play has stopped due to reaching the end.');
        break;
    case 'ssSeek':
        console.log('Play has seeked to ' + cmd.arg + ' seconds.');
        break;
    case 'ssLoopChange':
        console.log('Loop has changed to ' + cmd.arg);
        break;
    case 'ssCurrentTime':
        console.log('Current time is ' + cmd.arg + ' seconds.');
        break;
    case 'ssDuration':
        console.log('Duration is ' + cmd.arg + ' seconds.');
        break;
    case 'ssCurrentBar':
        console.log('Current bar is ' + cmd.arg);
        break;
    case 'ssBarCount':
        console.log('Bar count is ' + cmd.arg);
        break;
    case 'ssAudioLoaded':
        console.log('Recording ' + cmd.arg + ' has loaded.');
        break;
    case 'ssAudioSourceChanged':
        console.log('Recording changed to ' + cmd.arg);
        break;
    case 'ssSpeed':
        console.log('Speed is ' + (cmd.arg * 100) + ' percent.');
        break;
    case 'ssVolume':
        console.log('Volume is ' + (cmd.arg * 100) + ' percent.');
        break;
    case 'ssToggleSettings':
        if (cmd.arg === 1) {
            console.log('Settings were toggled on.');
        }
        else if (cmd.arg === 0) {
            console.log('Settings were toggled off.');
        }
        break;
    case 'ssPrint':
        console.log('User clicked Print');
        break;
    case 'ssZoom':
        console.log('Zoom is now ' + cmd.arg);
        break;
    case 'ssNotationVisibility':
        console.log('Notation visibility is now ' + cmd.arg);
        break;
    case 'ssFullscreenSupport':
        console.log('Does this browser support full screen? ' + cmd.arg);
        break;
}
});