top

AVPlay

This class defines functions and properties for playing video. This class allows a web application to play a video file which is not supported in HTML5.

Add the following line for AVplay class into a html file your own :

  script type="text/javascript" src="$MANAGER_WIDGET/Common/webapi/1.0/webapis.js">/script>

You can declare AVplay class like this :

  ex) var avplay = webapis.avplay;


Constants

NameValueDescription
PLAY_STATE_IDLE 0Represents that avplay is in idle state.
PLAY_STATE_INITIALIZED 1Represents that avplay is initialized.
PLAY_STATE_STOPPED 2Represents that avplay is stopped.
PLAY_STATE_PREPARED 3Represents that avplay is prepared to play.
PLAY_STATE_STARTED 4Represents that avplay is playing.
PLAY_STATE_PAUSED 5Represents that avplay is paused.

Methods

clear

Description
Erases the TV Screen with black.
Parameters
none
Return■Void
Emulator SupportY
SDK ConstraintNone
Example
.

getAvailableBitrates

Description
Retrieves an array consisting of all the available bitrates.
Parameters
none
Return■Array
  - containing all the available bitrates.
Emulator SupportY
SDK ConstraintNone
Example
.

getCurrentBitrates

Description
Gets the current playing bitrate.
Parameters
none
Return■Unsigned long
Emulator SupportY
SDK ConstraintNone
Example
console.log("current bitrate : " + avplay.getCurrentBitrate());

getVideoResolution

Description
This method is invoked when the resolution changes. (onresolutionchanged method changes resolution)
Parameters
■width
  - unsigned long 
  - width of resolution
■height
  - unsigned long
  - height of resolution
Return■String
  - width | height
Emulator SupportY
SDK ConstraintNone
Example
onresolutionchanged: function (width, height) {
        console.log("resolution changed : " + width + ", " + height);
    },

hide

Description
hides display area.
Parameters
none
Return■Boolean
  - true : success
  - false : failure
Emulator SupportY
SDK ConstraintNone
Example
var gAVPlayObj; 
gAVPlayObj.hide();

init

Description
Initializes the player with the URL of the video file that to be played and the VodPlayOption.
Parameters
■URL 
  - DOMString
  - URL of the video file
■Option 
  - AVPlayOption
Return■Void
Emulator SupportY
SDK ConstraintNone
Example
.

jumpBackward

Description
Rewinds the currently played video by the specified number of seconds.
Parameters
■sec
  - Number 
  - number of seconds to be forwarded.
Return■Boolean
  - true : success
  - false : failure
Emulator SupportY
SDK ConstraintNone
Example
.

pause

Description
Pauses the video file currently being played.
Parameters
none
Return■Void
Emulator SupportY
SDK ConstraintNone
Example
.

play

Description
Starts the playback of the video file stored in the URL passed as parameter to the init function. Upon successfully playing the video file successCallback is called and upon failure errorCallback is called. An option parameter can also be sent specifying the seconds from which the file has to start playing.
Parameters
■successCallback 
  - Callback Function
  - To be invoked if the play operation has completed successfully.
■errorCallback 
  - Callback Function
  - To be invoked when an error has occurred.
■sec (Optional)
  - unsigned long
  - Seconds at which playback has to be started
Return■Void
Emulator SupportY
SDK ConstraintNone
Example
function playSuccessCB() {
      console.log("playing the video is successfully.");  
}   
function successCB(avplayObj) {
      avplayObj.init();
      avplayObj.open("media.avi");
      avplayObj.play(playSuccessCB,
           function (error) {
                 console.error(error.message);
           },
          5);
}            
function errorCB(error) {
      console.log("Cannot get avplay object : " + error.name);
}
try {
      webapis.avplay.getAVPlay(successCB, errorCB);
} catch (error) {
      console.log(error.name);  
}

resume

Description
Resumes playing the paused video.
Parameters
none
Return■Void
Emulator SupportY
SDK ConstraintNone
Example
.

setAudioStreamID

Description
Sets the Audio track to the Audio track id mentioned in the parameter.
Parameters
■Index
  - unsigned short
  - index of the audio track
Return■Boolean
  - true : success
  - false : failure
Emulator SupportY
SDK ConstraintNone
Example
.

setDisplayRect

Description
Sets the display area of video content in TV screen.
Parameters
■rect
  - Rect
  - the position of the display area
Return■Boolean
  - true : success
  - false : failure
Emulator SupportY
SDK ConstraintNone
Example
var gAVplayObj; 
gAVplayObj.setDisplayRect(rect);

setSpeed

Description
Sets the current playback speed. This value can be positive or negative. If the value is set to negative, the video starts playing in the reverse direction.
Parameters
■speed
  - Long
  - playback speed
Return■Boolean
  - true : success
  - false : failure
Emulator SupportY
SDK ConstraintNone
Example
.

setSubtitleStreamID

Description
Sets the current subtitle track to the subtitle track ID given in the parameter.
Parameters
■Index 
  - Unsigned short
  - index of the audio track
Return■Boolean
  - true : success
  - false : failure
Emulator SupportY
SDK ConstraintNone
Example
.

setSubtitleSync

Description
Synchronizes the subtitle track with the video track by the number of milliseconds defined in the parameter.
Parameters
■millisec 
  - Number
  - number of milliseconds by which the subtitle track has to be moved forward or back in order to synchronize with the video track.
Return■Void
Emulator SupportY
SDK ConstraintNone
Example
.

show

Description
Shows the display area.
Parameters
none
Return■Boolean
  - true : success
  - false : failure
Emulator SupportY
SDK ConstraintNone
Example
var gAVplayObj;

function onShowScreen() {
     gAVplayObj.show();
}

startSubtitle

Description
Starts the subtitles by sending a subtitle option as a parameter.
Parameters
■option
  - SubtitleOption
  - option for the subtitle
Return■Boolean
  - true : success
  - false : failure
Emulator SupportY
SDK ConstraintNone
Example
.

stop

Description
Stops the player and hence any video currently being played. This function has to be called after the video completes playing.
Parameters
none
Return■Void
Emulator SupportY
SDK ConstraintNone
Example
.

stopSubtitle

Description
This function stops the current subtitle track if there is any.
Parameters
none
Return■Void
Emulator SupportY
SDK ConstraintNone
Example
.

getCurrentBitrate

Description
Gets the current playing bitrate.
Parameters
none
Return■Unsigned long
Emulator SupportY
SDK ConstraintNone
Example
console.log("current bitrate : " + avplay.getCurrentBitrate());