HDW Player Download

Javascript API

HDW Player is still trying to better the Examples section. Mail your ideas to [email protected]

Users can control embedded HDW Player via JavaScript calls made to the JavaScript API. Calls can be made to play, pause, seek to a certain time in a video, set the volume, mute the player, and other useful functions.

Getting Started

To use Javascript API, you need to embed HDW Player to your Web Page first. Please refer Add to your Own Page guidelines to add the player to your Web Page.

Then, you need to enable Javascript API by adding &api=true to the swf path. Now your swf path would be :

swf : 'player/player.swf&api=true'

When the player is ready, the API will call the onPlayerReady callback function in where you can start executing API methods.

Please check below for the List of Available API Properties, Methods and Events.

Playback controls and player settings

player.playVideo():Void
Plays the currently loaded video.

player.pauseVideo():Void
Pauses the currently playing video.

player.stopVideo():Void
Stops and cancels loading of the current video.

player.seekTo(seconds:Number):Void
Seeks to a specified time in the video.

The seconds parameter identifies the time from which the video should start playing.
If the player has already buffered the portion of the video to which the user is advancing, then the player will start playing the video at the closest keyframe to the specified time. This behavior is governed by the seek() method of the Flash player's NetStream object. In practice, this means that the player could advance to a keyframe just before or just after the specified time.

player.loadPlaylistItem(index:Number):Void
Switch the playback to the loadedPlaylist Item. index refer to the XML index from the playlist.

Our Current API doesn't allow you to load your Video through any API methods. Instead, you need to use Playlist XML functionality of HDW Player as a Video Provider for the Player. Then you can load any playlist item by using this method.

player.destroy():Void
Completely destroy the API Player. If this function is executed then the player won't work anymore until it is reloaded again.

Changing the player volume

player.mute():Void
Mutes the player.

player.unMute():Void
Unmutes the player.

player.setVolume(volume:Number):Void
Sets the volume. Accepts an integer between 0 and 100.

player.getVolume():Number
Returns the player's current volume, an integer between 0 and 100. Note that getVolume() will return the volume even if the player is muted.

Playback status

player.getVideoBytesLoaded():Number
Returns the number of bytes loaded for the current video.

player.getVideoBytesTotal():Number
Returns the size in bytes of the currently loaded/playing video.

player.getCurrentTime():Number
Returns the elapsed time in seconds since the video started playing.

player.getDuration():Number
Returns the duration in seconds of the currently playing video. Note that getDuration() will return 0 until the video's metadata is loaded, which normally happens just after the video starts playing.

Adding an event listener

player.addEventListener(event:String, listener:String):Void
Adds a listener function for the specified event. The Events section below identifies the different events that the player might fire. The listener is a string that specifies the function that will execute when the specified event fires.

Events

onStateChange
This event is fired whenever the player's state changes without any javascript events such as play, pause, etc.. Possible values are

  • MEDIA.PLAY
    Invoked when the video start playing.
  • MEDIA.PAUSE
    Invoked when the video is paused.
  • MEDIA.BUFFER
    Invoked when the video is bufferring.
  • MEDIA.STOP
    Invoked when the video is stopped.
  • MEDIA.CHANGED
    Invoked when the playlist item is changed.

onError
Invoked when the playback faced any trouble.

Check the working Example of this API at Here.

Support