The module defines the functionalities of the player that are exposed and which could be easily used by an application or widget developer to support multimedia (RTP/UDP) playback for audio or video that are provided by the Tizen Samsung Product API.
Since : 6.5
Product : B2B (HTV)
Remark :
webapp should include avplayextension.js file in index.html
ENABLE_TTX : Sets the player to handle ttx dataservice in streams. It has one string parameter, which is either "TRUE" or "FALSE" (for setStreamingProperty)
SET_INTERACTIVE_MODE : Enables the Interactive mode which sets the latency to the player. It has two parameters, one is the "mode" and the other is the "latency" (for setStreamingProperty).
The mode value can be 0 (off) and 1 (on), the latency must be given in milliseconds
1.4 AVPlayDrmType
This enumeration specifies the different DRM types defined by the player.
enum AVPlayDrmType {
"PROIDIOM",
"LYNK"
};
The following values are supported
PROIDIOM : Indicates DRM type is Pro:Idiom
LYNK : Indicates DRM type is LYNKDRM(SCAS)
1.5 AVPlayDrmOperation
This enumeration defines the different DRM operations by the player.
PLAYER_ERROR_NONE : Indicates that the operation is successfully completed
PLAYER_ERROR_INVALID_PARAMETER : If the Player finds any parameter (which a caller is trying to configure on it) to be incorrect, this error is generated
PLAYER_ERROR_INVALID_OPERATION : Indicates an Invalid API Call at the moment
PLAYER_ERROR_INVALID_STATE : Indicates the error that is generated when any API is called in a state where it is not suggested to be called. Refer to APIs description for valid states
PLAYER_ERROR_NOT_SUPPORTED_FILE : Indicates the error that is generated, when required multimedia components are not available to play the given content
PLAYER_ERROR_INVALID_URI : Indicates an error that is generated when an input URI is in the invalid format
PLAYER_ERROR_CONNECTION_FAILED : Indicates the error that is generated, when no data is coming from the network.
PLAYER_ERROR_GENEREIC : If the Player fails to create a display window, this error is generated
1.8 AVPlayEvent
This enumeration defines the events that come from the Player.
PLAYER_MSG_NONE : Notifies that a multimedia component message is not recognized by the player
PLAYER_STREAMING_EVENT : Any type of streaming data that the caller needs would be posted through this event
1.9 AVPlayStreamInfo
The AVPlayStreamInfo dictionary specifies the streaming media-related information for the video, audio, and the subtitles during various streaming scenarios.
type : Type of the stream, either video, audio, or text
extra_info : DOMString JSON string containing all the media-related information:
All stream types have an extra_info string.
//video extra_info example: "{fourCC:"H264","Width":"1920","Height":"1080","Bit_rate":" 477000"}"
//audio extra_info example: "{"language":"fr","channels":"2","sample_rate":"48000","bit_rate":"256000","fourCC":"mpeg","track_lang":"fra","audio_type":"0"}"
//text (subtitle) extra_info example: "{"track_lang":"eng","subtitle_type":"0","pid":"258","subtitle_mode":"0"}"
If the stream type is invalid, the DOMString becomes null and the index value becomes -1
1.10 DRMData
The DRMData dictionary specifies information about the data received from the player via the DRM event.
dictionary DRMData {
DOMString name;
long code;
DOMString message;
long reserved;
};
The following values are supported
name : name for the message received from the player
code : signifies the drm error code
message : Drm error message. Generally, it is a human readable message
reserved : reserved for future use
2. Interfaces
2.1 AVPlayManagerObject
The interface defines what is instantiated by the WebApi object of the Tizen-based Samsung TV Product API.
There will be a webapis object that allows access to the functionality of the AVPlay API.
This method prepares the media player for playback. The Player must have been created beforehand with a valid URI. This prepare method is synchronous. Hence, the calling context would be blocked until the player is prepared.
void prepare();
Product : B2B (HTV)
Constraint :
Can be called in the following states: "IDLE", "READY"
Exceptions :
WebAPIException
with error type NotSupportedError, if this feature is not supported
with error type InvalidValuesError, if the given URL through open() is invalid. //For example, webapis.avplay.open("InvalidURL")
with error type InvalidAccessError, if the given URL through open() is valid but have outside multicast range. //For example, webapis.avplay.open("udp://219.10.10.10")
with error type InvalidStateError, if it is called in an invalid state
with error type UnknownError in any other error case
This method prepares the media player for playback, asynchronously. This API prepares the MM core module, asynchronously. It means that the internal media elements will change the state, asynchronously.
We recommend this asynchronous prepareAsync call instead of the prepare call which is synchronous API which blocks the entire application during its execution.
prepareAsync() returns immediately, rather than blocking until enough data has been buffered.
Since this works in asynchronous model, this does not block the executing thread and the application is responsive during its execution.
When prepareAsync() gets successfully completed, it returns with successCallback and player reached in READY state. For some reason, e.g. network error, it returns with errorCallback with error value.
Can be called in the following states: "IDLE", "READY"
Parameters :
successCallback[optional][nullable] : Callback method to be invoked when this api is successful
errorCallback[optional][nullable] : Callback method to invoke when an error occurs. This function has one parameter which shows the following errorTypes
NotSupportedError, if this feature is not supported
InvalidValuesError, if the given URL through open() is invalid. e.g., webapis.avplay.open("InvalidURL")
InvalidAccessError, if the given URL through open() is valid, but does not exist or Network Issue. e.g., webapis.avplay.open("http://abc")
InvalidStateError, if it is called in an invalid state
UnknownError, for any other error
Exceptions :
WebAPIException
with error type TypeMismatchError, if an input parameter is not compatible with the expected type
This method sets the display area for playing the video content on the TV screen. It should be called for showing the video after calling an open method.
App's default resolution is 1920x1080. It needs 4 parameters (left,top,width,height) that always use 1920 x 1080 coordinate system regardless of your application resolution.
void setDisplayRect(unsigned long x, unsigned long y, unsigned long width, unsigned long height);
Product : B2B (HTV)
Constraint :
Can be called in the following states: "IDLE", "PAUSED", "READY", "PLAYING"
Parameters :
x : coordinate of the display area in the TV screen coordinates. This x value is smaller than the TV screen width
y : coordinate of the display area in the TV screen coordinates. This y value is smaller than the TV screen height
width : The width of the display area. This value is smaller than the width of the TV screen
height : The height of the display area from the source image. This value is smaller than the height of the source image
Exceptions :
WebAPIException
with error type TypeMismatchError, if the input parameter is not compatible with the expected type
with error type NotSupportedError, if this feature is not supported
with error type InvalidValuesError, if any of the input parameters contains an invalid value
with error type InvalidStateError, if it is called in an invalid state
with error type UnknownError in any other error case
This method returns the current state of the underlying player which is associated with the AVPlay object.
AVPlayPlayerState getState();
Product : B2B (HTV)
Constraint :
Can be called in the following states: "NONE", "IDLE", "READY", "PLAYING", "PAUSED"
Return Value :
AVPlayPlayerState : returns the state of the player "NONE", "IDLE", "READY", "PLAYING", "PAUSED".
Exceptions :
WebAPIException
with error type NotSupportedError, if this feature is not supported
with error type UnknownError in any other error case
Code Example :
var bRet = webapis.avplay.getState();
getCurrentTime
This method returns the current play time in milliseconds.
unsigned long getCurrentTime();
Product : B2B (HTV)
Constraint :
Can be called in the following states: "NONE", "IDLE", "READY", "PLAYING", "PAUSED"
Return Value :
unsigned long : Current Playback time in milliseconds.
Exceptions :
WebAPIException
with error type NotSupportedError, if this feature is not supported
with error type UnknownError in any other error case
Code Example :
var currentPlayTime = webapis.avplay.getCurrentTime();
setListener
This method is used in order to obtain the Player information, the DRM mode information etc., and the Callback function is registered. When the relevant Event occurs, the relevant Callback function gets called asynchronously.
Can be called in the following states: "NONE", "IDLE" (recommended), "READY", "PAUSED", "PLAYING"
But it is highly recommended to call this API just after PLAYER_STATUS_IDLE. For onerror, onevent, ondrmevent, it must be in PLAYER_STATUS_IDLE (i.e. just after player is created), otherwise the necessary information will be missed.
Parameters :
playbackCallback : AVPlayPlaybackCallback
Exceptions :
WebAPIException
with error type TypeMismatchError, if the input parameter is not compatible with the expected type
with error type NotSupportedError, if this feature is not supported
with error type InvalidValuesError, if any of the input parameters contains an invalid value
with error type UnknownError in any other error case
This method updates the DRM information, such as SetProperties, etc. It changes the DRM mode, and runs the Control feature. Every DRM has difference between AVPlayDrmOperation and jsonParam.
drmOperation : AVPlayDrmOperation : This is a string parameter which specifies the DRM operation to be performed for the current playback session.
It can have these values{"Initialize", "Finalize" }
"SetProperties" : This operation is used when the DRM related information is stringified in "json_string" format and passed along with this operation.
This is mainly used for setting the DRM information like license server, etc.
//Example : setting license server. Some of the code examples are given below.
jsonParam : DOMString DRM parameter represented by JSON string not object. The application can call JSON.stringify() to generate JSON string in java script. The above given DRM operation examples could be stringified in this json_string param
Return Value :
DOMString : "true" in case of success and "false" if fails.
Exceptions :
WebAPIException
with error type TypeMismatchError, if the input parameter is not compatible with the expected type
with error type NotSupportedError, if this feature is not supported
with error type InvalidValuesError, if any of the input parameters contains an invalid value
with error type SecurityError, if the application does not have the privilege to call this method
with error type InvalidStateError, if it is called in an invalid state, "NONE"
with error type UnknownError in any other error case
During failure scenarios this API would post an exception. The following could be the possible exception scenarios:
DRM Create failed : if creation of the underlying DRM module failed, an exception would be sent back with "FALSE" return status of this API call.
Invalid DRM session : if an invalid DRM session is detected, an exception would be sent back with "FALSE" return status of this API call.
DRM configuration failure : if a DRM configuration failure is detected, an exception would be sent back with "FALSE" return status of this API call.
NOTE : if you use this API, a special privilege level is required.
Insert the http://developer.samsung.com/privilege/drmplay in the config.xml file of the web application. Check below example
<tizen:privilege name="http://developer.samsung.com/privilege/drmplay"/>
Code Example :
//(Example) ProIdiom (setting forensic data)
var drmParam = new Object();
drmParam.ForensicData = "XXXXXXX";
playerObj.setDrm("PROIDIOM", "Initialize", JSON.stringify(drmParam));
//(Example) LYNKDRM (setting type and lynk server)
var drmParam = new Object();
drmParam.type ="2";
drmParam.LYNKServer="xxx.xxx.xxx.xxx:xxxxx";
playerObj.setDrm( "LYNK", "Initialize", JSON.stringify(drmParam));
setDisplayMethod
This method sets the Video Screen Mode within the given DISPLAY area.
This method is used with Multi Audio/Subtitle, when you want to change the Audio and Subtitle while playing.
void setSelectTrack(AVPlayStreamType trackType, long trackIndex);
Product : B2B (HTV)
Constraint :
Can be called in the following state: "PLAYING"
Parameters :
trackType : It may be AUDIO or TEXT value
trackIndex : It sets the index value of the AVPlayStreamInfo obtained through the webapis.avplay.getTotalTrackInfo Function
Exceptions :
WebAPIException
with error type TypeMismatchError, if the input parameter is not compatible with the expected type
with error type NotSupportedError, if this feature is not supported
with error type InvalidValuesError, if any of the input parameters contains an invalid value
with error type InvalidStateError, if it is called in an invalid state
with error type UnknownError in any other error case
Code Example :
var totalTrackInfo = webapis.avplay.getTotalTrackInfo();
for (var i=0; i<totalTrackInfo.length; i++) {
if(totalTrackInfo.type == 'TEXT') {
console.log('Find subtitle track.');
console.log('subtitle track index is ' + totalTrackInfo.index);
console.log('subtitle track language is ' + totalTrackInfo.extra_info.track_lang);
}
}
//For example, choose the subtitle track index number 2.
webapis.avplay.setSelectTrack('TEXT',2);
getCurrentStreamInfo
This method gets the currently playing Streams Video, Audio, and Subtitle information. It informs that a Stream is playing.
AVPlayStreamInfo getCurrentStreamInfo();
Product : B2B (HTV)
Constraint :
Can be called in the following states: "PLAYING"
Return Value :
AVPlayStreamInfo : AVPlayStreamInfo structure containing tracktype, extraInfo and Index of current stream
Exceptions :
WebAPIException
with error type NotSupportedError, if this feature is not supported
with error type InvalidStateError, if it is called in an invalid state
with error type UnknownError in any other error case
Code Example :
var streamInfo = webapis.avplay.getCurrentStreamInfo();
var text = '';
for (var i = 0; i < streamInfo.length; i++) {
text += 'index: ' + streamInfo[i].index + '';
text += 'type: ' + streamInfo[i].type + '';
text += 'extra_info: ' + streamInfo[i].extra_info + '';
}
All of stream type has extra_info which is JsonString.
//video extra_info example : "{fourCC:"H264","Width":"1920","Height":"1080","Bit_rate":" 477000"}"
//audio extra_info example : "{"language":"fr","channels":"2","sample_rate":"48000","bit_rate":"256000","fourCC":"mpeg","track_lang":"fra","audio_type":"0"}"
//text(subtitle) extra_info example : "{"track_lang":"eng","subtitle_type":"0","pid":"258","subtitle_mode":"0"}"
In the case of invalid Stream, the DOMString becomes null and the index value becomes -1.
getTotalTrackInfo
This method gets the currently playing Streams information.
AVPlayStreamInfo[] getTotalTrackInfo();
Product : B2B (HTV)
Constraint :
Can be called in the following state: "PLAYING"
Return Value :
AVPlayStreamInfo : AVPlayStreamInfo[] structure containing the tracktype, extraInfo, and the Index of current stream
It returns information for all the available tracks for the entire stream that is available in the current playback. The following structure is used to send the information back to the caller:
For video tracks:
"{"fourCC":"%s","Width":"%u","Height":"%u","Bit_rate":"%u"}"
For audio track:
"{"language":"%s","channels":"%d","sample_rate":"%d","bit_rate":"%d","fourCC":"%s","track_lang":"%s","audio_type":"%d"}"
For subtitle tracks:
"{"track_lang":"%s","subtitle_type":"%d","pid":"%d","subtitle_mode":"%s"}"
Exceptions :
WebAPIException
with error type NotSupportedError, if this feature is not supported
with error type InvalidStateError, if it is called in an invalid state
with error type UnknownError in any other error case
Code Example :
var trackInfo = webapis.avplay.getTotalTrackInfo();
var text = 'type of track info: ' + typeof trackInfo + '';
text += 'length: ' + trackInfo.length + '';
for (var i = 0; i<trackInfo.length; i++) {
text += 'index: ' + trackInfo[i].index + '';
text += 'type: ' + trackInfo[i].type + '';
text += 'extra_info: ' + trackInfo[i].extra_info + '';
}
setStreamingProperty
This method sets the value for a specific feature in the UDP/RTP playback.
void setStreamingProperty(AVPlayStreamingPropertyType propertyType, Any propparam);
Product : B2B (HTV)
Constraint :
Can be called in the following player state: "IDLE"
Parameters :
propertyType : property type to be set to the player
propparam : Value according to the propertyType. e.g. "ENABLE_TTX" PropetyTypes are true, false, and for the "SET_INTERACTIVE_MODE" mode is 1 with latency in milliseconds
Exceptions :
WebAPIException
with error type TypeMismatchError, if the input parameter is not compatible with the expected type
with error type NotSupportedError, if this feature is not supported
with error type InvalidValuesError, if any of the input parameters contains an invalid value
with error type InvalidStateError, if it is called in an invalid state
with error type UnknownError in any other error case
Code Example :
//set interactive mode example :
var propparam = new Object();
propparam.mode ="1";
propparam.latency="100"; //latency in ms
webapis.avplay.setStreamingProperty("SET_INTERACTIVE_MODE", propparam);
//Enable ttx mode example :
webapis.avplay.setStreamingProperty("ENABLE_TTX", true);
getVersion
This method gets the version of avplay.
DOMString getVersion();
Product : B2B (HTV)
Constraint :
Can be called in the following states: "NONE", "IDLE", "READY", "PAUSED", "PLAYING"
Return Value :
DOMString : DOMString string
current version
Exceptions :
WebAPIException
with error type NotSupportedError, if this feature is not supported
with error type UnknownError in any other error case
Code Example :
var version = webapis.avplay.getVersion();
setDisplayRotation
This method sets the rotation settings of the video surface display. If no display is set, no operation is performed. Use this method to change the video orientation to portrait mode. This API call will change the origin of the coordinates. Hence, the application should call setDisplayRect() again after calling this API.
Can be called in the following states: "IDLE", "READY", "PLAYING", "PAUSED"
Parameters :
displayRotation : The rotation of the display. The valid values for the display rotation are "PLAYER_DISPLAY_ROTATION_NONE", "PLAYER_DISPLAY_ROTATION_90", "PLAYER_DISPLAY_ROTATION_180", "PLAYER_DISPLAY_ROTATION_270"
Exceptions :
WebAPIException
with error type TypeMismatchError, if an input parameter is not compatible with the expected type
with error type NotSupportedError, if this feature is not supported
with error type InvalidValuesError, if any input parameter contains an invalid value
with error type InvalidStateError, if it is called in an invalid state
data : Detailed information about the DRM event received from the player
{
readonly attribute name : name for the message, means an error occurred during the DRM processing.
readonly attribute code : signifies the DRM error code
readonly attribute message : DRM error message
readonly attribute reserved : not currently applicable
}
Exceptions :
WebAPIException
with error type NotSupportedError, if this feature is not supported
with error type UnknownError in any other error case
Code Example :
ondrmevent: function(type, data) {
console.log("DRM callback: " + type + ", data: " + data);
var ErrorInfo = {
"NAME": data.name,
"ERROR_CODE": data.code,
"ERROR_MESSAGE": data.message // Generally, the error message is human readable.
}
}
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
.samsungdeveloperconference.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.