AVPlay API

To use Samsung Product API,

<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>

Should be loaded in index.html

This module defines the multimedia player functionalities provided by the Tizen Samsung TV Product API.

Since : 2.3

Product : TV, AV, B2B

Summary of Interfaces and Methods

Interface

Method

AVPlayManagerObject

AVPlayManager

void open(DOMString url);
void close();
void prepare();
void prepareAsync(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
void setDisplayRect(unsigned long x, unsigned long y, unsigned long width, unsigned long height);
AVPlayVideoSeamlessInfo getVideoSeamlessInfo();
void play();
void seekTo(long milliseconds, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
void stop();
AVPlayPlayerState getState();
void pause();
void jumpForward(long milliseconds, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
void jumpBackward(long milliseconds, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
unsigned long getDuration();
unsigned long getCurrentTime();
void setTimeoutForBuffering(unsigned long seconds);
void setBufferingParam(AVPlayBufferOption option, AVPlayBufferSizeUnit unit, unsigned long amount);
void setSpeed(long playbackSpeed);
void setListener(AVPlayPlaybackCallback playbackCallback);
DOMString setDrm(AVPlayDrmType drmType, AVPlayDrmOperation drmOperation, DOMString jsonParam);
DOMString getUID(AVPlayDrmType drmType);
void setSoundAnalysisListener(AVPlaySoundAnalysisCallback soundAnalysisCallback);
void unsetSoundAnalysisListener();
void setSilentSubtitle(boolean onoff);
void setExternalSubtitlePath(DOMString filePath);
void setSubtitlePosition(long position);
void setDisplayMethod(AVPlayDisplayMode displayMode);
void setSelectTrack(AVPlayStreamType trackType, long trackIndex);
AVPlayStreamInfo[] getCurrentStreamInfo();
AVPlayStreamInfo[] getTotalTrackInfo();
void setStreamingProperty(AVPlayStreamingPropertyType propertyType, DOMString propertyParam);
DOMString getStreamingProperty(AVPlayStreamingPropertyType propertyType);
DOMString getVersion();
void suspend();
void setLooping(boolean isLooping);
void setVideoStillMode(DOMString mode);
void setDisplayRotation(DOMString displayRotation);
void restore(optional DOMString? URL, optional unsigned long? resumeTime, optional boolean? bPrepare);
void restoreAsync(optional DOMString? URL, optional unsigned long? resumeTime, optional boolean? bPrepare, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
void enableAudioStream();
void disableAudioStream();
void setVideoRoi(double x_ratio, double y_ratio, double w_ratio, double h_ratio);

AVPlayPlaybackCallback

void onbufferingstart();
void onbufferingprogress(unsigned long percent);
void onbufferingcomplete();
void oncurrentplaytime(unsigned long currentTime);
void onstreamcompleted();
void onevent(AVPlayEvent eventid, DOMString data);
void onerror(AVPlayError eventid);
void onerrormsg(AVPlayError eventid, DOMString errorMsg);
void ondrmevent(AVPlayDrmType type, drmData data);
void onsubtitlechange(DOMString duration, DOMString subtitles, DOMString type, AVPlaySubtitleAttribute[] attributes);

AVPlaySoundAnalysisCallback

void ongetexception(WebAPIError err);
void onsetexception(WebAPIError err);
void ongetbandsarray(long[] band);

1. Type Definitions

1.1 AVPlayPlayerState

Specifies the player state.

enum AVPlayPlayerState {
  "NONE",
  "IDLE",
  "READY",
  "PLAYING",
  "PAUSED"
};

The following values are supported

  • NONE : Player is not created
  • IDLE : Player is created but not prepared
  • READY : Player is ready to play media
  • PLAYING : Player is playing media
  • PAUSED : Player is paused

1.2 ScanType

Specifies the video scan type.

enum ScanType {
  "INTERLACED",
  "PROGRESSIVE"
};

The following values are supported

  • INTERLACED : video scanning type is interlaced
  • PROGRESSIVE : Video scanning type is progressive

1.3 AVPlayDisplayMode

Specifies display modes.

enum AVPlayDisplayMode {
  "PLAYER_DISPLAY_MODE_LETTER_BOX",
  "PLAYER_DISPLAY_MODE_FULL_SCREEN",
  "PLAYER_DISPLAY_MODE_AUTO_ASPECT_RATIO"
};

The following values are supported

  • PLAYER_DISPLAY_MODE_LETTER_BOX : Letterbox mode
  • PLAYER_DISPLAY_MODE_FULL_SCREEN : Full-screen mode
  • PLAYER_DISPLAY_MODE_AUTO_ASPECT_RATIO : Screen mode based on video dar/par info

1.4 AVPlayBufferOption

Specifies buffering scenarios.

enum AVPlayBufferOption {
  "PLAYER_BUFFER_FOR_PLAY",
  "PLAYER_BUFFER_FOR_RESUME"
};

The following values are supported

  • PLAYER_BUFFER_FOR_PLAY : Initial buffering scenario
  • PLAYER_BUFFER_FOR_RESUME : Re-buffering which might be occured after initial buffering during the playback.
    The onbufferingcomplete event would be triggered when the PLAYER_BUFFER_FOR_PLAY amount of data is buffered.
    The actual buffering completion time may vary depending on the contents format, bitrate, network speed and so on.

1.5 AVPlayBufferSizeUnit

Specifies buffer size units.

enum AVPlayBufferSizeUnit {
  "PLAYER_BUFFER_SIZE_IN_SECOND"
};

The following values are supported

  • PLAYER_BUFFER_SIZE_IN_SECOND : Buffer size in seconds

Remark :

  • "PLAYER_BUFFER_SIZE_IN_BYTE" property has been deprecated from Tizen version 5.0

1.6 AVPlayStreamingPropertyType

Specifies parameters for various streaming protocols, such as HTTP, MMS, and adaptive streaming (Smooth Streaming, HLS, and MPEG-DASH).

enum AVPlayStreamingPropertyType {
  "COOKIE",
  "USER_AGENT",
  "PREBUFFER_MODE",
  "ADAPTIVE_INFO",
  "SET_MODE_4K",
  "LISTEN_SPARSE_TRACK",
  "IS_LIVE",
  "AVAILABLE_BITRATE",
  "GET_LIVE_DURATION",
  "CURRENT_BANDWIDTH",
  "USE_VIDEOMIXER",
  "SET_MIXEDFRAME",
  "PORTRAIT_MODE",
  "IN_APP_MULTIVIEW"
};

The following values are supported

  • COOKIE : HTTP request cookie used to establish the session with the HTTP server. (for setStreamingProperty)
  • USER_AGENT : HTTP user agent, used in the HTTP request header. (for setStreamingProperty)
  • PREBUFFER_MODE : Property to initiate prebuffering mode. The second parameter indicates start-time for prebuffered content, in milliseconds. (for setStreamingProperty)
  • ADAPTIVE_INFO : Sets a custom streaming URL with various streaming parameters, such as "BITRATES", "STARTBITRATE", or "SKIPBITRATE" (for setStreamingProperty)
    String containing custom attributes for adaptive streaming playback.
    "STARTBITRATE=" Valid values are "LOWEST", "HIGHEST", and "AVERAGE". You can also define a specific bandwidth for the start of playback.
    "BITRATES=" Use '~' to define a bandwidth range (5000 ~ 20000). You can also define a specific bandwidth for playback.
    "SKIPBITRATE=" Defines the bandwidth to use after a skip operation.
    "STARTFRAGMENT=" For live content playback, defines the start fragment number.
    "FIXED_MAX_RESOLUTION=max_widthXmax_height". Only if the given media URI such as mpd in MPEG-DASH or m3u8 in HLS through open() method doesn't describe entire required video resolutions,
    application should use this attribute to complete the resolution information for the player.
  • SET_MODE_4K : Forces the player to use the 4K UHD decoder. Its parameter can be the string "TRUE" or "FALSE". (for setStreamingProperty)
    In the case of adaptive streaming which requires stream-change for different video resolution during the playback,
    Only if the given media URI such as mpd in MPEG-DASH or m3u8 in HLS through open() method doesn't describe entire required video resolutions,
    pass TRUE with this property in IDLE state.
  • LISTEN_SPARSE_TRACK : For the Smooth Streaming case, configures the player to listen for a "Sparse name" configured through "propertyParam" . The sparse track name is a string. (for setStreamingProperty)
  • IS_LIVE : Whether the stream is LIVE or VOD. Applicable to all streaming types. (for getStreamingProperty)
  • AVAILABLE_BITRATE : String listing the available bit-rates for the currently-playing stream. (for getStreamingProperty)
  • GET_LIVE_DURATION : String describing the duration of live content. (for getStreamingProperty)
  • CURRENT_BANDWIDTH : String describing the current streaming bandwidth. (for getStreamingProperty)
  • USE_VIDEOMIXER : Property used for enabling/initializing video mixer feature on B2B product only( for setStreamingProperty). It should be set before setting SET_MIXEDFRAME property on the player.
  • SET_MIXEDFRAME : Property to set the position of mixed frame( for setStreamingProperty). setDisplayRect with required position on corresponding player instance to be called before setting this property.
  • PORTRAIT_MODE : Property to force the playback the video in potrait mode on B2B proudct only( for setStreamingProperty).
  • IN_APP_MULTIVIEW : Property to select the Scaler type, By Default MAIN Scaler selected.

Remark :

  • "IN_APP_MULTIVIEW" is available since Tizen version 7.0
  • "GET_LIVE_DURATION" is available since Tizen version 2.4
  • "WIDEVINE" property has been deprecated from Tizen version 4.0
  • "PROPERTY_HD_AUDIO" property has been deprecated from Tizen version 2.4
  • "SET_VR360_MODE" property has been deprecated from Tizen version 5.0
  • "SET_MODE_4K" property has been deprecated from Tizen version 5.0 for Retail TV. Property "ADAPTIVE_INFO" with attribute "FIXED_MAX_RESOLUTION=max_widthXmax_height" has been available since 5.0 as an alternative.
  • "ADAPTIVE_INFO" with attribute "FIXED_MAX_RESOLUTION=max_widthXmax_height" is available since Tizen version 5.0 and API version 4.1
  • calling setStreamingProperty with SET_MODE_4K with parameter "TRUE" is same as setting "ADAPTIVE_INFO" with attribute "FIXED_MAX_RESOLUTION=3840X2160".

1.7 AVPlayDrmType

Specifies DRM systems supported by the player.

enum AVPlayDrmType {
  "PLAYREADY",
  "VERIMATRIX",
  "WIDEVINE_CDM"
};

The following values are supported

  • PLAYREADY : PlayReady
  • VERIMATRIX : Verimatrix
  • WIDEVINE_CDM : Widevine Modular

1.8 AVPlayDrmOperation

Specifies various DRM operations.

enum AVPlayDrmOperation {
  "SetProperties",
  "InstallLicense",
  "ProcessInitiator",
  "widevine_license_data"
};

The following values are supported

  • SetProperties : Sets DRM instance properties and initialize the DRM instance for PlayReady, Verimatrix, and Widevine CDM.
  • InstallLicense : Base64-encoded license data for PlayReady. An application shall retrieve license data using challenge data received in ondrmevent() callback.
  • ProcessInitiator : initialize the PlayReady DRM instance
  • widevine_license_data : Base64-encoded license data with given session id for Widevine CDM. An application shall retrieve license data using challenge data received in ondrmevent() callback.
DRM Type

DRM Operation

JSON Parameters

Value

Description

Playready

SetProperteis

DeleteLicenseAfterUse

boolean (true/false)

  • True: Delete the used license from TV storage after use.
  • False: Do not delete the used license from TV storage after use.
SetProperties

GenChallenge

boolean (true/false)

  • True: Execute PlayReady GenChallenge case. AVPlay will configure Challenge data and provide Challenge data through onDRMEvent callback. Applications are responsible for communicating with license server and getting license. After getting license, applications must perform “InstallLicense” drm operation via setDrm() avplay api.
  • False: Execute PlayReady GetRights case. In this case, PlayReady will communicate with License Server, get License and install license. Applications do not need to perform “InstallLicense” drmoperation.
SetProperties

Cookie

string

Set Cookies.

SetProperties

CustomData

string

Set Custom data.

SetProperties

LicenseServer

string

Set license server url for contents.

SetProperties

HttpHeader

string

Set Http header that the license server requires.

SetProperties

UserAgent

string

Set User agent to be used.

SetProperties

SoapHeader

string

Set Soap header that the license server requires.

InstallLicense

string

Set base64-encoded license data for PlayReady. An application shall retrieve license data using Challenge data received in ondrmevent() callback.

ProcessInitiator

This has been deprecated since 2019.

Initialize

This has been deprecated since 2019.

Finalize

This has been deprecated since 2019.

Verimatrix

SetProperties

CompanyName

string

Set company name.

SetProperties

IPTV

string

Set license server url for IPTV.

SetProperties

Web

string

Set license server url for WebClient.

SetProperties

ClientType

string

Set client type. The value can be "web", "web-hls", "web-dash", or "iptv". Verimatrix supports only “iptv”, “web” and “web-hls”.

Initialize

This has been deprecated since 2019.

Finalize

This has been deprecated since 2019.

Widevine CDM

SetProperties

AppSession

string

Set session ID string for the session established between an application and a server, earlier known as “widevine_app_session”.

SetProperties

DataType

string

Set the data type such as "matroska_webm" or "MPEG-DASH", earlier known as "widevine_data_type".

widevine_license_data

string

Set license data. It accepts string type data that contains base64-encoded license data.

Initialize

This has been deprecated since 2019.

Finalize

This has been deprecated since 2019.

Remark :

  • 'GetUID' operation has been deprecated from Tizen version 5.0, rather application should use getUID() API.
  • 'Initialize' and 'Finalize' operations have been deprecated from Tizen version 5.0. Because these are being executed by avplay itself.
  • 'widevine_app_session' and 'widevine_data_type' operations have been deprecated from Tizen version 5.0. Because these are merged into "SetProperties". Please refer to setDrm() example.

1.9 AVPlayStreamType

Specifies stream types supported by the player.

enum AVPlayStreamType {
  "VIDEO",
  "AUDIO",
  "TEXT"
};

The following values are supported

  • VIDEO : Video track
  • AUDIO : Audio track
  • TEXT : Subtitle track

1.10 AVPlayError

Specifies the player error messages.

enum AVPlayError {
  "PLAYER_ERROR_NONE",
  "PLAYER_ERROR_INVALID_PARAMETER",
  "PLAYER_ERROR_NO_SUCH_FILE",
  "PLAYER_ERROR_INVALID_OPERATION",
  "PLAYER_ERROR_SEEK_FAILED",
  "PLAYER_ERROR_INVALID_STATE",
  "PLAYER_ERROR_NOT_SUPPORTED_FILE",
  "PLAYER_ERROR_NOT_SUPPORTED_FORMAT",
  "PLAYER_ERROR_INVALID_URI",
  "PLAYER_ERROR_CONNECTION_FAILED",
  "PLAYER_ERROR_GENEREIC"
};

The following values are supported

  • PLAYER_ERROR_NONE : Operation has successfully completed; no error.
  • PLAYER_ERROR_INVALID_PARAMETER : Unable to find the parameter
  • PLAYER_ERROR_NO_SUCH_FILE : Unable to find the specified media content
  • PLAYER_ERROR_INVALID_OPERATION : Invalid API Call at the moment
  • PLAYER_ERROR_SEEK_FAILED : Failed to perform seek operation, or seek operation called during an invalid state
  • PLAYER_ERROR_INVALID_STATE : AVPlay API method was called during an invalid state
  • PLAYER_ERROR_NOT_SUPPORTED_FILE : Multimedia file type not supported
  • PLAYER_ERROR_NOT_SUPPORTED_FORMAT : Multimedia file format not supported
  • PLAYER_ERROR_INVALID_URI : Input URI is in an invalid format
  • PLAYER_ERROR_CONNECTION_FAILED : Failed multiple attempts to connect to the specified content server
  • PLAYER_ERROR_GENEREIC : Failed to create the display window

1.11 AVPlayEvent

Specifies player events.

enum AVPlayEvent {
  "PLAYER_MSG_NONE",
  "PLAYER_MSG_RESOLUTION_CHANGED",
  "PLAYER_MSG_BITRATE_CHANGE",
  "PLAYER_SPARSE_TRACK_DETECT",
  "PLAYER_STREAMING_EVENT",
  "PLAYER_MSG_HTTP_ERROR_CODE",
  "PLAYER_MSG_DRM_CHALLENGE_DATA",
  "PLAYER_MSG_CUE_TAG_INFO"
};

The following values are supported

  • PLAYER_MSG_NONE : Notifies that a multimedia component message was not recognized by the player
  • PLAYER_MSG_RESOLUTION_CHANGED : During adaptive streaming playback, notifies that the video resolution has changed
  • PLAYER_MSG_BITRATE_CHANGE : During adaptive streaming playback, notifies of a change, based on network heuristics, in the bandwidth-specific URL. The current bandwidth value is also sent.
  • PLAYER_SPARSE_TRACK_DETECT : During adaptive streaming playback, notifies that a sparse track was encountered
  • PLAYER_STREAMING_EVENT : Posts required streaming data
  • PLAYER_MSG_HTTP_ERROR_CODE : Describes the detailed HTTP network situation information
  • PLAYER_MSG_DRM_CHALLENGE_DATA : For encrypted content playback, posts the DRM challenge data
  • PLAYER_MSG_CUE_TAG_INFO : During adaptive streaming playback, notifies that the video is having a CUE event to indicate the discontinuity due to Ad. Event data is also sent. Sample event data: "CUE_TAG_INFO: {CUEOUT-> timestamp : 18000, Expected AdDuration : 18000}{CUEIN-> timestamp : 36000, Actual AdDuration : 18000}"

Remark :

  • 'PLAYER_MSG_FRAGMENT_INFO' event has been deprecated from Tizen version 2.4, because it affects the application performance.

1.12 AVPlayStreamInfo

Defines a dictionary for streaming video, audio and subtitle information for various streaming scenarios.

dictionary AVPlayStreamInfo {
  unsigned long index;
  AVPlayStreamType type;
  DOMString extra_info;
};

The following values are supported

  • index : unsigned long Index
  • type : Track type (audio, video, or text)
  • extra_info : DOMString JSON string containing all media-related info (such as height, width, and fourCC for a video stream, and bitrate, fourCC, language, and codec type for an audio stream)

1.13 AVPlaySubtitleAttribute

Defines a dictionary for subtitle attributes.

dictionary AVPlaySubtitleAttribute {
  DOMString attr_type;
  long start_pos;
  long stop_pos;
};

The following values are supported

  • attr_type : Attribute type DOMString (json)
  • start_pos : Start position
  • stop_pos : Stop position

1.14 AVPlayVideoSeamlessInfo

Defines a dictionary for auto rotate degree and scan_type of video playback information.

dictionary AVPlayVideoSeamlessInfo {
  ScanType scan_type;
  double rotation_degree;
};

The following values are supported

  • scan_type : scantype of the video (value is 0(interlaced) or 1(progressive))
  • rotation_degree : auto rotate degree of the video (Value can be 0,90,180,270)

2. Interfaces

2.1 AVPlayManagerObject

Defines a WebApi object instance of the Tizen Samsung TV Product API.
The webapis.AVPlay object enables access to AVPlay API functionality.

[NoInterfaceObject] interface AVPlayManagerObject {
  readonly attribute AVPlayManager avplay;
};
WebApi implements AVPlayManagerObject;

Attributes

2.2 AVPlayManager

Provides methods for the AVPlay functionalities.

[NoInterfaceObject] interface AVPlayManager {
  void open(DOMString url);
  void close();
  void prepare();
  void prepareAsync(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
  void setDisplayRect(unsigned long x, unsigned long y, unsigned long width, unsigned long height);
  AVPlayVideoSeamlessInfo getVideoSeamlessInfo();
  void play();
  void seekTo(long milliseconds, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
  void stop();
  AVPlayPlayerState getState();
  void pause();
  void jumpForward(long milliseconds, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
  void jumpBackward(long milliseconds, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
  unsigned long getDuration();
  unsigned long getCurrentTime();
  void setTimeoutForBuffering(unsigned long seconds);
  void setBufferingParam(AVPlayBufferOption option, AVPlayBufferSizeUnit unit, unsigned long amount);
  void setSpeed(long playbackSpeed);
  void setListener(AVPlayPlaybackCallback playbackCallback);
  DOMString setDrm(AVPlayDrmType drmType, AVPlayDrmOperation drmOperation, DOMString jsonParam);
  DOMString getUID(AVPlayDrmType drmType);
  void setSoundAnalysisListener(AVPlaySoundAnalysisCallback soundAnalysisCallback);
  void unsetSoundAnalysisListener();
  void setSilentSubtitle(boolean onoff);
  void setExternalSubtitlePath(DOMString filePath);
  void setSubtitlePosition(long position);
  void setDisplayMethod(AVPlayDisplayMode displayMode);
  void setSelectTrack(AVPlayStreamType trackType, long trackIndex);
  AVPlayStreamInfo[] getCurrentStreamInfo();
  AVPlayStreamInfo[] getTotalTrackInfo();
  void setStreamingProperty(AVPlayStreamingPropertyType propertyType, DOMString propertyParam);
  DOMString getStreamingProperty(AVPlayStreamingPropertyType propertyType);
  DOMString getVersion();
  void suspend();
  void setLooping(boolean isLooping);
  void setVideoStillMode(DOMString mode);
  void setDisplayRotation(DOMString displayRotation);
  void restore(optional DOMString? URL, optional unsigned long? resumeTime, optional boolean? bPrepare);
  void restoreAsync(optional DOMString? URL, optional unsigned long? resumeTime, optional boolean? bPrepare, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
  void enableAudioStream();
  void disableAudioStream();
  void setVideoRoi(double x_ratio, double y_ratio, double w_ratio, double h_ratio);
};

Methods

open

Instantiates the player object with a content URL as the input parameter.

void open(DOMString url);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "NONE", "IDLE"

Parameters :

  • url : Content URL for playback. It can be an absolute local path or a remote URL from a network-based stream server.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Code Example :

try
{
  webapis.avplay.open(url);
}
catch (e)
{
  console.log(e)
}

close

Destroys the player object.

void close();

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "NONE", "IDLE", "READY", "PLAYING", "PAUSED"

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

try
{
  webapis.avplay.close();
}
catch (e)
{
  console.log(e)
}

prepare

Prepares the media player for playback synchronously. The player must already be created with a valid URI.

void prepare();

Product : TV, AV, B2B

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 given URL through open() is invalid. e.g., webapis.avplay.open("InvalidURL").
    • with error type InvalidAccessError, if given URL through open() is valid, but not exist or not accessible due to Network Issue. e.g., webapis.avplay.open("http://abc").
    • with error type InvalidStateError, if it is called in an invalid state.
    • with error type UnknownError, for any other error.

Code Example :

try
{
  webapis.avplay.prepare();
}
catch (e)
{
  console.log(e)
}

prepareAsync

Prepares the media player for playback asynchronously. This method is preferred over prepare because it returns immediately and does not block the application thread during preparation.
When preparation is successful, the success callback is returned and the player is in READY state. If preparation fails, the error callback returns the error value.
When prepareAsync is used with "PREBUFFER_MODE", successCallback is invoked when prebuffering is complete, instead of when preparation is complete.

void prepareAsync(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE", "READY"

Parameters :

  • successCallback [optional][nullable] : Callback method to invoke when the call 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 given URL through open() is invalid. e.g., webapis.avplay.open("InvalidURL").
    InvalidAccessError, if given URL through open() is valid, but 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 its expected type.

Code Example :

webapis.avplay.prepareAsync(successCallback, errorCallback);

setDisplayRect

Sets the display area for video content playback.
The 4 parameters specify the left side, top, window width, and window height based on a 1920 x 1080 resolution screen, regardless of the actual application resolution.

void setDisplayRect(unsigned long x, unsigned long y, unsigned long width, unsigned long height);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states:"IDLE", "READY", "PLAYING", "PAUSED" (when APP is using normal calling sequence , OPEN+setDisplay+PREPARE etc).

Parameters :

  • x : Display area top-left X-coordinate. Must be less than the TV screen width.
  • y : Display area top-left Y-coordinate. Must be less than the TV screen height.
  • width : Display area width. Must be less than the TV screen width.
  • height : Display area height. Must be less than the source image height.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
    • with error type NotSupportedError, if this feature is not supported.
    • with error type InvalidValuesError, if any input parameter contains a negative value.
    • with error type InvalidStateError, if it is called in an invalid state.
    • with error type UnknownError, for any other error.

Code Example :

try
{
  webapis.avplay.setDisplayRect(0, 0, 1920, 1080);
}
catch (e)
{
  console.log(e)
}

getVideoSeamlessInfo

Retrieves the video auto rotate degree and scan_type from demux side.

AVPlayVideoSeamlessInfo getVideoSeamlessInfo();

Product : B2B(LFD)

Constraint :

  • Can be called in the following states: "READY", "PLAYING", "PAUSED"

Return Value :

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, for any other error.

Since : 6.5

Code Example :

Player1 = webapis.avplaystore.getPlayer(); //Playback of Current Video
Player2 = webapis.avplaystore.getPlayer(); //Playback of Next Video
Player1.open('http://www.example.com/example_1.mp4');
Player1.setDisplayRect(x, y, width, height);
Player1.prepare();
var AVPlayVideoSeamlessInfo_1 = Player1.getVideoSeamlessInfo();
var scan_type_1 = AVPlayVideoSeamlessInfo_1.scan_type;
var rotation_degree_1 = AVPlayVideoSeamlessInfo_1.rotation_degree;
Player1.play();
Player2.open('http://www.example.com/example_2.mp4');
Player2.setStreamingProperty("PREBUFFER_MODE", "5000");
Player2.setDisplayRect(x, y, width, height);
var AVPlayVideoSeamlessInfo_2 = Player1.getVideoSeamlessInfo();
var scan_type_2 = AVPlayVideoSeamlessInfo_2.scan_type;
var rotation_degree_2 = AVPlayVideoSeamlessInfo_2.rotation_degree;
if(scan_type_1 == scan_type_2 && rotation_degree_1 == rotation_degree_2){
  Player1.setVideoStillMode("true");
}

//getVideoSeamlessInfo() can be called in prebuffer state, and then comapre scan_type_1 & rotation_degree_1 of current video
//with next video scan_type_2 & rotation_degree_2, if there is mismatch , avoid calling setVideoStillMode(), to avoid flicker.
//In order to work Seamless feature, between two videos, both videos should be of same scan type and rotation_degree.

Player2.prepare();
Player1.stop();
Player2.play();

play

Starts stream playback, or resumes stream playback after pause.

void play();

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "READY", "PLAYING", "PAUSED"

Remark :

  • Adaptive streaming using TS container (for e.g. HLS) with audio sample rate changing across variants may cause audio loss.

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, for any other error.

Code Example :

try
{
  webapis.avplay.play();
}
catch (e)
{
  console.log(e)
}

seekTo

Skips playback to a specific timestamp.
For HTTP streaming, this method is successful even when the specified timestamp is invalid. The internal player automatically resets an out-of-range value to an in-range one.

void seekTo(long milliseconds, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE","READY", "PLAYING" (buffered data is flushed and buffering starts over), "PAUSED"
    During this async operation, the other API would not be allowed. So, the application needs to wait for one of both callbacks( SuccessCallback, errorCallback) before any other API call.
    For LIVE stream case, seek position must be within DVR range. DVR range could be retrieved using GET_LIVE_DURATION property in getStreamingProperty API.

Parameters :

  • milliseconds : Timestamp to skip to
  • successCallback [optional][nullable] : Callback method to invoke when the call 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 given URL through open() is invalid. e.g., webapis.avplay.open("InvalidURL")
    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 its expected type.

Code Example :

try
{
  webapis.avplay.seekTo(10000,successCallback, errorCallback);
}
catch (e)
{
  console.log(e)
}

// for live cases, get the live duration as :
var StartTime = webapis.avplay.getStreamingProperty("GET_LIVE_DURATION").split('|')[0];
var EndTime = webapis.avplay.getStreamingProperty("GET_LIVE_DURATION").split('|')[1];
// seekpoint must be between StartTime and Endtime.

stop

Stops the player. Call this function after the video finishes playing.

void stop();

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "NONE", "IDLE", "READY", "PLAYING", "PAUSED"

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

try
{
  webapis.avplay.stop();
}
catch (e)
{
  console.log(e)
}

getState

Retrieves the current player state.

AVPlayPlayerState getState();

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "NONE", "IDLE", "READY", "PLAYING", "PAUSED"

Return Value :

  • AVPlayPlayerState : AVPlayPlayerState "NONE", "IDLE", "READY", "PLAYING", "PAUSED".

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

var BRet = webapis.avplay.getState();

pause

Pauses playback. If this method is called successfully, current time updates are stopped.

void pause();

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "PLAYING", "PAUSED"

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 InvalidAccessError, if this API couldn't operate at the moment. (E.g. During the async operation such as seekTo, etc.)
    • with error type UnknownError, for any other error.

Code Example :

try
{
  webapis.avplay.pause();
}
catch (e)
{
  console.log(e)
}

jumpForward

Skips playback forward by a specific amount of time. The player state is unchanged.
Passing the optional callbacks is recommended. For best performance, ensure that the previous call to this API was successful.
For HTTP streaming, this method is successful even when the resulting timestamp is invalid. The internal player automatically resets an out-of-range value to an in-range one.

void jumpForward(long milliseconds, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "READY" (when using the synchronous prepare method), "PLAYING", "PAUSED"
    During this async operation, the other API would not be allowed. So, the application needs to wait for one of both callbacks( SuccessCallback, errorCallback) before any other API call.

Parameters :

  • milliseconds : Time to skip forward, in milliseconds
  • successCallback [optional][nullable] : Callback method to invoke when the call 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 given URL through open() is invalid. e.g., webapis.avplay.open("InvalidURL").
    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 its expected type.

Code Example :

webapis.avplay.jumpForward(5000,successCallback, errorCallback);

jumpBackward

Skips playback backward by a specific amount of time. The player state is unchanged.
For HTTP streaming, this method is successful even when the resulting timestamp is invalid. The internal player automatically resets an out-of-range value to an in-range one.

void jumpBackward(long milliseconds, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "READY" (when using the synchronous prepare method), "PLAYING", "PAUSED"
    During this async operation, the other API would not be allowed. So, the application needs to wait for one of both callbacks( SuccessCallback, errorCallback) before any other API call.

Parameters :

  • milliseconds : Time to skip backward, in milliseconds
  • successCallback [optional][nullable] : Callback method to invoke when the call 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 given URL through open() is invalid. e.g., webapis.avplay.open("InvalidURL").
    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 its expected type.

Code Example :

webapis.avplay.jumpBackward(5000,successCallback, errorCallback);

getDuration

Retrieves the total media duration.

unsigned long getDuration();

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states:"NONE", "IDLE", "READY", "PLAYING", "PAUSED"

Return Value :

  • unsigned long : unsigned long number Duration, in milliseconds

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

duration = calcPlaytime(webapis.avplay.getDuration())

function calcPlaytime(totalMilisec) {
  var Hours = Math.floor(totalMilisec/3600000);
  var Minutes = Math.floor((totalMilisec - (Hours3600000)) / 60000);
  var Seconds = Math.floor((totalMilisec - (Hours3600000) - (Minutes60000)) / 1000);
  var Milisec = totalMilisec - (Hours3600000) - (Minutes60000) - (Seconds1000);
  return {
    Hours: Hours,
    Minutes: Minutes,
    Seconds: Seconds,
    milisec: Milisec,
    totalMilisec: totalMilisec
  }
}

getCurrentTime

Retrieves the current playback time.

unsigned long getCurrentTime();

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "NONE", "IDLE", "READY", "PLAYING", "PAUSED"

Return Value :

  • unsigned long : unsigned long number Current playback time, in milliseconds.

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

var CurrentPlayTime = webapis.avplay.getCurrentTime();

setTimeoutForBuffering

Sets the stream buffering timeout. When the specified amount of time has passed, the onbufferingcomplete callback is invoked, irrespective of buffering progress.
If not set using this method, the default buffer size is 32MB or 10 seconds of playable data, and 20 seconds time-out.

void setTimeoutForBuffering(unsigned long seconds);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE", "READY", "PLAYING", "PAUSED"

Parameters :

  • seconds : Buffering timeout duration, in seconds. Depending on network conditions, 3 to 10 seconds is recommended.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Code Example :

webapis.avplay.setTimeoutForBuffering(10);

setBufferingParam

Sets the buffer size for the play and resume scenarios. The time buffer size must be at least 4 seconds.
For example, if a 10 second buffer size is set, playback can only start or resume after 10 seconds of media has accumulated in the buffer.
Play scenarios include user-initiated streaming playback and whenever media playback is starting for the first time.
Resume scenarios include resuming playback after pause or seek operations, or when lack of data causes playback rebuffering.

void setBufferingParam(AVPlayBufferOption option, AVPlayBufferSizeUnit unit, unsigned long amount);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE"

Parameters :

  • option : "PLAYER_BUFFER_FOR_PLAY" or "PLAYER_BUFFER_FOR_RESUME"
  • unit : "PLAYER_BUFFER_SIZE_IN_SECOND" or "PLAYER_BUFFER_SIZE_IN_BYTE"
  • amount : Data amount to be buffered, in seconds as specified by the unit parameter

Remark :

  • unit "PLAYER_BUFFER_SIZE_IN_BYTE" has been deprecated from Tizen version 5.0
  • Since tizen version 6.0, if first parameter contains a value which is not in AVPlayBufferOption enum, TypeMismatchError is thrown instead of InvalidValuesError.
  • Since tizen version 6.0, if second parameter contains a value which is not in AVPlayBufferSizeUnit enum, TypeMismatchError is thrown instead of InvalidValuesError.
  • Since tizen version 6.0, if third parameter contains a value which is not unsigned long, TypeMismatchError is thrown instead of InvalidValuesError.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Code Example :

// For the initial buffering
webapis.avplay.setBufferingParam("PLAYER_BUFFER_FOR_PLAY","PLAYER_BUFFER_SIZE_IN_SECOND", 5);  // 5 is in seconds
// For the rebuffering
webapis.avplay. setBufferingParam("PLAYER_BUFFER_FOR_RESUME","PLAYER_BUFFER_SIZE_IN_SECOND", 15);  // 15 is in seconds

setSpeed

Sets the current playback rate. Positive parameter values play the media forwards, while negative values cause the media to play in reverse.
The range of valid playback rates depends on the streaming protocol. If the input parameter is out of range, the player returns the PLAYER_ERROR_INVALID_PARAMETER flag.

void setSpeed(long playbackSpeed);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "READY, "PLAYING", "PAUSED"
    For the general HTTP and HTTPS, the supported playback rate is -8x ~ 8x. (Repeated seek)
    Please refer to the specification (https://developer.samsung.com/tv/develop/specifications/general-specifications/#streaming-feature-support) for the supported range of other streaming types.

Parameters :

  • playbackSpeed : -16x, -8x, -4x, -2x, 1x, 2x, 4x, 8x, 16x

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Code Example :

try
{
  webapis.avplay.setSpeed(2);
}
catch (e)
{
  console.log(e)
}

setListener

Sets asynchronous callback methods for player information notifications, such as buffering progress, player information, playback mode, and DRM mode information.

void setListener(AVPlayPlaybackCallback playbackCallback);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "NONE", "IDLE" (recommended), "READY", "PLAYING", "PAUSED"
    To avoid missing necessary information, the onbufferingstart, onbufferingprogress, onbufferingcomplete, onerror, onerrormsg, onevent, and ondrmevent listeners must be set during the "IDLE" state.

Parameters :

  • playbackCallback : AVPlayPlaybackCallback

Remark :

  • All callback functions are optional. User can add only the methods for necessary notifications.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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 UnknownError, for any other error.

Code Example :

var Listener = {
  onbufferingstart: function() {
    console.log("Buffering start.");
  },
  onbufferingprogress: function(percent) {
    console.log("Buffering progress data : " + data1);
  },
  onbufferingcomplete: function() {
    console.log("Buffering complete.");
  },
  oncurrentplaytime: function(currentTime) {
    console.log("Current Playtime : " + data1);
  },
  onbufferingcomplete: function() {
    console.log("Buffering complete.");
  },
  onevent: function(eventType, eventData) {
    console.log("event type error : " + eventType + ", data: " + eventData);
  },
  onerror: function(eventType) {
    console.log("event type error : " + eventType);
  },
  onerrormsg: function(eventType,eventMsg) {
    console.log("event type error : " + eventType);
    console.log("event Message : " + eventMsg);
  },
  onsubtitlechange: function(duration, text, data3, data4) {
    console.log("Subtitle Changed.");
  },
  ondrmevent: function(drmEvent, drmData) {
    console.log("DRM callback: " + drmEvent + ", data: " + drmData);
  },
  onstreamcompleted: function() {
    console.log("Stream Completed");
  }
}

webapis.avplay.setListener(Listener);

setDrm

Updates the DRM information, such as SetProperties. You can change the DRM mode and run the control feature. The AVPlayDrmOperation and jsonParam parameters depend on the DRM type.
Please refer to the specification (https://developer.samsung.com/tv/develop/specifications/general-specifications) for the supported DRM.

DOMString setDrm(AVPlayDrmType drmType, AVPlayDrmOperation drmOperation, DOMString jsonParam);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE"

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/drmplay

Parameters :

  • drmType : AVPlayDrmType {"PLAYREADY", "VERIMATRIX", "WIDEVINE_CDM" }
  • drmOperation : AVPlayDrmOperation : String specifying the DRM operation to be performed. The valid values are depending on the DRM Types.
    This is mainly used for setting DRM information, such as the license server, application-specific custom data, SOAP or HTTP header, the genChallenge mode, and license usage.
  • jsonParam : DOMString DRM parameter represented by JSON string. You can use the JSON.stringify method to generate the JSON string.

Return Value :

  • DOMString : DRMString

Remark :

  • 'VERIMATRIX' DRM Not supported web client since Tizen 7.0.
  • 'GetUID' operation has been deprecated from Tizen version 5.0, rather application should use getUID() API.
  • 'Initialize' and 'Finalize' operations have been deprecated from Tizen version 5.0. Because these are being executed by avplay itself.
  • 'widevine_app_session' and 'widevine_data_type' operations have been deprecated from Tizen version 5.0. Because these are merged into "SetProperties". Please refer to setDrm() example.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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 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, for any other error.
      Examples of exception scenarios include an invalid DRM session, or failure to create the underlying DRM module or configuration. In these scenarios, an exception is thrown and the method call returns FALSE.

Code Example :

// Implementing DRM support
// 1. PlayReady example: Setting license server and custom data

// 1.1 PlayReady with GenChallenge (supported since TIzen 4.0)
var Listener = {
  ondrmevent: function(drmType, drmData) {
    if(drmData.name === 'Challenge') {
      // take drmData.challenge to obtain license data.
    }
  }
}
webapis.avplay.setListener(Listener);
var appdata={DeleteLicenseAfterUse:true,GetChallenge:true,LicenseServer:"http://license.company.com", CustomData:"mycustom"};
webapis.avplay.setDrm("PLAYREADY", "SetProperties", JSON.stringify(appdata));

// The avplay will configure and provide challenged data through ondrmevent() callback.
// Once challenge data is received, the application should first decode challenge data using base64, and obtain license from the license server.
var license_data;// After obtaining license data, encode it using base64 and save into this 'license_data'.
webapis.avplay.setDrm("PLAYREADY", "InstallLicense", license_data);
// 1.2. PlayReady without GenChallenge
var appdata={DeleteLicenseAfterUse:true, LicenseServer:"http://license.company.com", CustomData:"mycustom"};
webapis.avplay.setDrm("PLAYREADY", "SetProperties", JSON.stringify(appdata));
// 2. Verimatrix example: Initializing Verimatrix DRM
// Application should call GetUID only once and save it for further use, after every open API GetUID need not be called.
if (true) {  // Since Tizen version 5.0
  DOMString Verimatrix_UID = webapis.avplay.getUID("VERIMATRIX");
} else {  // Before Tizen version 5.0
  webapis.avplay.setDrm( "VERIMATRIX", "GetUID", "");
}
// After open application should follow following sequence
var DrmParam = {};
DrmParam.CompanyName ="MyCompany";
DrmParam.IPTV="public2.verimatrix.com";
DrmParam.Web="public-ott-nodrm.verimatrix.com:80";
if (true) {  // Since Tizen version 5.0
  webapis.avplay.setDrm( "VERIMATRIX", "SetProperties", JSON.stringify(DrmParam));
} else {  // Before Tizen version 5.0
  webapis.avplay.setDrm( "VERIMATRIX", "Initialize", JSON.stringify(DrmParam));
}

// 3. Widevine Modular example
var sessionId;
var Listener = {
  ondrmevent: function(drmType, drmData) {
    if(drmData.name === 'Challenge') {
      sessionId = drmData.session_id;
      // take drmData.challenge and drmData.serverurl to obtain license data.
    }
  }
}
webapis.avplay.setListener(Listener);

var DrmParam = {};
// Sample session value; App must set there own session id.
DrmParam.AppSession = "test-session";
DrmParam.DataType = "MPEG-DASH";
if (true) {  // Since Tizen version 5.0
  webapis.avplay.setDrm("WIDEVINE_CDM", "SetProperties", JSON.stringify(DrmParam));
} else {  // Before Tizen version 5.0
  webapis.avplay.setDrm("WIDEVINE_CDM", "Initialize", "");
  webapis.avplay.setDrm("WIDEVINE_CDM", "widevine_app_session", DrmParam.AppSession);
  webapis.avplay.setDrm("WIDEVINE_CDM", "widevine_data_type", DrmParam.DataType);
}
// The avplay will configure and provide challenged data and session id through ondrmevent() callback.
// Once challenge data is received, the application should first decode challenge data using base64, and obtain license from the license server.
var license_data;// After obtaining license data, encode it using base64 and save into this 'license_data'.
var LicenseParam = sessionId + "PARAM_START_POSITION" + license_data + "PARAM_START_POSITION";
webapis.avplay.setDrm("WIDEVINE_CDM", "widevine_license_data", LicenseParam);
//In Tizen 5.0 onwards use EME_WIDEVINE_CDM instead of using WIDEVINE_CDM

getUID

Gets the device UID. The input would be the drm type.

DOMString getUID(AVPlayDrmType drmType);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "NONE", "IDLE", "READY", "PLAYING", "PAUSED".

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/drmplay

Parameters :

  • drmType : AVPlayDrmType {"VERIMATRIX"} // only VERIMATRIX is supported AVPlayDrmType for getUID interface.

Return Value :

  • DOMString : DOMString

Remark :

  • Since tizen version 6.0, if input contains a value which is not in AVPlayDrmType enum, TypeMismatchError is thrown instead of InvalidValuesError.
  • Its deprecated Because Verimatrix Not supported web client since Tizen 7.0.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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 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.
    • with error type UnknownError, for any other error.

Deprecated : 7.0

Code Example :

var verimatrixUID = webapis.avplay.getUID("VERIMATRIX"); //Verimatrix example: Retrieving the Verimatrix UID

setSoundAnalysisListener

Retrieves the audio spectrum analysis result every 30 ms. You can use it for an equalizer effect video or in a PartyTV application. The spectrum is analyzed across an array of 31 bands, of which Bands[14] ~ Bands[18] generally have the largest values.

void setSoundAnalysisListener(AVPlaySoundAnalysisCallback soundAnalysisCallback);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE"

Parameters :

  • soundAnalysisCallback : AVPlaySoundAnalysisCallback

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Deprecated : 2.4

Code Example :

webapis.avplay.setSoundAnalysisListener(soundAnalysisListener);

function soundAnalysisListener(dataArray) {           // Listener registered to and receiving data from AVPlay
  var BarHeight = 0;
  var AbsValue = 0;
  var Threshold = 70;
  for (var I = 0; I < dataArray.length; I++) {
    AbsValue = Math.abs(dataArray[I]);
    if (AbsValue > Threshold) {
      BarHeight = Main.barContainerHeight;
    }
    else {
      BarHeight = Math.round((AbsValue/Threshold)Main.barContainerHeight);
    }
    if (BarHeight == 0) BarHeight = 1;
    document.getElementById('frequencyBar' + I).style.height = BarHeight + 'px';
  }
  console.log("Sound analysis: " + dataArray.toString());
}

unsetSoundAnalysisListener

Unregisters the sound analysis listener.

void unsetSoundAnalysisListener();

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE", "READY", "PLAYING", "PAUSED"

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, for any other error.

Deprecated : 2.4

Code Example :

webapis.avplay.unsetSoundAnalysisListener();

setSilentSubtitle

Enables or disables external subtitles.

void setSilentSubtitle(boolean onoff);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE", "READY" (when using the synchronous prepare method), "PLAYING", "PAUSED"

Parameters :

  • onoff : Boolean value:
    true: Subtitles are hidden
    false: Subtitles are shown. The application does not receive any subtitle-related events.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Code Example :

webapis.avplay.setSilentSubtitle(true);

setExternalSubtitlePath

Sets the local path for the external subtitle file. Only absolute local paths are supported. If the subtitle file is stored remotely, you must first download the file to local storage, and pass the absolute local path.

void setExternalSubtitlePath(DOMString filePath);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE", "READY", "PLAYING", "PAUSED"

Parameters :

  • filePath : Absolute local path

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Code Example :

webapis.avplay.setExternalSubtitlePath(uri);

setSubtitlePosition

Adjusts external subtitle synchronization with the audio and video.

void setSubtitlePosition(long position);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "PLAYING", "PAUSED"

Parameters :

  • position : Time delay in milliseconds. The duration can be a positive or negative number; a positive delay displays the subtitles later, while a negative delay displays the subtitles sooner.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Code Example :

webapis.avplay.setSubtitlePosition(position_millisec);

setDisplayMethod

Sets the video screen mode in the specified display area.

void setDisplayMethod(AVPlayDisplayMode displayMode);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE", "READY", "PLAYING", "PAUSED"

Parameters :

  • displayMode : "PLAYER_DISPLAY_MODE_LETTER_BOX", "PLAYER_DISPLAY_MODE_FULL_SCREEN", or "PLAYER_DISPLAY_MODE_AUTO_ASPECT_RATIO"

Remark :

  • Since tizen version 6.0, if input contains a value which is not in AVPlayDisplayMode enum, TypeMismatchError is thrown instead of InvalidValuesError.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Code Example :

webapis.avplay.setDisplayMethod("PLAYER_DISPLAY_MODE_FULL_SCREEN");

setSelectTrack

Switches audio or subtitle tracks during playback.

void setSelectTrack(AVPlayStreamType trackType, long trackIndex);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "READY" (for Smooth Streaming only), "PLAYING", "PAUSED" (for TEXT tracks only)
  • The trackType "TEXT" is not supported for DASH streaming.

Parameters :

  • trackType : "AUDIO" or "TEXT"
  • trackIndex : AVPlayStreamInfo index

Remark :

  • Since tizen version 6.0, if first parameter contains a value which is not in AVPlayStreamType enum, TypeMismatchError is thrown instead of InvalidValuesError.
  • Since tizen version 5.0, the trackType "AUDIO" is supported for DASH streaming.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

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);
  }
}
// Choose subtitle track index 2
webapis.avplay.setSelectTrack('TEXT',2);

getCurrentStreamInfo

Retrieves the currently-playing video, audio, or subtitle stream information, and notifies that a stream is playing.

AVPlayStreamInfo[] getCurrentStreamInfo();

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "READY", "PLAYING", "PAUSED"

Return Value :

  • AVPlayStreamInfo[] : AVPlayStreamInfo array of objects containing tracktype, extraInfo and index for the current stream

Remark :

  • For the adaptive streaming such as HLS, DASH and SmoothStreaming, the 'language' is same as what represented on given manifest file.

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, for any other error.

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 streams have extra_info as a JSONString.
// video extra_info example : "{fourCC:"H264","Width":"1920","Height":"1080","Bit_rate":" 477000"}"
// audio extra_info example : "{"language":"en","channels":"2","sample_rate":"44100","bit_rate":"96000","fourCC":"AACL"}"
// text(subtitle) extra_info example : "{"track_num":"0","track_lang":"en","subtitle_type":"-1","fourCC":"TTML"}"
// If the stream is invalid, the DOMString is null and the index value is -1.

getTotalTrackInfo

Retrieves the currently-playing stream information.

AVPlayStreamInfo[] getTotalTrackInfo();

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "READY" (when using the synchronous prepare method), "PLAYING", "PAUSED"

Return Value :

  • AVPlayStreamInfo[] : AVPlayStreamInfo[] structure containing tracktype, extraInfo and Index of current stream
    Returns information for the all available tracks in the stream. The information is returned in the following structure:
    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"}"
    For subtitle tracks:
    "{"track_num":"%d","track_lang":"%s","subtitle_type":"%d","fourCC":"%s"}"
    Some of them are not constant value(E.g. Video:Width, Height, and Bit_rate, Audio:channels, sample_rate, and bit_rate) for adaptive streaming such as HLS, DASH and SmoothStreaming.

Remark :

  • For the adaptive streaming such as HLS, DASH and SmoothStreaming, the 'language' is same as what represented on given manifest file.

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, for any other error.

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

Sets specific feature values for HTTP, MMS, or specific streaming engine (Smooth Streaming, HLS, DASH, DivX Plus Streaming, or Widevine). The available streaming properties depend on the streaming protocol or engine.
Use the CUSTOM_MESSAGE property for streaming engine or CP-specific settings.

void setStreamingProperty(AVPlayStreamingPropertyType propertyType, DOMString propertyParam);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE"

Parameters :

  • propertyType : { "COOKIE", "USER_AGENT", "PREBUFFER_MODE" , "ADAPTIVE_INFO", "SET_MODE_4K", "PROPERTY_HD_AUDIO", "LISTEN_SPARSE_TRACK", "WIDEVINE", "USE_VIDEOMIXER", "SET_MIXEDFRAME", "PORTRAIT_MODE" , "IN_APP_MULTIVIEW" };
  • propertyParam : Value according to the propertyType. e.g. "ADAPTIVE_INFO" PropetyTypes are "BITRATES", "STARTBITRATE", "SKIPBITRATE" . "IN_APP_MULTIVIEW" PropetyTypes are "VIDEO_VIEW_RESOURCE_MAIN" , "VIDEO_VIEW_RESOURCE_SUB" .

Remark :

  • "USE_VIDEOMIXER", "SET_MIXEDFRAME" are only for product B2B and available from Tizen 2.4 onwards.
  • "PORTRAIT_MODE" is only for product B2B and available from Tizen 3.0 onwards.
  • "WIDEVINE" unit has been deprecated from Tizen version 4.0
  • "PROPERTY_HD_AUDIO" unit has been deprecated from Tizen version 2.4
  • Since tizen version 6.0, if first paramter contains a value which is not in AVPlayStreamingPropertyType enum, TypeMismatchError is thrown instead of InvalidValuesError.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Code Example :

//Smooth Streaming example:
var BitRateString = "BITRATES=5000~10000|STARTBITRATE=HIGHEST|SKIPBITRATE=LOWEST";
webapis.avplay.setStreamingProperty("ADAPTIVE_INFO", BitRateString);

//Prebuffer mode example:
//Player1 => Playback of Main Content
//Player2 => Playback of advertisement (Buffered   the ad content before playback).
Player1 = webapis.avplaystore.getPlayer();
Player2 = webapis.avplaystore.getPlayer();
Player1.open('http://www.example.com/example_1.mp4');
Player1.setDisplayRect(x, y, width, height);
Player1.prepare();
Player1.play();
Player2.open('http://www.example.com/example_2.mp4');
Player2.setStreamingProperty("PREBUFFER_MODE", "5000");
Player2.setDisplayRect(x, y, width, height);
Player2.prepare();
Player1.stop();
Player2.play();

//User-agent example:
webapis.avplay.setStreamingProperty("USERAGENT", "samsungsmooth-agent/1.1");

Setting resolution information for HLS/DASH
webapis.avplay.setStreamingProperty("ADAPTIVE_INFO", "FIXED_MAX_RESOLUTION=7680X4320");


//Mixer example:
Player1 = webapis.avplaystore.getPlayer();
Player2 = webapis.avplaystore.getPlayer();
Player1.open(url1);
Player1.setStreamingProperty("USE_VIDEOMIXER", ""); //enable video mixer
Player1.setDisplayRect(17, 17, 932, 1044); //configure the position (coordinates) of this player instance, used for SET_MIXEDFRAME
Player1.prepare();
Player1.setStreamingProperty("SET_MIXEDFRAME", ""); //now sets position of mixed frame
Player1.play();

Player2.open(url2);
Player2.setStreamingProperty("USE_VIDEOMIXER", ""); //enable video mixer
Player2.setDisplayRect(973, 17, 932, 1044); //configure the position (coordinates) of this player instance, used for SET_MIXEDFRAME
Player2.prepare();
Player2.setStreamingProperty("SET_MIXEDFRAME", ""); //now sets position of mixed frame
Player2.play();

// 2 Video Simulatenous Play example(IN_APP_MULTIVIEW):
player1 = webapis.avplaystore.getPlayer()
player2 = webapis.avplaystore.getPlayer();
//player1 => Playback of Main Content
//player2 => Playback of SUB Content
player1.open(MainUrl);
player1.setListener(listener1);
player1.setDisplayRect(0, 0, 1920, 1080);
//player1.setStreamingProperty('IN_APP_MULTIVIEW','VIDEO_VIEW_RESOURCE_MAIN');
//By default it will use MAIN Video Resource
player1.prepare();
player1.play();

player2.open(SubURL);
player2.setListener(listener2);
player2.setDisplayRect(700, 0, 600, 400);
player2.disableAudioStream();
player2.setStreamingProperty('IN_APP_MULTIVIEW','VIDEO_VIEW_RESOURCE_SUB');
player2.prepare();
player2.play();

getStreamingProperty

Retrieves a specific property value obtained by the streaming engine (Smooth Streaming, HLS, DASH, or Widevine).

DOMString getStreamingProperty(AVPlayStreamingPropertyType propertyType);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "READY", "PLAYING", "PAUSED"

Parameters :

  • propertyType : AVPlayStreamingPropertyType { "IS_LIVE", "AVAILABLE_BITRATE", "GET_LIVE_DURATION","CURRENT_BANDWIDTH"};

Return Value :

  • DOMString : DOMString Property value

Remark :

  • Since tizen version 6.0, if input contains a value which is not in AVPlayStreamingPropertyType enum, TypeMismatchError is thrown instead of InvalidValuesError.
  • GET_SERVER_TIME_SCALE and GET_ABSOLUTE_SERVER_TIME: Supported for Smooth Streaming only.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Code Example :

var Text = 'AVAILABLE_BITRATE: ' + webapis.avplay.getStreamingProperty ("AVAILABLE_BITRATE") ;
Text += 'CURRENT_BANDWIDTH: ' + webapis.avplay.getStreamingProperty ("CURRENT_BANDWIDTH") + '';
Text += 'IS_LIVE: ' + webapis.avplay.getStreamingProperty ("IS_LIVE") +'';

@code
var StartTime = webapis.avplay.getStreamingProperty("GET_LIVE_DURATION").split('|')[0];
var EndTime = webapis.avplay.getStreamingProperty("GET_LIVE_DURATION").split('|')[1];

if (StartTime > targetSeekTime)
{
  if (EndTime < targetSeekTime)
  {
    webapis.avplay.seekTo(targetSeekTime);  //ms
  }
}

getVersion

Retrieves the AVPlay version.

DOMString getVersion();

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "NONE", "IDLE", "READY", "PLAYING", "PAUSED"

Return Value :

  • DOMString : DOMString string current version

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

var Version = webapis.avplay.getVersion();

suspend

Pauses the player state when the application is sent to the background. Saves the current statistics for the ongoing playback session.

void suspend();

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "READY, "PLAYING", "PAUSED"

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, for any other error.

Code Example :

document.addEventListener("visibilitychange", function() {
  if(document.hidden){
    // Something you want to do when application is paused.
    console.log("lifecycle [pause]");
    webapis.avplay.suspend();
  } else {
    // Something you want to do when application is resumed.
    console.log("lifecycle [resume]");
    webapis.avplay.restore();
  }
});

setLooping

This method sets the player's looping status. If the looping status is true, playback automatically restarts upon finishing. If it is false, it won't. The default value of looping status is false.

void setLooping(boolean isLooping);

Product : B2B(LFD)

Constraint :

  • Can be called in the following states: "IDLE","READY", "PLAYING", "PAUSED"

Parameters :

  • isLooping : The new looping status where true means looping and false means non-looping.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Since : 4.0

Code Example :

webapis.avplay.setLooping(true);

setVideoStillMode

This method sets video still mode. Still mode is for freezing last frame in display buffer.

void setVideoStillMode(DOMString mode);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE", "READY", "PLAYING", "PAUSED"

Parameters :

  • mode : The still mode value where "true" sets video still mode and "false" turns off video still mode.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Since : 4.0

Code Example :

webapis.avplay.setVideoStillMode("true");

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 coordinates. So, Application should call setDisplayRect() again after calling this API.

void setDisplayRotation(DOMString displayRotation);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "IDLE", "READY", "PLAYING", "PAUSED"

Parameters :

  • displayRotation : The rotation of the display. The valid values for 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 its 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.
    • with error type UnknownError, for any other error.

Since : 4.0

Code Example :

webapis.avplay.setDisplayRotation("PLAYER_DISPLAY_ROTATION_90");

restore

During multitasking, restores the player state when the application is resumed. For live streaming or DRM-encrypted content playback, you must check whether the streaming URL has changed or the DRM session or license has expired, and specify the new URL and DRM information as needed.

void restore(optional DOMString? URL, optional unsigned long? resumeTime, optional boolean? bPrepare);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "NONE", "PLAYING", "PAUSED"

Parameters :

  • URL [optional][nullable] : Optional updated URL after suspend. If null, the stored URL is used.
    For live streaming or DRM-encrypted content playback, in case the URL has changed or the DRM license or session has expired, checking for and passing the newest URL is recommended.
  • resumeTime [optional][nullable] : (milliseconds) Optional. Position from which to resume playback. If 0, the stored position is used.
    For live streaming, this parameter is not meaningful. Do not pass 0 for this parameter.
    For DRM-encrypted content playback, if the DRM session has expired, to recreate the playback pipeline, pass 0 for this parameter.
  • bPrepare [optional][nullable] : Optional boolean. false (default): Player sets the resume behavior automatically. true: Player does not resume automatically. The application must invoke the prepare and play methods.
    For live streaming, this parameter is not meaningful. Do not pass true for this parameter.
    For DRM-encrypted content playback: if the DRM session has expired, pass true for this parameter.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Code Example :

document.addEventListener("visibilitychange", function() {
  if(document.hidden){
    // Something you want to do when application is paused
    console.log("lifecycle [pause]");
    webapis.avplay.suspend();
  } else {
    // Something you want to do when application is resumed
    console.log("lifecycle [resume]");
    webapis.avplay.restore(url, 0, false);
  }
});

restoreAsync

During multitasking, restores the player state when the application is resumed. restoreAsync is an asynchronous interface.
Other API, restore is a synchronous interface which blocks the application thread.
This method is preferred over restore because it returns immediately and does not block the application thread during its restoration.
When player is restored successful, the success callback is returned and player resumed the playback from the restored playback position, state, properties etc.
If restoration fails, the error callback returns the error value.
Application is required to make further calls to avplay on its success or failure callback happens.
For live streaming or DRM-encrypted content playback, you must check whether the streaming URL has changed or the DRM session or license has expired, and specify the new URL and DRM information as needed.

void restoreAsync(optional DOMString? URL, optional unsigned long? resumeTime, optional boolean? bPrepare, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);

Product : TV, AV, B2B

Constraint :

  • Can be called in the following states: "NONE", "PLAYING", "PAUSED"

Parameters :

  • URL [optional][nullable] : Optional updated URL after suspend. If null, the stored URL is used.
    For live streaming or DRM-encrypted content playback, in case the URL has changed or the DRM license or session has expired, checking for and passing the newest URL is recommended.
  • resumeTime [optional][nullable] : (milliseconds) Optional. Position from which to resume playback. If 0, the stored position is used.
    For live streaming, this parameter is not meaningful. Do not pass 0 for this parameter.
    For DRM-encrypted content playback, if the DRM session has expired, to recreate the playback pipeline, pass 0 for this parameter.
  • bPrepare [optional][nullable] : Optional boolean. false (default): Player sets the resume behavior automatically. true: Player does not resume automatically. The application must invoke the prepare and play methods.
    For live streaming, this parameter is not meaningful. Do not pass true for this parameter.
    For DRM-encrypted content playback: if the DRM session has expired, pass true for this parameter.
  • successCallback [optional][nullable] : Callback method to invoke when the call is successful
  • errorCallback [optional][nullable] : Callback method to invoke when an error occurs

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its 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.
    • with error type UnknownError, for any other error.

Code Example :

document.addEventListener("visibilitychange", function() {
  if(document.hidden){
    // Something you want to do when application is paused
    console.log("lifecycle [pause]");
    webapis.avplay.suspend();
  } else {
    // Something you want to do when application is resumed
    console.log("lifecycle [resume]");
    try {
      var successCallback = function()
      {
        console.log("success");
      }
      var errorCallback = function(err)
      {
        throw new Error('Error:' + err.name);
      }
      webapis.avplay.restoreAsync(url, 0, false, successCallback, errorCallback);
    } catch (e) {
      console.log(e)
    }
  }
});

enableAudioStream

API to enable Audio Stream of a particular player instance out of current playing player instances. This Api disables audio stream of current active player instance and then enable Audio for the player instance for which enableAudioStream() has been called.

void enableAudioStream();

Product : TV,AV,B2B

Constraint :

  • Can be called in the following states: "IDLE", "READY", "PLAYING", "PAUSED"

Remark :

  • If application calls this API for a particular instance then its application responsibility to take care of for enable/disable Audio Stream using respective API's when required.
  • This API is available in TV since Tizen 6.5

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, for any other error.

Code Example :

try
{
  webapis.avplay.enableAudioStream();
}
catch (e)
{
  console.log(e)
}

disableAudioStream

API to disable Audio Stream of a particular player instance out of current playing player instances.

void disableAudioStream();

Product : TV,AV,B2B

Constraint :

  • Can be called in the following states: "IDLE", "READY", "PLAYING", "PAUSED"

Remark :

  • If application calls this API for a particular instance then its application responsibility to take care of for enable/disable Audio Stream using respective API's when required.
  • This API is available in TV since Tizen 6.5

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, for any other error.

Code Example :

try
{
  webapis.avplay.disableAudioStream();
}
catch (e)
{
  console.log(e)
}

setVideoRoi

Sets the ROI (Region Of Interest) area of the content video source.

void setVideoRoi(double x_ratio, double y_ratio, double w_ratio, double h_ratio);

Product : B2B(LFD)

Constraint :

  • Can be called in the following states: "READY, "PLAYING", "PAUSED"
    Please refer to the specification (https://developer.samsung.com/tv/develop/specifications/general-specifications/#streaming-feature-support) for the supported range of other streaming types.

Parameters :

  • x_ratio : coordinate ratio value of x to the max video source width size, Valid range is 0.0~1.0.
  • y_ratio : coordinate ratio value of y to the max video source height size, Valid range is 0.0~1.0.
  • w_ratio : Width ratio value of the video source area based on the video width size, Valid range is from greater than 0.0 to 1.0.
  • h_ratio : Height ratio value of the video source area based on the video height size, Valid range is from greater than 0.0 to 1.0.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
    • with error type InvalidValuesError, if any input parameter contains an invalid value.
    • with error type InvalidStateError, if it is called in an invalid state.
    • with error type UnknownError, for any other error.
    • with error type NotSupportedError, if this API is called from a TV device application.

Since : 6.0

Code Example :

try
{
  webapis.avplay.setVideoRoi(0,0,0.5,0.5);
}
catch (e)
{
  console.log(e)
}

;

2.3 AVPlayPlaybackCallback

Defines callbacks for buffering and playback notifications.

[Callback=FunctionOnly, NoInterfaceObject] interface AVPlayPlaybackCallback {
  void onbufferingstart();
  void onbufferingprogress(unsigned long percent);
  void onbufferingcomplete();
  void oncurrentplaytime(unsigned long currentTime);
  void onstreamcompleted();
  void onevent(AVPlayEvent eventid, DOMString data);
  void onerror(AVPlayError eventid);
  void onerrormsg(AVPlayError eventid, DOMString errorMsg);
  void ondrmevent(AVPlayDrmType type, drmData data);
  void onsubtitlechange(DOMString duration, DOMString subtitles, DOMString type, AVPlaySubtitleAttribute[] attributes);
};

Methods

onbufferingstart

Callback method for asynchronous buffering started notifications.

void onbufferingstart();

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

onbufferingstart: function() {
  console.log("Buffering start.");
}

onbufferingprogress

Callback method for asynchronous buffering progress notifications.

void onbufferingprogress(unsigned long percent);

Parameters :

  • percent : unsigned long

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

onbufferingprogress: function(percent) {
  console.log("Buffering progress data : " + percent);
}

onbufferingcomplete

Callback method for asynchronous buffering complete notifications.

void onbufferingcomplete();

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

onbufferingcomplete: function() {
  console.log("Buffering complete.");
}

oncurrentplaytime

Callback method for the current playback time.

void oncurrentplaytime(unsigned long currentTime);

Parameters :

  • currentTime : unsigned long

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

oncurrentplaytime: function(currentTime) {
  console.log("Current playtime: " + currentTime);
}

onstreamcompleted

Callback method for asynchronous playback finished notifications.

void onstreamcompleted();

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

onstreamcompleted: function() {
  console.log("Stream Completed");
}

onevent

Callback method for asynchronous event notifications.

void onevent(AVPlayEvent eventid, DOMString data);

Parameters :

  • eventid : AVPlayEvent object
  • data : DOMString

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

onevent: function(eventType, eventData) {
  console.log("OnEvent Callback with eventType: " + eventType);
}

onerror

Callback method for AVPlay error notifications.

void onerror(AVPlayError eventid);

Parameters :

  • eventid : AVPlayError object

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

onerror: function(eventType) {
  console.log("OnError Event Callback with eventType: " + eventType);
}

onerrormsg

Callback method for AVPlay detailed error message notifications.

void onerrormsg(AVPlayError eventid, DOMString errorMsg);

Parameters :

  • eventid : is of type AVPlayError enum, which is defined above.
  • errorMsg : DOMString JSON string containing all media-related info with respect to the error scenario.

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Since : 6.0

Code Example :

onerrormsg: function(eventType, errorMsg) {
  console.log("OnErrorMsg Event Callback with eventType: " + eventType + "Error Message: " + errorMsg);
}
//errorMsg example:  "{"error_code": "PLAYER_ERROR_CONNECTION_FAILED","url": "http://www.xxxxx.m3u8","DownloadSpeed": "10MB/s",
  //  "http_request_header": "xxxxxxxx","http_response_header": "xxxxxxxx", "connect_error": {"curl": -23}}"

//errorMsg example:  " {"error_code": "PLAYER_ERROR_NOT_SUPPORTED_FORMAT","codec": "h264","demux": "mp4demux",
  // "resolution": "19201080","fps": "30", "detail_info": "decoder error"}"

ondrmevent

Callback method for DRM information notifications.

void ondrmevent(AVPlayDrmType type, drmData data);

Parameters :

  • type : AVPlayDrmType object
  • data : drmData

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

ondrmevent: function(drmType, drmData) {
  console.log("DRM callback, type: " + drmType + ", data: " + drmData);
  if(drmData.name === 'Challenge') {
    var ChallengeData = {
      "NAME": drmData.name,
      "SESSION_ID": drmData.session_id,
      "CHALLENGE": drmData.challenge,
      "CHALLENGE_LEN": drmData.challenge_len,
      "SERV_URL": drmData.serverurl,
      "SERV_URL_LEN": drmData.serverurl_len
    }
    // Use challenge data to get drm license.
  } else if (drmData.name === 'DrmError') {
    var ErrorInfo = {
      "NAME": drmData.name,
      "ERROR_CODE": drmData.code,
      "ERROR_MESSAGE": drmData.message // Generally, it's human readable message.
    }
  }
}

onsubtitlechange

Callback method for asynchronous subtitle change notifications.

void onsubtitlechange(DOMString duration, DOMString subtitles, DOMString type, AVPlaySubtitleAttribute[] attributes);

Parameters :

  • duration : How long the subtitle data should show(unsigned long value in milliseonds)
  • subtitles : DOMString. The actual subtitle data. It can be of type text of type image.
  • type : DOMString of unsigned int value. A value of '0' means subtitle data is of type text and '1' means subtitle data is of type Image
  • attributes : array of AVPlaySubtitleAttribute "attr_type": "AttributeType:value"; "start_pos": start position as long; "stop_pos": stop position as long

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if this feature is not supported.
    • with error type UnknownError, for any other error.

Code Example :

onsubtitlechange: function(duration, text, data3, data4) {
  console.log("Subtitle Changed.");
}

2.4 AVPlaySoundAnalysisCallback

This callback interface specifies subscriptions for any notification for sound Analysis.

[Callback=FunctionOnly, NoInterfaceObject] interface AVPlaySoundAnalysisCallback {
  void ongetexception(WebAPIError err);
  void onsetexception(WebAPIError err);
  void ongetbandsarray(long[] band);
};

Deprecated : 2.4

Methods

ongetexception

Required for error handling.

void ongetexception(WebAPIError err);

Parameters :

  • err : WebAPIError

Deprecated : 2.4

onsetexception

set for the error handling.

void onsetexception(WebAPIError err);

Parameters :

  • err : WebAPIError

Deprecated : 2.4

ongetbandsarray

Provide the Band Array[32] having sound effect information.

void ongetbandsarray(long[] band);

Parameters :

  • band : long Band Array[32] having sound effect information

Deprecated : 2.4

3. Full WebIDL

module AVPlay {
  enum AVPlayPlayerState {
    "NONE",
    "IDLE",
    "READY",
    "PLAYING",
    "PAUSED"
  };

  enum ScanType {
    "INTERLACED",
    "PROGRESSIVE"
  };

  enum AVPlayDisplayMode {
    "PLAYER_DISPLAY_MODE_LETTER_BOX",
    "PLAYER_DISPLAY_MODE_FULL_SCREEN",
    "PLAYER_DISPLAY_MODE_AUTO_ASPECT_RATIO"
  };

  enum AVPlayBufferOption {
    "PLAYER_BUFFER_FOR_PLAY",
    "PLAYER_BUFFER_FOR_RESUME"
  };

  enum AVPlayBufferSizeUnit {
    "PLAYER_BUFFER_SIZE_IN_SECOND"
  };

  enum AVPlayStreamingPropertyType {
    "COOKIE",
    "USER_AGENT",
    "PREBUFFER_MODE",
    "ADAPTIVE_INFO",
    "SET_MODE_4K",
    "LISTEN_SPARSE_TRACK",
    "IS_LIVE",
    "AVAILABLE_BITRATE",
    "GET_LIVE_DURATION",
    "CURRENT_BANDWIDTH",
    "USE_VIDEOMIXER",
    "SET_MIXEDFRAME",
    "PORTRAIT_MODE",
    "IN_APP_MULTIVIEW"
  };

  enum AVPlayDrmType {
    "PLAYREADY",
    "VERIMATRIX",
    "WIDEVINE_CDM"
  };

  enum AVPlayDrmOperation {
    "SetProperties",
    "InstallLicense",
    "ProcessInitiator",
    "widevine_license_data"
  };

  enum AVPlayStreamType {
    "VIDEO",
    "AUDIO",
    "TEXT"
  };

  enum AVPlayError {
    "PLAYER_ERROR_NONE",
    "PLAYER_ERROR_INVALID_PARAMETER",
    "PLAYER_ERROR_NO_SUCH_FILE",
    "PLAYER_ERROR_INVALID_OPERATION",
    "PLAYER_ERROR_SEEK_FAILED",
    "PLAYER_ERROR_INVALID_STATE",
    "PLAYER_ERROR_NOT_SUPPORTED_FILE",
    "PLAYER_ERROR_NOT_SUPPORTED_FORMAT",
    "PLAYER_ERROR_INVALID_URI",
    "PLAYER_ERROR_CONNECTION_FAILED",
    "PLAYER_ERROR_GENEREIC"
  };

  enum AVPlayEvent {
    "PLAYER_MSG_NONE",
    "PLAYER_MSG_RESOLUTION_CHANGED",
    "PLAYER_MSG_BITRATE_CHANGE",
    "PLAYER_SPARSE_TRACK_DETECT",
    "PLAYER_STREAMING_EVENT",
    "PLAYER_MSG_HTTP_ERROR_CODE",
    "PLAYER_MSG_DRM_CHALLENGE_DATA",
    "PLAYER_MSG_CUE_TAG_INFO"
  };

  dictionary AVPlayStreamInfo {
    unsigned long index;
    AVPlayStreamType type;
    DOMString extra_info;
  };

  dictionary AVPlaySubtitleAttribute {
    DOMString attr_type;
    long start_pos;
    long stop_pos;
  };

  dictionary AVPlayVideoSeamlessInfo {
    ScanType scan_type;
    double rotation_degree;
  };

  [NoInterfaceObject] interface AVPlayManagerObject {
    readonly attribute AVPlayManager avplay;
  };

  WebApi implements AVPlayManagerObject;

  [NoInterfaceObject] interface AVPlayManager {
    void open(DOMString url);
    void close();
    void prepare();
    void prepareAsync(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
    void setDisplayRect(unsigned long x, unsigned long y, unsigned long width, unsigned long height);
    AVPlayVideoSeamlessInfo getVideoSeamlessInfo();
    void play();
    void seekTo(long milliseconds, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
    void stop();
    AVPlayPlayerState getState();
    void pause();
    void jumpForward(long milliseconds, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
    void jumpBackward(long milliseconds, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
    unsigned long getDuration();
    unsigned long getCurrentTime();
    void setTimeoutForBuffering(unsigned long seconds);
    void setBufferingParam(AVPlayBufferOption option, AVPlayBufferSizeUnit unit, unsigned long amount);
    void setSpeed(long playbackSpeed);
    void setListener(AVPlayPlaybackCallback playbackCallback);
    DOMString setDrm(AVPlayDrmType drmType, AVPlayDrmOperation drmOperation, DOMString jsonParam);
    DOMString getUID(AVPlayDrmType drmType);
    void setSoundAnalysisListener(AVPlaySoundAnalysisCallback soundAnalysisCallback);
    void unsetSoundAnalysisListener();
    void setSilentSubtitle(boolean onoff);
    void setExternalSubtitlePath(DOMString filePath);
    void setSubtitlePosition(long position);
    void setDisplayMethod(AVPlayDisplayMode displayMode);
    void setSelectTrack(AVPlayStreamType trackType, long trackIndex);
    AVPlayStreamInfo[] getCurrentStreamInfo();
    AVPlayStreamInfo[] getTotalTrackInfo();
    void setStreamingProperty(AVPlayStreamingPropertyType propertyType, DOMString propertyParam);
    DOMString getStreamingProperty(AVPlayStreamingPropertyType propertyType);
    DOMString getVersion();
    void suspend();
    void setLooping(boolean isLooping);
    void setVideoStillMode(DOMString mode);
    void setDisplayRotation(DOMString displayRotation);
    void restore(optional DOMString? URL, optional unsigned long? resumeTime, optional boolean? bPrepare);
    void restoreAsync(optional DOMString? URL, optional unsigned long? resumeTime, optional boolean? bPrepare, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
    void enableAudioStream();
    void disableAudioStream();
    void setVideoRoi(double x_ratio, double y_ratio, double w_ratio, double h_ratio);
  };

  [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayPlaybackCallback {
    void onbufferingstart();
    void onbufferingprogress(unsigned long percent);
    void onbufferingcomplete();
    void oncurrentplaytime(unsigned long currentTime);
    void onstreamcompleted();
    void onevent(AVPlayEvent eventid, DOMString data);
    void onerror(AVPlayError eventid);
    void onerrormsg(AVPlayError eventid, DOMString errorMsg);
    void ondrmevent(AVPlayDrmType type, drmData data);
    void onsubtitlechange(DOMString duration, DOMString subtitles, DOMString type, AVPlaySubtitleAttribute[] attributes);
  };

  [Callback=FunctionOnly, NoInterfaceObject] interface AVPlaySoundAnalysisCallback {
    void ongetexception(WebAPIError err);
    void onsetexception(WebAPIError err);
    void ongetbandsarray(long[] band);
  };

};