NKInternetPlayer
From NimbleKit
[edit] Overview
Internet player allows you to played streamed media. MP3 and AAC streams supported.
- NKInternetPlayer()
creates and initializes InternetPlayer instance, which acts as singleton, so if you created InternetPlayer before current instance will just reuse resources.
- 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
- notifyPlayingStopped(callback)
notifies when playback stopped
- 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]
[edit] Example:
function playRadio() {
var radio = new NKInternetPlayer();
radio.notifyPlayingStarted("stopLoadingIndicator");
radio.playFromURL("http://radio.myserver.com:8080");
}
function stopRadio() {
var radio = new NKInternetPlayer();
radio.stop();
}
