Events
Events that can be subscribed to using the on method on BAM instances.
ready
Dispatched when a BAM instance is initialized.
connectionsuccess
Dispatched when a connection is successful.
connectionclosed
Dispatched when a stream connection has closed.
canplay
Dispatched when the stream connection is available for playback.
play
Dispatched when the stream starts playing.
pause
Dispatched when the stream is paused.
paused
Dispatched when the stream is paused.
playing
Dispatched when the stream is resumed.
stop
Dispatched when the stream is stopped.
ended
Dispatched when a stream ends naturally.
stalled
Dispatched when the stream connection is lost.
durationchange
Dispatched when the stream duration is available or changes. The duration is passed as an argument and is also available as a getter.
Examples:
handleDuration(value){
console.log("duration:"+value);
}
handleDuration(value){
console.log("duration:"+bam.duration);
}
loadedmetadata
Dispatched when the stream metadata is available. The metadata is passed as an argument and is also available as a getter.
Metadata:
{
ref_type: "track",
id: "tr51760477",
display: "Blood On The Tracks"
}
Example:
handleMetadata(value){
console.log("Song Title:" + value.display);
}
handleMetadata(value){
console.log("Song Title:" + bam.metadata.display);
}
timeupdate
Dispatched when requestAnimationFrame is invoked.
error
Dispatched when an input or output error occurs that causes a network operation to fail.
Types of errors that can be handled:
auth - If a Beats Music access token has expired.
streamsecurity - If a crossdomain error when connecting to the stream.
streamio - If a stream IO Error occurs.
apisecurity - If there is a crossdomain error when connecting to the Beats Music API.
apiio - If a Beats Music track data IO Error occurs.
Example:
handleError(value){
switch(value){
case "auth":
// your handling code here
break;
case "streamsecurity":
// your handling code here
break;
case "streamio":
// your handling code here
break;
case "apisecurity":
// your handling code here
break;
case "apiio":
// your handling code here
break;
}
console.log("Error:" + value);
}

