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; |
Contents
Constants
Name | Value | Description |
PLAY_STATE_IDLE | 0 | Represents that avplay is in idle state. |
PLAY_STATE_INITIALIZED | 1 | Represents that avplay is initialized. |
PLAY_STATE_STOPPED | 2 | Represents that avplay is stopped. |
PLAY_STATE_PREPARED | 3 | Represents that avplay is prepared to play. |
PLAY_STATE_STARTED | 4 | Represents that avplay is playing. |
PLAY_STATE_PAUSED | 5 | Represents that avplay is paused. |
Methods
clear | ||
Description | ||
Erases the TV Screen with black. | ||
Parameters | none | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | None | |
Example | ||
. |
getAvailableBitrates | ||
Description | ||
Retrieves an array consisting of all the available bitrates. | ||
Parameters | none | |
Return | ■Array - containing all the available bitrates. | |
Emulator Support | Y | |
SDK Constraint | None | |
Example | ||
. |
getCurrentBitrates | ||
Description | ||
Gets the current playing bitrate. | ||
Parameters | none | |
Return | ■Unsigned long | |
Emulator Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
Example | ||
. |
pause | ||
Description | ||
Pauses the video file currently being played. | ||
Parameters | none | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
Example | ||
. |
show | ||
Description | ||
Shows the display area. | ||
Parameters | none | |
Return | ■Boolean - true : success - false : failure | |
Emulator Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
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 Support | Y | |
SDK Constraint | None | |
Example | ||
. |
stopSubtitle | ||
Description | ||
This function stops the current subtitle track if there is any. | ||
Parameters | none | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | None | |
Example | ||
. |
getCurrentBitrate | ||
Description | ||
Gets the current playing bitrate. | ||
Parameters | none | |
Return | ■Unsigned long | |
Emulator Support | Y | |
SDK Constraint | None | |
Example | ||
console.log("current bitrate : " + avplay.getCurrentBitrate()); |