NKInternetPlayer
Overview
Internet player allows you to played streamed media. MP3 and AAC streams supported.
playFromURL(url)
tries to play streamed media from given URL.
stop()
stops current InternetPlayer, does nothing if no media.
mute()
mutes current InternetPlayer, does nothing if no media.
notifyPlayingStarted(callback)
notifies when caching is finished and actual playback started, callback is a string name of the function to be called
notifyPlayingStopped(callback)
notifies when playback stopped, callback is a string name of the function to be called
seekToPosition(seconds)
seeks to specified position in seconds, works when playing file from internet, does not work on 'real' streams.
getDurationInSeconds()
returns duration of the streamed file in seconds (duration may change during playback and is approximated)
getCurrentPositionInSeconds()
returns current position in streamed file, this value is approximated
Parameters:
callback - javascript function to be called when playback started, should not contain any parameters.
setVolume(volume)
sets volume for current audio stream
Parameters:
volume - volume value [0..100]
getCurrentMetaString()
returns current stream's metadata (StreamTitle and optionally StreamUrl). Works with Shoutcast and Icecast stream services
forceDecoderFormat(format)
specifies decoder format to use, this is often an issue for AAC or AAC+ streams when server does not provide information about decoder to be used, can take values "aac" and "mp3".
setMaximumBuffersCount(count)
sets maximum buffers to use, consider using smaller amount for real streamed audio (2-16) and bigger amount for static files hosted in the web (16-128). Each buffer has size of 32 Kilobytes. Default value is 64 buffers, which is 2Mb cache and most suitable for most cases.
Example:
function playRadio()
{
var radio = new NKInternetPlayer();
radio.notifyPlayingStarted("stopLoadingIndicator");
radio.forceDecoderFormat("aac");
radio.playFromURL("http://radio.myserver.com:8080");
}
function stopRadio()
{
var radio = new NKInternetPlayer();
radio.stop();
}

