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 readonly avplaymanager avplay avplay api namespace 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 avplayvideoseamlessinfo avplayvideoseamlessinfo current version 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 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 ; }; };