Dynamic rich media component for ASP.Net Flash, Video and Audio controls for C# and VB.Net

ASPNetAudio JavaScript API Reference

The ASPNetAudio JavaScript API provides an interface to control any ASPNetAudio control at run-time using JavaScript client code.
The API can be accessed by using the accessor function below: 

Accessor function

ASPNetMedia.Audio(ControlName)

Returns an object allowing you to use the JavaScript API methods to control a ASPNetAudio object.

e.g. soundObject = ASPNetMedia. Audio (“Audio1”)

 

JavaScript API

To use the API functions, you must call them using the object returned by the Accessor function.

e.g. ASPNetMedia.Audio(“Audio1”).PlayMedia()

PlayMedia ([URL])

Commands the sound to start playing.  The optional URL parameter allow you to change the audio file to be played.

LoadMedia(URL)

Changes the audio file  that will be played back.  The parameter URL should be the url of the new target audio file.

PauseMedia()

Pauses the sound.  Playback can be resumed by using the PlayMedia function.

StopMedia()

Stops the sound and rewinds it to the start.

Mute()

Toggles the muted (silenced) state of the audio player.

GetVolume()

Returns the volume setting of the audio player as an integer between 0 and 100.

SetVolume(VolumeLevel)

Sets the volume of the audio player. VolumeLevel must be an integer between 0 and 100.

GetPosition()

Returns the position of the audio play-head in seconds.

GetDuration()

Returns the duration of the audio in seconds.

SetPosition (TimeInSeconds)

Sets the position of the audio play-head in seconds.  Note that the audio play-head cannot move to a section of the track which has not yet been downloaded.

FastForward([SeekRate])

Starts the audio fast-forwarding.  The optional seek rate parameter allows you to use an integer to specify the relative speed of the fast-forward.

The fast-forward behavior can be canceled using the FastForwardStop method.

FastForwardStop()

Stops the audio fast-forwarding.

FastReverse([SeekRate])

Starts the audio rewinding.  The optional seek rate parameter allows you to use an integer to specify the relative speed of the fast-reverse.

The fast- reverse behavior can be canceled using the FastReverseStop method.

FastReverseStop()

Stops the audio fast-reversing.

 


JavaScript Events

To use ASPNetAudio Events, assign them a callback function. 

e.g.  

ASPNetMedia.Audio(“Audio1”). OnPause = function(object, position){
            alert(‘paused’);
}

The parameter object send in the ASPNetAudio API object for convenience.
The parameter position
returns the sound play-head’s position in seconds.

 

OnStop (object, position)

Called when the sound is stopped.

OnPause (object, position)

Called when the sound is paused.

OnPlay (object, position)

Called when the sound starts playing.

OnFinish (object, position)

Called when the sound finishes.

OnStartBuffer (object)

Called when the sound starts buffering.

OnReady (object)

Called when the sound stops buffering and is ready to play.

OnStartSeek (object, position)

Called when the sound starts fast-forwarding or fast-reversing.

OnStopSeek (object, position)

Called when the sound stops fast-forwarding or fast-reversing.

OnProgress (object, position)

Called regularly while the sound is playing as a heartbeat function.

OnSeek (object, position)

Called regularly while the sound is fast-forwarding or fast-reversing as a heartbeat function.