Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Filter
Develop Samsung IAP
websamsung in-app purchase seamless integration with galaxy store for your in-app purchase products what is samsung in-app purchase? samsung in-app purchase (iap) is a payment service that makes it possible to sell a variety of products in applications for samsung galaxy store and internally manages communication with supporting iap services in the samsung ecosystem, such as samsung account, samsung checkout, and samsung rewards. learn more four basic steps to selling in-app products start selling in-app products by integrating with samsung iap. 1. develop your app using our sdk download the samsung in-app purchase sdk and integrate it into your app. 2. request commercial seller status you must be a commercial seller in order to sell your in-app products. 3. register your app upload your binary file to samsung galaxy store seller portal. 4. add in-app products to your app add in-app products and register product-related information. technical documents programming guide how to integrate and configure iap, the iap sdk and iap server apis, and what to do before submitting your app to galaxy store. subscription guide how to manage subscriptions and an explanation of the pricing options configured in samsung galaxy store seller portal. test guide how to test in-app product purchase and payment. iap api guides how to view, register, modify, and remove samsung iap products and view all payments and refunds on a specific date. sdk and plugins sdk samsung iap libraries and sample app. unity plugin samsung iap-related scripts and libraries used to integrate with the unity engine. unreal plugin samsung iap-related scripts and libraries used to integrate with the unreal engine. videos samsung developers youtube nov 6, 2019 maximize your revenue with samsung in-app purchase learn about the new features and improvements released in samsung iap 6.0. review the steps to register your app in seller portal, test samsung iap integration, and how to publish your app in galaxy store. nov 6, 2019 nov 11, 2018 monetize your games with samsung in-app purchase introduction to samsung iap plug-in functionality for unity and unreal game engines. learn how to integrate, register and publish your game with samsung iap. nov 11, 2018 have questions? samsung answers your frequently asked questions and provides a forum to communicate with other developers. faq forum
Develop Mobile Samsung Automation
docsamsung automation studio get started - samsung automation studio beta the automation studio allows you to integrate samsung bixby, smartthings and 3rd party your apis connect it with samsung bixby and smartthings! you can start a free trial the 6th promotion will end when the free trial code we have prepared are exhausted samsung account a samsung account is your gateway to the world of samsung when you sign up for a samsung account, you gain access to apps and services of samsung smartthings support samsung automation studio supports smartthings integration via smartthings node customization bixby voice support bixby voice can execute your flow that designed with "capsule label" node and "capsule result" node securely stored manage and store your flows simply export and import all files are encrypted and securely stored, protect in what matters pre-defined flows start with pre-defined flow templates for a mashing-up various cases get inspiration and create your new flow runtime environment deploy your flows in secured and isolated containers whose healths and lifecycles are managed automatically by the reliable container platform cf bixby capsule support you can create a flow using the capsule label node and capsule result node you can run this flow using the capsule for automation studio we have already developed the capsule for automation studio it is listed on bixby marketplace remote-endpoint makes your business logic more flexible on bixby voice "capsule label" node allows you to call the remote-endpoint without developing a capsule use a remote-endpoint to your capsules? get a paradigm shift when using bixby and its platform for an advanced state of conversational ai and voice jump on the bixby train and be ready for the 500 million, bixby-enabled, samsung devices that ships yearly as these are enabled with remote-endpoints making it more to flexibly code on bixby capsules capsule node decide which name is called through bixby voice without developing a capsule learn more > smartthings support webhook endpoints in this context is a web services application it serves as an api endpoint on the internet, that receives incoming http post requests webhook endpoints must be an https url rapidly build a smartapp by connecting devices and smartthings services easily what is the automation? automation allows the user to control their smartthings ecosystem without any manual intervention an example of an automation is a webhook that uses the smartthings rest api to control and get status notifications from smartthings devices automation node connect easily with the smartthings smartapp using a web hook endpoint deviceprofile node know what capability you need? find the 71 capabilities of smartthings learn more > get started you can start a free trial the 6th promotion will end when the free trial code we have prepared are exhausted *[sign up][1] for a samsung account, if you do not already have one the minimum requirements are samsung account signed up to smartthings or bixby developers get the subscription code development service level get free trial > use our node on your server! you can find our node named "samsung-automation-studio" in node-red community and can install it in node-red you can keep your flows through the import/export npm install node-red-contrib-samsung-automation-studio-nodes self-managed servers limited features learn more > get started - samsung automation studio beta
Develop Smart TV
api'tizen tv service adinfo adinfo' class reference tifa is a samsung smart tv identifier made and used for the purpose of providing advertising on samsung smart tvs you may collect and use the tifa and the personal information based on the tifa collectively 'tifa information' through your application for the following purposes collecting or using the tifa information for any other purpose is prohibited in-app advertisements installation of other applications through your in-app advertisement launching another application including apps already installed on the samsung smart tv , web browser or video player through your in-app advertisement collecting the app usage data related to the in-app advertisement e g in-app subscription, in-app contents purchasement, or etc for the purpose of analyzing in-app advertisement attribution in the event a user resets the tifa, you agree not to map or associate any previous tifa with the newly generated tifa 'mapping' means tracking and identifying any previous tifa with the newly generated tifa you agree not to connect the tifa to personally-identifiable information or associated with any persistent device identifier e g duid, mac address, etc you agree to use encrypted protocol e g https when the tifa is sent outside the device you agree to comply with all applicable privacy and data protection laws and regulations including getting prior consent from the user regarding your collection and use of the tifa information you may be unable to register your application on the samsung smart tv, or your registration may be cancelled if you are found to be in violation of the above said obligations i agree and commit to comply with all policies and restrictions regarding tifa and tv ad platform listed in this page also i agree to t&cs of d-forum linked in the bottom of the website public static functions string gettifa tifa is a randomized, non-persistent, and resettable samsung smart tv device identifier the personal information collected for the purpose of providing advertisement is linked to tifa collectively "tifa information" tifa shall be collected and used only for the following purposes any other purpose is prohibited more bool islatenabled checks whether the device has limited ad tracking this api is also available in net version 4 4 3 and later more string getuuid get universally unique identifier uuid different uuid values are generated for each app uuid shall not be used for advertising purpose if your app collects and uses both uuid and tifa, they shall be transferred by separate streaming when each of such identifiers is sent outside of the device also, uuid and tifa shall be separated in the entire data processing procedure, including storage, utilization, processing and deletion within the server the collection and use of the uuid shall be in compliance with all applicable privacy and data protection laws and regulations including getting prior consent from the user this api is also available in net version 4 4 3 and later more public static functions string gettifa tifa is a randomized, non-persistent, and resettable samsung smart tv device identifier the personal information collected for the purpose of providing advertisement is linked to tifa collectively "tifa information" tifa shall be collected and used only for the following purposes any other purpose is prohibited in-app advertisements installation of other applications through your in-app advertisement running another application including apps already installed on the samsung smart tv , web browser or video player through your in-app advertisement collecting the app usage data related to the in-app advertisement e g in-app subscription, in-app contents purchasement, or etc for the purpose of analyzing in-app advertisement attribution tifa will be newly generated whenever user resets the tifa, and you shall agree not to map any previous tifa with the newly generated tifa "mapping" means tracking and identifying any previous tifa with the newly generated tifa the encrypted protocol e g https shall be used when the tifa is sent outside of the device tifa shall not be connected to personally-identifiable information or associated with any persistent device identifier e g duid, mac address, etc the collection and use of the tifa information shall be in compliance with all applicable privacy and data protection laws and regulations including getting prior consent from the user this api is also available in net version 4 4 3 and later returns string id for advertising exceptions exception thrown when check privilege failed invalidoperationexception thrown when psid has wrong value privilege http //developer samsung com/privilege/adinfo privilege level public legal review result legal review completed details have been added to the description product tv version 5 5 0 sdk support y bool islatenabled checks whether the device has limited ad tracking this api is also available in net version 4 4 3 and later returns boolean value to indicate whether limited ad tracking is set true limit ad tracking false not limit ad tracking exceptions exception thrown when check privilege failed privilege http //developer samsung com/privilege/adinfo privilege level public legal review result legal review completed details have been added to the description product tv version 5 5 0 sdk support y string getuuid get universally unique identifier uuid different uuid values are generated for each app uuid shall not be used for advertising purpose if your app collects and uses both uuid and tifa, they shall be transferred by separate streaming when each of such identifiers is sent outside of the device also, uuid and tifa shall be separated in the entire data processing procedure, including storage, utilization, processing and deletion within the server the collection and use of the uuid shall be in compliance with all applicable privacy and data protection laws and regulations including getting prior consent from the user this api is also available in net version 4 4 3 and later returns randomized 36 characters uuid privilege none privilege level non-privilege legal review result legal review completed details have been added to the description product tv version 5 5 0 sdk support y
Develop Samsung IAP
docsamsung iap publish api the samsung iap publish api is used to view, register, modify, and remove samsung in-app purchase iap items before you can start using the iap publish api, you must meet all requirements and use the required authorization header parameters in your requests see get started with the iap apis for more information noteusing the iap publish api to register, modify, or delete an item immediately changes it within the content, even when the content is in the for sale state the publish api can only be used for item product types it cannot be used for subscription product types see the iap programming guide for more information about item and subscription product types the following is a quick reference to the iap publish apis name request description view item list get /iap/v6/applications/ packagename/items request a list of item information within a scope appropriate for the page and size view individual item get /iap/v6/applications/ packagename/items/ id request detailed information on one item create item post /iap/v6/applications/ packagename/items register an in-app item modify item put /iap/v6/applications/ packagename/items modify an in-app item partial item modification patch /iap/v6/applications/ packagename/items modify the specified parameters of an in-app item remove item delete /iap/v6/applications/ packagename/items/ id remove an in-app item see in-app purchase for more information about iap functionality in seller portal view item list request a list of item information within a scope appropriate for the page and size request get /iap/v6/applications/ packagename/items?page={}&size={} name type in description page int query required number of pages of content to return size int query required number of items to be returned on a page curl \ -x get \ -h "content-type application/json" \ -h "authorization bearer <your-access-token>" \ -h "service-account-id <your-service-account-id>" \ "https //devapi samsungapps com/iap/v6/applications/com package name/items?page=1&size=20" response parameters name type description id string unique identifier of the in-app item registered in seller portal title string title of the in-app item registered in seller portal description string brief explanation of the in-app item registered in seller portal type string in-app item type item goods and services that charge users on a one-time basis non_consumable an item that is purchased only once and remains effective or available in the app at all times, even after deletion and re‑installation of the app for example, game boards or an upgrade starting from june 2025, the non_consumable type has been deprecated, and the ability to register new non-consumable items through the publish api will no longer be possible please refer to the programming guide for more information status string item distribution status in seller portal published item is for sale in galaxy store unpublished item is not available in galaxy store removed item has been removed from galaxy store itempaymentmethod phonebillstatus boolean whether or not the item is paid with an automatic payment on a phone bill true the item is paid by an automatic payment on a phone bill false the item is not paid by an automatic payment on a phone bill usdprice number the base price in usd united states of america dollars of the item the price can be set between 0 and 999 99 prices[] countryid string three-character country code iso 3166 of the country where the item is sold prices[] currency string three-character currency code iso 4217 of the specified country's currency for example, eur, gbp, usd prices[] localprice string price of the item in the specified country's currency totalcount number number of items listed in the response success status 200 success { "itemlist" [ { "id" "one_gallon_gas", "title" "1 gallon gas", "description" "fuel for driving game", "type" "item", "status" "published", "itempaymentmethod" { "phonebillstatus" true }, "usdprice" 0 900, "prices" [ { "countryid" "kor", "currency" "krw", "localprice" "1000 000" }, { "countryid" "usa", "currency" "usd", "localprice" "0 900" }, ] }, ], "totalcount" 3 } see failure response codes for a list of possible response codes when a request fails view individual item request detailed information about one item request get /iap/v6/applications/ packagename/items/ id name type description id string required unique identifier of the in-app item registered in seller portal curl \ -x get -h "content-type application/json" \ -h "authorization bearer <your-access-token>" \ -h "service-account-id <your-service-account-id>" \ "https //devapi samsungapps com/iap/v6/applications/com package name/items/one_gallon_gas" response see view item response parameters for a description of the response parameters success status 200 success { "id" "one_gallon_gas", "title" "1 gallon gas", "description" "fuel for driving game", "type" "item", "status" "published", "itempaymentmethod" { "phonebillstatus" true }, "usdprice" 0 900, "prices" [ { "countryid" "kor", "currency" "krw", "localprice" "1000 000" }, { "countryid" "usa", "currency" "usd", "localprice" "0 900" }, ] } see failure response codes for a list of possible response codes when a request fails create item register an in-app item request post /iap/v6/applications/com package name/items name type description id string required unique identifier of the in-app item registered in seller portal title string required title of the in-app item registered in seller portal description string required brief explanation of the in-app item registered in seller portal type string optional in-app product type item goods and services that charge users on a one-time basis status string required item distribution status in seller portal published item is for sale in galaxy store unpublished item is not available in galaxy store removed item has been removed from galaxy store itempaymentmethod phonebillstatus boolean required whether or not the item is paid with an automatic payment on a phone bill true the item is paid by an automatic payment on a phone bill false the item is not paid by an automatic payment on a phone bill usdprice number required the base price in usd united states of america dollars of the item the price can be set between 0 and 999 99 prices[] countryid string required three-character country code iso 3166 of the country where the item is sold prices[] currency string three-character currency code iso 4217 of the specified country's currency for example, eur, gbp, usd prices[] localprice string required price of the item in the specified country's currency curl \ -x post \ -h "content-type application/json" \ -h "authorization bearer <your-access-token>" \ -h "service-account-id <your-service-account-id>" \ -d '{"id" "one_gallon_gas","title" "1 gallon gas","description" "fuel for driving game","type" "item","status" "published","itempaymentmethod" {"phonebillstatus" true},"usdprice" 0 99,"prices" [{"countryid" "kor","currency" "krw","localprice" "1000"},{"countryid" "usa","currency" "usd","localprice" "0 99"}]}' \ "https //devapi samsungapps com/iap/v6/applications/com package name/items" response success status 200 success { "id" "one_gallon_gas", "type" "item", "status" "published", "prices" [ { "countryid" "kor", "currency" "krw", "localprice" "1000 000" }, { "countryid" "usa", "currency" "usd", "localprice" "0 99" }, ] } see failure response codes for a list of possible response codes when a request fails modify item modify an in-app item the request replaces all existing information, except the content id, of the item tipto modify an app, use the response from view individual item to create the input required for this request request put /iap/v6/applications/ packagename/items see create item request for a description of the request parameters curl \ -x put \ -h "content-type application/json" \ -h "authorization bearer <your-access-token>" \ -h "service-account-id <your-service-account-id>" \ -d '{"id" "one_gallon_gas","title" "1 gallon gas","description" "fuel for driving game fix","type" "item","status" "published","itempaymentmethod" {"phonebillstatus" true},"usdprice" 1,"prices" [{"countryid" "kor","currency" "krw","localprice" "1000"},{"countryid" "usa","currency" "usd","localprice" "1"}]}' \ "https //devapi samsungapps com/iap/v6/applications/com package name/items" response success status 200 success { "id" "one_gallon_gas", "type" "item", "status" "published", "prices" [ { "countryid" "kor", "currency" "krw", "localprice" "1000 000" }, { "countryid" "usa", "currency" "usd", "localprice" "1" }, ] } see failure response codes for a list of possible response codes when a request fails partial item modification modify the title, countryid, or localprice of an in-app item the id cannot be modified parameters that are not specified are not modified request patch /iap/v6/applications/ packagename/items name type description id string required unique identifier of the in-app item registered in seller portal title string title of the in-app item registered in seller portal prices[] countryid string three-character country code iso 3166 of the country where the item is sold prices[] localprice string price of the item in the specified country's currency curl \ -x patch \ -h "content-type application/json" \ -h "authorization bearer <your-access-token>" \ -h "service-account-id <your-service-account-id>" \ -d '{"id" "one_gallon_gas","title" "2 gallon gas"}' \ "https //devapi samsungapps com/iap/v6/applications/com package name/items" response success status 200 success { "id" "one_gallon_gas", "type" "item", "status" "published" } see failure response codes for a list of possible response codes when a request fails remove item remove an in-app item request delete /iap/v6/applications/ packagename/items/ id name type in description id string path required unique identifier of the in-app item registered in seller portal curl \ -x delete -h "content-type application/json" \ -h "authorization bearer <your-access-token>" \ -h "service-account-id <your-service-account-id>" \ "https //devapi samsungapps com/iap/v6/applications/com package name/items/one_gallon_gas" response success status 200 ok { "id" "one_gallon_gas" } see failure response codes for a list of possible response codes when a request fails failure response codes the following are response codes you may see when the request fails status code and message 400bad request 109 subscription is not yet supported117 price is under minimum value for example, the local price of 0 69 is lower than the minimum price of 0 99 118 price is lower than minimum unit for example, the local price of 1 099 does not match the minimal price unit of 0 01119 price exceeds maximum value120 non-consumable type is no longer supported400 bad request with wrong in-app product information 401unauthorized 101 user doesn't have permission to change this app103 failed to verify gateway server authorization 404not found 104 content doesn't exist please create content first 106 itemgroup doesn't exist in production level need to publish iap-supported app 110 product does not exist 409conflict 105 the product already exists with the requested id107 there are multiple itemgroupids or itemids with the requested packagename
Develop Smart Signage
apiavplay 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 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 ; }; };
Develop Smart TV
apiavplay 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 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 ; }; };
Develop Smart Hospitality Display
apiavplay 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 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 ; }; };
Develop Smart TV
docsamsung checkout this topic describes how you can develop a billing system for your application, to allow users to make purchases within your application related info billing api productinfo api sso api samsung checkout dpi portal guide samsung checkout for tizen net samsung checkout dpi portal samsung checkout on tv samples samsung checkout web application samsung checkout net application samsung checkout offers an optimized purchase experience for your users on samsung tvs the user can quickly and safely register a payment method and make frictionless payments repeatedly within the tv environment in addition, samsung checkout provides a comprehensive global monetization platform, which allows you to integrate various business models and promotional campaigns into your services the tv-optimized purchase experience provides the user a quick and simple 3-step checkout, once a payment method is registered the checkout requires only number-centric information to be entered, making it easy to use with a tv remote control users can register their payment method directly on the tv or through a mobile phone to use samsung checkout, the user needs tv samsung smart tv, 2016 or later model supporting tizen excluding evolution kit payment method credit or debit card, paypal, or samsung pay in korea, united states security tizen secureime, 2nd-screen card registration mobile or pc account samsung account for sharing account and payment information with galaxy phones importanta samsung account is mandatory for using samsung checkout samsung checkout assumes that the user is logged in to samsung account at all times samsung checkout provides one solution for payment execution ✔ one solution supports all functions from payment operation ✔ operate automatically settlement and payout strong security payment solution ✔ acquire pci-dss certification and follow regulation each of countries psd2 ✔ following psd2 regulantion and gdpr deliver the coupon/promotional code in various ways of distribution with easiest ux ✔ issue coupons for promotion provide dpi digital product inventory system ✔ create and manage service items ✔ check the status of sales amounts and transaction scale ✔ refund and cancel subscription you can manage your product application and product sales through the dpi digital product inventory and process the actual purchase through samsung checkout importantall application data that is saved locally on a tv is deleted when the application is deleted from that tv if the user's purchase history is saved only in the tv storage and not remotely, and the user deletes and reinstalls the application, all application settings and content are removed, including purchased content if your application saves purchase information in the tv storage only, inform the user that uninstalling the application deletes their purchased content the dpi portal provides functions, such as "purchase history unapply" and "refund", to help you address situations when your customer inadvertently deletes application data before proceeding with the unapply and refund processes, you must contact a samsung representative by going to "samsung apps tv seller office > support" and creating a "1 1 q&a" support ticket samsung checkout purchase process when a user wants to purchase a product on your application, samsung checkout provides a common purchase gui, which identifies the user and confirms first the purchase and then the purchase completion after the user completes the purchase, samsung checkout returns the purchase result to your application product, purchase, and payment management the following figure illustrates how you can use samsung checkout and the information in the dpi server to manage in-app purchases and payments in your application request the purchase list retrieve the customer purchase list using a purchase list api request respond to the purchase list content if there are products in the purchase list which are not applied, verify the purchase and apply the products if there are products in the purchase list which have been refunded, retrieve the products send the application result to the server request the product list request the product information list using a products list api request the user purchases the product when the user selects “buy” in the application, provide a common purchase gui through samsung checkout the user can enter a voucher or coupon code to modify the purchase price the user confirms the purchase by entering a pin on the common purchase gui, or biometric information on samsung pay samsung checkout delivers the purchase result to your application request the purchase list update the customer purchase list verify the purchase verify the purchase using a verify purchase api request apply the product apply the product using an apply product api request, and send the application result to the server payment flow with dynamic product in case that partner already has cms server which manage products and price, and it is required to change the product information frequently, partner and samsung can discuss to use dynamic product when they integrate samsung checkout and once they agree on that products and prices will be managed by cms of partner not by samsung’s dpi, partner need to register a representative item on dpi so that samsung checkout system can display information on samsung smart tv app/game store which is legally required partner does not need to register each products on dpi that they sells in their app, however, they should builds and operates its own cms to manage products information including prices and provide rest api for verification of purchase requests the following figure shows data flow of initialize stage in payment process with dynamic product additional requirement for dpi as model require partner cms to manage product information, there is additional requirement that partner need to do for dpi settings verification/no verification ‘verification’ is a recommended option otherwise partner has to handle the verification process by themselves and take all the responsibility for all the error cases related to verification process if ‘verification’ is selected, ‘verify uri’ is also required this uri should serve the function of checking product information such as product itself, price and currency in sequence of initialization during payment process price setting price range information of products that you actually sells in your app is required by country it is not used for actual payment for providing the app information on samsung smart tv app/game store which is legally required thus, it has to be updated when the price range of your products is changed difference when dynamic product when buyitem unlike ordinary purchase, when dynamic product, partner need to set values as below in order to complete payment process "orderitemid" - representative productid that registered to dpi portal as dynamic product type "ordertitle" - customized name for each purchase displayed as in figure 9 "ordertotal" - customized price for each purchase displayed as in figure 9 "dynmcproductid" - unique product id managed by partner cms when verify product partner need to strictly verify the below values in order to identify if it's appropriate product information "appid" - if it's appropriate application for this payment process "productid" - if this is same as representative productid from dpi portal "productprice" - if price of product that partner intended to sell to user "dynmcproductid" - if this is is appropriate id that are under control of partner cms checkout service county/location list no area country eng biz model 1 north america canada agent 2 north america united states commissionaire 3 europe aland islands commissionaire 4 europe albania agent 5 europe austria commissionaire 6 europe belgium commissionaire 7 europe bosnia and herzegovina agent 8 europe bulgaria commissionaire 9 europe croatia commissionaire 10 europe cyprus commissionaire 11 europe czech republic commissionaire 12 europe denmark commissionaire 13 europe estonia commissionaire 14 europe faroe islands commissionaire 15 europe finland commissionaire 16 europe france commissionaire 17 europe germany commissionaire 18 europe greece commissionaire 19 europe greenland commissionaire 20 europe guernsey commissionaire 21 europe hungary commissionaire 22 europe iceland agent 23 europe ireland commissionaire 24 europe isle of man commissionaire 25 europe italy commissionaire 26 europe jersey commissionaire 27 europe latvia commissionaire 28 europe lithuania commissionaire 29 europe luxembourg commissionaire 30 europe montenegro agent 31 europe netherlands commissionaire 32 europe north macedonia agent 33 europe norway commissionaire 34 europe poland commissionaire 35 europe portugal commissionaire 36 europe romania commissionaire 37 europe serbia agent 38 europe slovakia commissionaire 39 europe slovenia commissionaire 40 europe spain commissionaire 41 europe sweden commissionaire 42 europe switzerland agent 43 europe united kingdom commissionaire 44 asia australia agent 45 asia hong kong agent 46 asia india agent 47 asia indonesia agent 48 asia korea, republic of agent 49 asia malaysia agent 50 asia new zealand agent 51 asia philippines agent 52 asia singapore agent 53 asia taiwan agent 54 asia thailand agent 55 asia vietnam agent 56 cis belarus agent 57 cis kazakhstan agent 58 cis kyrgyzstan agent 59 cis moldova agent 60 cis mongolia agent 61 cis russian federation agent 62 cis tajikistan agent 63 cis turkmenistan agent 64 cis ukraine agent 65 cis uzbekistan agent 66 latam argentina agent 67 latam bolivia agent 68 latam brazil agent 69 latam chile agent 70 latam colombia agent 71 latam costa rica agent 72 latam dominican republic agent 73 latam ecuador agent 74 latam guatemala agent 75 latam mexico agent 76 latam panama agent 77 latam peru agent 78 latam venezuela agent 79 mena algeria agent 80 mena bahrain agent 81 mena egypt agent 82 mena ghana agent 83 mena iraq agent 84 mena israel agent 85 mena jordan agent 86 mena kenya agent 87 mena kuwait agent 88 mena lebanon agent 89 mena libya agent 90 mena mauritius agent 91 mena morocco agent 92 mena nigeria agent 93 mena oman agent 94 mena pakistan agent 95 mena qatar agent 96 mena saudi arabia agent 97 mena south africa agent 98 mena tunisia agent 99 mena turkey agent 100 mena united arab emirates agent 101 mena yemen agent 102 latam paraguay agent 103 latam uruguay agent 104 latam el salvador agent 105 latam honduras agent 106 latam nicaragua agent 107 latam bahamas agent 108 latam jamaica agent 109 latam trinidad & tobago agent 110 asia cambodia agent 111 asia myanmar agent 112 asia laos agent 113 asia macao agent 114 asia bangladesh agent 115 asia nepal agent 116 asia sri lanka agent 117 cis armenia agent 118 cis azerbaijan agent 119 cis georgia agent 120 europe liechtenstein agent
Develop Smart Hospitality Display
apiavplayextension api to use samsung product api, <script type="text/javascript" src="$webapis/avplayextension/avplayextension js"></script> should be loaded in index html the module defines the functionalities of the player that are exposed and which could be easily used by an application or widget developer to support multimedia rtp/udp playback for audio or video that are provided by the tizen samsung product api since 6 5 product b2b htv remark webapp should include avplayextension js file in index html 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 ;void play ;void stop ;avplayplayerstate getstate ;unsigned long getcurrenttime ;void setlistener avplayplaybackcallback playbackcallback ;domstring setdrm avplaydrmtype drmtype, avplaydrmoperation drmoperation, domstring jsonparam ;void setdisplaymethod avplaydisplaymode displaymode ;void setselecttrack avplaystreamtype tracktype, long trackindex ;avplaystreaminfo getcurrentstreaminfo ;avplaystreaminfo[] gettotaltrackinfo ;void setstreamingproperty avplaystreamingpropertytype propertytype, any propparam ;domstring getversion ;void setdisplayrotation domstring displayrotation ; avplayplaybackcallback void onevent avplayevent eventid, domstring data ;void onerror avplayerror eventid ;void ondrmevent avplaydrmtype type, drmdata data ; 1 type definitions 1 1 avplayplayerstate this enumeration defines the player states enum avplayplayerstate { "none", "idle", "ready", "playing", "paused" }; the following values are supported none indicates that the player is not created idle indicates that the player is created but not prepared ready indicates that the player is ready to play a media playing indicates that the player is playing a media paused indicates that the player is paused 1 2 avplaydisplaymode this enumeration defines the possible values for webapis avplay setdisplaymethod 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 letter box mode player_display_mode_full_screen full screen mode player_display_mode_auto_aspect_ratio use the dar/par from the video info to show video 1 3 avplaystreamingpropertytype this enumeration specifies the values for a specific feature in udp/rtp enum avplaystreamingpropertytype { "enable_ttx", "set_interactive_mode" }; the following values are supported enable_ttx sets the player to handle ttx dataservice in streams it has one string parameter, which is either "true" or "false" for setstreamingproperty set_interactive_mode enables the interactive mode which sets the latency to the player it has two parameters, one is the "mode" and the other is the "latency" for setstreamingproperty the mode value can be 0 off and 1 on , the latency must be given in milliseconds 1 4 avplaydrmtype this enumeration specifies the different drm types defined by the player enum avplaydrmtype { "proidiom", "lynk" }; the following values are supported proidiom indicates drm type is pro idiom lynk indicates drm type is lynkdrm scas 1 5 avplaydrmoperation this enumeration defines the different drm operations by the player enum avplaydrmoperation { "initialize", "finalize" }; the following values are supported initialize initializes the drm instance for further processing finalize finalizes the drm instance which was created earlier this must be done at the end before closing the player instance 1 6 avplaystreamtype this enumeration defines the stream types defined by the player enum avplaystreamtype { "video", "audio", "text" }; the following values are supported video indicates the video track audio indicates the audio track text indicates the subtitle track 1 7 avplayerror this enumeration defines the player error message types defined by the player enum avplayerror { "player_error_none", "player_error_invalid_parameter", "player_error_invalid_operation", "player_error_invalid_state", "player_error_not_supported_file", "player_error_invalid_uri", "player_error_connection_failed", "player_error_genereic" }; the following values are supported player_error_none indicates that the operation is successfully completed player_error_invalid_parameter if the player finds any parameter which a caller is trying to configure on it to be incorrect, this error is generated player_error_invalid_operation indicates an invalid api call at the moment player_error_invalid_state indicates the error that is generated when any api is called in a state where it is not suggested to be called refer to apis description for valid states player_error_not_supported_file indicates the error that is generated, when required multimedia components are not available to play the given content player_error_invalid_uri indicates an error that is generated when an input uri is in the invalid format player_error_connection_failed indicates the error that is generated, when no data is coming from the network player_error_genereic if the player fails to create a display window, this error is generated 1 8 avplayevent this enumeration defines the events that come from the player enum avplayevent { "player_msg_none", "player_streaming_event" }; the following values are supported player_msg_none notifies that a multimedia component message is not recognized by the player player_streaming_event any type of streaming data that the caller needs would be posted through this event 1 9 avplaystreaminfo the avplaystreaminfo dictionary specifies the streaming media-related information for the video, audio, and the subtitles during various streaming scenarios dictionary avplaystreaminfo { unsigned long index; avplaystreamtype type; domstring extra_info; }; the following values are supported index index value of the stream type type of the stream, either video, audio, or text extra_info domstring json string containing all the media-related information all stream types have an extra_info string //video extra_info example "{fourcc "h264","width" "1920","height" "1080","bit_rate" " 477000"}" //audio extra_info example "{"language" "fr","channels" "2","sample_rate" "48000","bit_rate" "256000","fourcc" "mpeg","track_lang" "fra","audio_type" "0"}" //text subtitle extra_info example "{"track_lang" "eng","subtitle_type" "0","pid" "258","subtitle_mode" "0"}" if the stream type is invalid, the domstring becomes null and the index value becomes -1 1 10 drmdata the drmdata dictionary specifies information about the data received from the player via the drm event dictionary drmdata { domstring name; long code; domstring message; long reserved; }; the following values are supported name name for the message received from the player code signifies the drm error code message drm error message generally, it is a human readable message reserved reserved for future use 2 interfaces 2 1 avplaymanagerobject the interface defines what is instantiated by the webapi object of the tizen-based samsung tv product api there will be a webapis object that allows access to the functionality of the avplay api [nointerfaceobject] interface avplaymanagerobject { readonly attribute avplaymanager avplay; }; webapi implements avplaymanagerobject; attributes readonly avplaymanager avplay namespace for the avplay api 2 2 avplaymanager this interface provides methods to use 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 ; void play ; void stop ; avplayplayerstate getstate ; unsigned long getcurrenttime ; void setlistener avplayplaybackcallback playbackcallback ; domstring setdrm avplaydrmtype drmtype, avplaydrmoperation drmoperation, domstring jsonparam ; void setdisplaymethod avplaydisplaymode displaymode ; void setselecttrack avplaystreamtype tracktype, long trackindex ; avplaystreaminfo getcurrentstreaminfo ; avplaystreaminfo gettotaltrackinfo ; void setstreamingproperty avplaystreamingpropertytype propertytype, any propparam ; domstring getversion ; void setdisplayrotation domstring displayrotation ; }; methods open this method instantiates the player object and takes the content url as the input parameter void open domstring url ; product b2b htv constraint can be called in the following states "none", "idle" privilege level partner privilege http //developer samsung com/privilege/streamingtvplayer parameters url the url of content to play it supports udp and rtp multicast urls exceptions webapiexception with error type typemismatcherror, if the input parameter is not compatible with the expected type with error type notsupportederror, if this feature is not supported with error type invalidvalueserror, if any of the input parameters contains an invalid value with error type invalidstateerror, if it is called in an invalid state with error type unknownerror in any other error case code example try { webapis avplay open url ; } catch e { console log e ; } close this method destroys the avplay object void close ; product b2b htv constraint can be called in the following states "none", "idle", "ready", "paused" , "playing" exceptions webapiexception with error type notsupportederror, if this feature is not supported with error type unknownerror in any other error case code example try { webapis avplay close ; } catch e { console log e ; } prepare this method prepares the media player for playback the player must have been created beforehand with a valid uri this prepare method is synchronous hence, the calling context would be blocked until the player is prepared void prepare ; product b2b htv constraint can be called in the following states "idle", "ready" exceptions webapiexception with error type notsupportederror, if this feature is not supported with error type invalidvalueserror, if the given url through open is invalid //for example, webapis avplay open "invalidurl" with error type invalidaccesserror, if the given url through open is valid but have outside multicast range //for example, webapis avplay open "udp //219 10 10 10" with error type invalidstateerror, if it is called in an invalid state with error type unknownerror in any other error case code example try { webapis avplay prepare ; } catch e { console log e ; } prepareasync this method prepares the media player for playback, asynchronously this api prepares the mm core module, asynchronously it means that the internal media elements will change the state, asynchronously we recommend this asynchronous prepareasync call instead of the prepare call which is synchronous api which blocks the entire application during its execution prepareasync returns immediately, rather than blocking until enough data has been buffered since this works in asynchronous model, this does not block the executing thread and the application is responsive during its execution when prepareasync gets successfully completed, it returns with successcallback and player reached in ready state for some reason, e g network error, it returns with errorcallback with error value void prepareasync optional successcallback? successcallback, optional errorcallback? errorcallback ; product b2b htv constraint can be called in the following states "idle", "ready" parameters successcallback [optional][nullable] callback method to be invoked when this api is successful errorcallback [optional][nullable] callback method to invoke when an error occurs this function has one parameter which shows the following errortypes notsupportederror, if this feature is not supported invalidvalueserror, if the given url through open is invalid e g , webapis avplay open "invalidurl" invalidaccesserror, if the given url through open is valid, but does not exist or network issue e g , webapis avplay open "http //abc" invalidstateerror, if it is called in an invalid state unknownerror, for any other error exceptions webapiexception with error type typemismatcherror, if an input parameter is not compatible with the expected type code example webapis avplay prepareasync = function successcallback, errorcallback { if typeof successcallback === 'undefined' { successcallback = null; } if typeof errorcallback === 'undefined' { errorcallback = null; } try { webapis epavplay prepareasync successcallback, errorcallback ; } catch e { logerror e ; throw e ; } }; setdisplayrect this method sets the display area for playing the video content on the tv screen it should be called for showing the video after calling an open method app's default resolution is 1920x1080 it needs 4 parameters left,top,width,height that always use 1920 x 1080 coordinate system regardless of your application resolution void setdisplayrect unsigned long x, unsigned long y, unsigned long width, unsigned long height ; product b2b htv constraint can be called in the following states "idle", "paused", "ready", "playing" parameters x coordinate of the display area in the tv screen coordinates this x value is smaller than the tv screen width y coordinate of the display area in the tv screen coordinates this y value is smaller than the tv screen height width the width of the display area this value is smaller than the width of the tv screen height the height of the display area from the source image this value is smaller than the height of the source image exceptions webapiexception with error type typemismatcherror, if the input parameter is not compatible with the expected type with error type notsupportederror, if this feature is not supported with error type invalidvalueserror, if any of the input parameters contains an invalid value with error type invalidstateerror, if it is called in an invalid state with error type unknownerror in any other error case code example try { webapis avplay setdisplayrect 0, 0, 1920, 1080 ; } catch e { console log e ; } play this method starts the playback of the stream void play ; product b2b htv constraint can be called in the following states "ready", "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 in any other error case code example try { webapis avplay play ; } catch e { console log e ; } stop this method stops the player and hence any video that is currently being played void stop ; product b2b htv constraint can be called in the following states "none", "idle", "ready", "paused", "playing" exceptions webapiexception with error type notsupportederror, if this feature is not supported with error type unknownerror in any other error case code example try { webapis avplay stop ; } catch e { console log e ; } getstate this method returns the current state of the underlying player which is associated with the avplay object avplayplayerstate getstate ; product b2b htv constraint can be called in the following states "none", "idle", "ready", "playing", "paused" return value avplayplayerstate returns the state of the player "none", "idle", "ready", "playing", "paused" exceptions webapiexception with error type notsupportederror, if this feature is not supported with error type unknownerror in any other error case code example var bret = webapis avplay getstate ; getcurrenttime this method returns the current play time in milliseconds unsigned long getcurrenttime ; product b2b htv constraint can be called in the following states "none", "idle", "ready", "playing", "paused" return value unsigned long current playback time in milliseconds exceptions webapiexception with error type notsupportederror, if this feature is not supported with error type unknownerror in any other error case code example var currentplaytime = webapis avplay getcurrenttime ; setlistener this method is used in order to obtain the player information, the drm mode information etc , and the callback function is registered when the relevant event occurs, the relevant callback function gets called asynchronously void setlistener avplayplaybackcallback playbackcallback ; product b2b htv constraint can be called in the following states "none", "idle" recommended , "ready", "paused", "playing" but it is highly recommended to call this api just after player_status_idle for onerror, onevent, ondrmevent, it must be in player_status_idle i e just after player is created , otherwise the necessary information will be missed parameters playbackcallback avplayplaybackcallback exceptions webapiexception with error type typemismatcherror, if the input parameter is not compatible with the expected type with error type notsupportederror, if this feature is not supported with error type invalidvalueserror, if any of the input parameters contains an invalid value with error type unknownerror in any other error case code example var listener = { onevent function eventtype, eventdata { console log "event type error " + eventtype + ", data " + eventdata ; }, onerror function eventtype { console log "event type error " + eventtype ; }, ondrmevent function drmevent, drmdata { console log "drm callback " + drmevent + ", data " + drmdata ; } } webapis avplay setlistener listener ; setdrm this method updates the drm information, such as setproperties, etc it changes the drm mode, and runs the control feature every drm has difference between avplaydrmoperation and jsonparam domstring setdrm avplaydrmtype drmtype, avplaydrmoperation drmoperation, domstring jsonparam ; product b2b htv constraint can be called in the following states "idle" privilege level public privilege http //developer samsung com/privilege/drmplay parameters drmtype is the type of the drm drmoperation avplaydrmoperation this is a string parameter which specifies the drm operation to be performed for the current playback session it can have these values{"initialize", "finalize" } "setproperties" this operation is used when the drm related information is stringified in "json_string" format and passed along with this operation this is mainly used for setting the drm information like license server, etc //example setting license server some of the code examples are given below jsonparam domstring drm parameter represented by json string not object the application can call json stringify to generate json string in java script the above given drm operation examples could be stringified in this json_string param return value domstring "true" in case of success and "false" if fails exceptions webapiexception with error type typemismatcherror, if the input parameter is not compatible with the expected type with error type notsupportederror, if this feature is not supported with error type invalidvalueserror, if any of the input parameters contains an invalid value with error type securityerror, if the application does not have the privilege to call this method with error type invalidstateerror, if it is called in an invalid state, "none" with error type unknownerror in any other error case during failure scenarios this api would post an exception the following could be the possible exception scenarios drm create failed if creation of the underlying drm module failed, an exception would be sent back with "false" return status of this api call invalid drm session if an invalid drm session is detected, an exception would be sent back with "false" return status of this api call drm configuration failure if a drm configuration failure is detected, an exception would be sent back with "false" return status of this api call note if you use this api, a special privilege level is required insert the http //developer samsung com/privilege/drmplay in the config xml file of the web application check below example <tizen privilege name="http //developer samsung com/privilege/drmplay"/> code example // example proidiom setting forensic data var drmparam = new object ; drmparam forensicdata = "xxxxxxx"; playerobj setdrm "proidiom", "initialize", json stringify drmparam ; // example lynkdrm setting type and lynk server var drmparam = new object ; drmparam type ="2"; drmparam lynkserver="xxx xxx xxx xxx xxxxx"; playerobj setdrm "lynk", "initialize", json stringify drmparam ; setdisplaymethod this method sets the video screen mode within the given display area void setdisplaymethod avplaydisplaymode displaymode ; product b2b htv constraint can be called in the following states "idle", "paused", "ready", "playing" limitation this api works when set as setdisplayrect 0,0,1920,1080 parameters displaymode could be one of "player_display_mode_letter_box", "player_display_mode_full_screen", "player_display_mode_auto_aspect_ratio" exceptions webapiexception with error type typemismatcherror, if the input parameter is not compatible with the expected type with error type notsupportederror, if this feature is not supported with error type invalidvalueserror, if any of the input parameters contains an invalid value with error type invalidstateerror, if it is called in an invalid state with error type unknownerror in any other error case code example webapis avplay setdisplaymethod "player_display_mode_full_screen" ; setselecttrack this method is used with multi audio/subtitle, when you want to change the audio and subtitle while playing void setselecttrack avplaystreamtype tracktype, long trackindex ; product b2b htv constraint can be called in the following state "playing" parameters tracktype it may be audio or text value trackindex it sets the index value of the avplaystreaminfo obtained through the webapis avplay gettotaltrackinfo function exceptions webapiexception with error type typemismatcherror, if the input parameter is not compatible with the expected type with error type notsupportederror, if this feature is not supported with error type invalidvalueserror, if any of the input parameters contains an invalid value with error type invalidstateerror, if it is called in an invalid state with error type unknownerror in any other error case code example var totaltrackinfo = webapis avplay gettotaltrackinfo ; for var i=0; i<totaltrackinfo length; i++ { if totaltrackinfo type == 'text' { console log 'find subtitle track ' ; console log 'subtitle track index is ' + totaltrackinfo index ; console log 'subtitle track language is ' + totaltrackinfo extra_info track_lang ; } } //for example, choose the subtitle track index number 2 webapis avplay setselecttrack 'text',2 ; getcurrentstreaminfo this method gets the currently playing streams video, audio, and subtitle information it informs that a stream is playing avplaystreaminfo getcurrentstreaminfo ; product b2b htv constraint can be called in the following states "playing" return value avplaystreaminfo avplaystreaminfo structure containing tracktype, extrainfo and index of current stream exceptions webapiexception with error type notsupportederror, if this feature is not supported with error type invalidstateerror, if it is called in an invalid state with error type unknownerror in any other error case code example var streaminfo = webapis avplay getcurrentstreaminfo ; var text = ''; for var i = 0; i < streaminfo length; i++ { text += 'index ' + streaminfo[i] index + ''; text += 'type ' + streaminfo[i] type + ''; text += 'extra_info ' + streaminfo[i] extra_info + ''; } all of stream type has extra_info which is jsonstring //video extra_info example "{fourcc "h264","width" "1920","height" "1080","bit_rate" " 477000"}" //audio extra_info example "{"language" "fr","channels" "2","sample_rate" "48000","bit_rate" "256000","fourcc" "mpeg","track_lang" "fra","audio_type" "0"}" //text subtitle extra_info example "{"track_lang" "eng","subtitle_type" "0","pid" "258","subtitle_mode" "0"}" in the case of invalid stream, the domstring becomes null and the index value becomes -1 gettotaltrackinfo this method gets the currently playing streams information avplaystreaminfo[] gettotaltrackinfo ; product b2b htv constraint can be called in the following state "playing" return value avplaystreaminfo avplaystreaminfo[] structure containing the tracktype, extrainfo, and the index of current stream it returns information for all the available tracks for the entire stream that is available in the current playback the following structure is used to send the information back to the caller for video tracks "{"fourcc" "%s","width" "%u","height" "%u","bit_rate" "%u"}" for audio track "{"language" "%s","channels" "%d","sample_rate" "%d","bit_rate" "%d","fourcc" "%s","track_lang" "%s","audio_type" "%d"}" for subtitle tracks "{"track_lang" "%s","subtitle_type" "%d","pid" "%d","subtitle_mode" "%s"}" exceptions webapiexception with error type notsupportederror, if this feature is not supported with error type invalidstateerror, if it is called in an invalid state with error type unknownerror in any other error case code example var trackinfo = webapis avplay gettotaltrackinfo ; var text = 'type of track info ' + typeof trackinfo + ''; text += 'length ' + trackinfo length + ''; for var i = 0; i<trackinfo length; i++ { text += 'index ' + trackinfo[i] index + ''; text += 'type ' + trackinfo[i] type + ''; text += 'extra_info ' + trackinfo[i] extra_info + ''; } setstreamingproperty this method sets the value for a specific feature in the udp/rtp playback void setstreamingproperty avplaystreamingpropertytype propertytype, any propparam ; product b2b htv constraint can be called in the following player state "idle" parameters propertytype property type to be set to the player propparam value according to the propertytype e g "enable_ttx" propetytypes are true, false, and for the "set_interactive_mode" mode is 1 with latency in milliseconds exceptions webapiexception with error type typemismatcherror, if the input parameter is not compatible with the expected type with error type notsupportederror, if this feature is not supported with error type invalidvalueserror, if any of the input parameters contains an invalid value with error type invalidstateerror, if it is called in an invalid state with error type unknownerror in any other error case code example //set interactive mode example var propparam = new object ; propparam mode ="1"; propparam latency="100"; //latency in ms webapis avplay setstreamingproperty "set_interactive_mode", propparam ; //enable ttx mode example webapis avplay setstreamingproperty "enable_ttx", true ; getversion this method gets the version of avplay domstring getversion ; product b2b htv constraint can be called in the following states "none", "idle", "ready", "paused", "playing" return value domstring domstring string current version exceptions webapiexception with error type notsupportederror, if this feature is not supported with error type unknownerror in any other error case code example var version = webapis avplay getversion ; setdisplayrotation this method sets the rotation settings of the video surface display if no display is set, no operation is performed use this method to change the video orientation to portrait mode this api call will change the origin of the coordinates hence, the application should call setdisplayrect again after calling this api void setdisplayrotation domstring displayrotation ; product b2b htv constraint can be called in the following states "idle", "ready", "playing", "paused" parameters displayrotation the rotation of the display the valid values for the display rotation are "player_display_rotation_none", "player_display_rotation_90", "player_display_rotation_180", "player_display_rotation_270" exceptions webapiexception with error type typemismatcherror, if an input parameter is not compatible with the expected type with error type notsupportederror, if this feature is not supported with error type invalidvalueserror, if any input parameter contains an invalid value with error type invalidstateerror, if it is called in an invalid state with error type unknownerror, for any other error code example webapis avplay setdisplayrotation "player_display_rotation_90" ; 2 3 avplayplaybackcallback this callback interface defines subscriptions for any notification on the buffering, playback [callback=functiononly, nointerfaceobject] interface avplayplaybackcallback { void onevent avplayevent eventid, domstring data ; void onerror avplayerror eventid ; void ondrmevent avplaydrmtype type, drmdata data ; }; methods onevent this method gets called async when some kind of event other event is received from the player void onevent avplayevent eventid, domstring data ; parameters eventid id of the event triggered by the player data description of the event received from the player exceptions webapiexception with error type notsupportederror, if this feature is not supported with error type unknownerror in any other error case code example onevent function eventid, data { console log "onevent callback with eventtype " + eventid ; } onerror this method gets called when an error event is received from the player void onerror avplayerror eventid ; parameters eventid id of the error event trigerred by the player exceptions webapiexception with error type notsupportederror, if this feature is not supported with error type unknownerror in any other error case code example onerror function eventid { console log "onerror event callback with eventtype " + eventid ; } ondrmevent this method gets called when the drm information is received from the player void ondrmevent avplaydrmtype type, drmdata data ; parameters type drm type data detailed information about the drm event received from the player { readonly attribute name name for the message, means an error occurred during the drm processing readonly attribute code signifies the drm error code readonly attribute message drm error message readonly attribute reserved not currently applicable } exceptions webapiexception with error type notsupportederror, if this feature is not supported with error type unknownerror in any other error case code example ondrmevent function type, data { console log "drm callback " + type + ", data " + data ; var errorinfo = { "name" data name, "error_code" data code, "error_message" data message // generally, the error message is human readable } } 3 full webidl module avplayextension { enum avplayplayerstate { "none", "idle", "ready", "playing", "paused" }; enum avplaydisplaymode { "player_display_mode_letter_box", "player_display_mode_full_screen", "player_display_mode_auto_aspect_ratio" }; enum avplaystreamingpropertytype { "enable_ttx", "set_interactive_mode" }; enum avplaydrmtype { "proidiom", "lynk" }; enum avplaydrmoperation { "initialize", "finalize" }; enum avplaystreamtype { "video", "audio", "text" }; enum avplayerror { "player_error_none", "player_error_invalid_parameter", "player_error_invalid_operation", "player_error_invalid_state", "player_error_not_supported_file", "player_error_invalid_uri", "player_error_connection_failed", "player_error_genereic" }; enum avplayevent { "player_msg_none", "player_streaming_event" }; dictionary avplaystreaminfo { unsigned long index; avplaystreamtype type; domstring extra_info; }; dictionary drmdata { domstring name; long code; domstring message; long reserved; }; [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 ; void play ; void stop ; avplayplayerstate getstate ; unsigned long getcurrenttime ; void setlistener avplayplaybackcallback playbackcallback ; domstring setdrm avplaydrmtype drmtype, avplaydrmoperation drmoperation, domstring jsonparam ; void setdisplaymethod avplaydisplaymode displaymode ; void setselecttrack avplaystreamtype tracktype, long trackindex ; avplaystreaminfo getcurrentstreaminfo ; avplaystreaminfo[] gettotaltrackinfo ; void setstreamingproperty avplaystreamingpropertytype propertytype, any propparam ; domstring getversion ; void setdisplayrotation domstring displayrotation ; }; [callback=functiononly, nointerfaceobject] interface avplayplaybackcallback { void onevent avplayevent eventid, domstring data ; void onerror avplayerror eventid ; void ondrmevent avplaydrmtype type, drmdata data ; }; };
tutorials game, mobile
bloggalaxy store is one of the top app stores to sell your android games in many different countries. you can also sell various in-app purchase (iap) items inside your games using the samsung iap sdk. as many of you now use the unity engine to develop your games, samsung has introduced a unity plugin for the samsung iap sdk that enables you to implement iap features. follow the steps outlined in this blog to easily implement the unity plugin into your project and utilize the samsung iap functionalities. prerequisites it is assumed you are already familiar with the samsung iap procedure. if not, please read the iap sdk programming guide carefully before proceeding further. after that, download the samsung iap unity plugin package and go through its documentation. to avoid compatibility issues, make sure you meet the system requirements. there are three types of iap items: consumable: can be used only one time and re-purchasable non-consumable: can be used any number of times and not re-purchasable subscription: can be used any number of times while it is active for this example, we have developed a basic coin collecting game in unity for android and added ui buttons that allow users to buy iap items (consumable and non-consumable) and a subscription. the “buy super jump” button initiates purchasing a super jump item from galaxy store using the samsung iap sdk. super jump is a consumable item which enables the player to jump higher than normal. similarly, the “upgrade player” button initiates purchasing a player upgrade, which is a non-consumable item. this blog only covers consumable and non-consumable purchases, we’ll discuss subscriptions in a future blog. figure 1: preview of the sample game developed in unity. note: you are required to develop your game/application in unity beforehand to integrate the iap unity plugin into it. integrate the samsung iap unity plugin after creating the game in unity, you need to enable samsung iap functionalities in your project. follow the steps below: import the samsung iap unity plugin package into the project. in unity, click assets -> import package -> custom package and select the downloaded plugin package. you can now see the plugins folder under your assets folder and the “samsungiap.cs” script at assets/plugins/script. copy or move the “samsungiap.cs” script into the default scripts folder of your project (where all the scripts are kept together) so that other scripts can access it easily. if you don’t already have a scripts folder, create a new one and keep all your project scripts together along with “samsungiap.cs.” create an empty game object in the hierarchy tab and drag-and-drop the “samsungiap.cs” script onto it. in our sample project, we have renamed the game object as “samsungiap.” click on the “samsungiap” game object and check if the iap functionality is enabled in the inspector, as shown below: figure 2: samsung iap is enabled for the project. set the iap operation mode iap supports three operational modes. the production mode is for enabling billing for item purchases and the other two are for testing iap functions without billing the game users for item purchases. the default operation mode is set to operation_mode_test with the return value as success, but you can set the return value to failure instead, or switch to operation_mode_production by checking (√) the production build checkbox in the inspector as shown in figure 2. you can learn more about the iap operation modes and how they work from here. register the game and iap items in seller portal to process/test the samsung iap operations, both your game and any iap items need to be registered in seller portal. follow the steps below: ensure you have switched the platform of your game to android and the package name is different from the apps registered in other app stores. you can rename the package name of your project from player settings -> other settings. save your unity project and build the apk file. in unity, go to file -> build settings and then click the build button. follow the steps listed in register an app and in-app items in seller portal and complete the registration of your game and iap items accordingly. for our sample game, we have registered a consumable and a non-consumable item with the ids “buysuperjump” and “buyupgradedplayer” respectively. keep the item ids in mind as they will be required when initiating the purchases. you can add testers (non-licensed and licensed) in the binary tab of seller portal while registering your game in the manner covered in the previous step. licensed testers are not charged for purchasing any iap items. you can register the licensed testers in your seller portal profile. see iap testing for more information. get previously purchased items make sure to retrieve any previously purchased non-consumable and unconsumed items every time the user starts the game. use the getownedlist() method of the iap plugin to get information about the items the user has already purchased. however, please note there is a script called “player.cs” in our project which is added to the main player game object as a component. from now on we will be editing the code in “player.cs” to enable all the samsung iap functions for this project. follow the steps below: add the following line at the beginning to access the samsung iap libraries in this script. using samsung; call the getownedlist() method whenever the game launches by adding the following line at the beginning of the start() method. learn more about the getownedlist() method here. samsungiap.instance.getownedlist(itemtype.all, ongetownedlist); after the processing of the getownedlist() method is completed, the ongetownedlist callback is triggered, which receives information about the specified purchased items and api call processing. we need to implement this callback method under the same class as in the following; void ongetownedlist(ownedproductlist _ownedproductlist){ if(_ownedproductlist.errorinfo != null){ if(_ownedproductlist.errorinfo.errorcode == 0){// 0 means no error if(_ownedproductlist.results != null){ foreach(ownedproductvo item in _ownedproductlist.results){ if(item.mconsumableyn == "y"){ //consume the consumable items and onconsume callback is triggered afterwards samsungiap.instance.consumepurchaseditems(item.mpurchaseid, onconsume); } if(item.mitemid == "buysuperjump"){ superjump++; } else if(item.mitemid == "buyupgradedplayer"){ playermaterial = resources.load<material>("playermaterial"); meshrenderer meshrenderer = getcomponent<meshrenderer>(); meshrenderer.material = playermaterial; } } } } } as you can see, some actions have been taken inside the game depending on the respective item ids. for example, the super jump counter has been increased and the material of the player gets changed. if there is any consumable item which has not been reported as consumed, then the consumepurchaseditems() method is invoked. we describe this method in the next section. consume purchased consumable items use the consumepurchaseditems() method to report the purchased consumable item as consumed, which enables the item to be purchased again. see acknowledge a purchased consumable item to understand this process better. when the process of the consumepurchaseditems() method in the previous section is finished, the item data and processing results are returned to the onconsume callback method. we need to implement this method in the same way under the same class as we implemented the ongetownedlist method earlier. void onconsume(consumedlist _consumedlist){ if(_consumedlist.errorinfo != null){ if(_consumedlist.errorinfo.errorcode == 0){ if(_consumedlist.results != null){ foreach(consumevo item in _consumedlist.results){ if(item.mstatuscode == 0){ //successfully consumed and ready to be purchased again. } } } } } } get purchasable iap items the users may want to see details of the available iap items in the store for the game. the getproductsdetails() method helps to retrieve detailed information (for example, item name, price, or id) about the iap items registered in your game that are available for users to purchase. there is a ui button “available items” in our sample game for querying the purchasable items. after clicking this button, brief information for each item is presented in a simple dropdown list next to the button (see figure 3). to get the list of available items: declare a button variable and a dropdown variable in the beginning of the “player.cs” script. public button getproductsbutton; public dropdown itemlist; add a listener method for the “available items” button at the end of the start() method. getproductsbutton.onclick.addlistener(ongetproductsbutton); to initiate the getproductsdetails() method, we need to implement the listener ongetproductsbutton() method. void ongetproductsbutton(){ //get all the product details samsungiap.instance.getproductsdetails("", ongetproductsdetails); } after the processing is completed on the server side, the ongetproductsdetails callback is triggered, which contains information about the available iap items. implement this callback method and add information of each item to the dropdown method so that the users can see them easily. in the example, we show only the item name and price. void ongetproductsdetails(productinfolist _productlist){ if (_productlist.errorinfo != null){ if (_productlist.errorinfo.errorcode == 0){// 0 means no error if (_productlist.results != null){ itemlist.clearoptions(); list<string> optionitems = new list<string>(); int i = 1; foreach (productvo item in _productlist.results){ string temp = i+ ". " + item.mitemname + ": $ " + item.mitemprice; optionitems.add(temp); i++; } itemlist.addoptions(optionitems); } } } } figure 3: showing the available iap items in the game. the information about all iap items is shown in the dropdown menu as a list. you can show only one specific item or more items by specifying their ids in the getproductsdetails() method if you want. learn more about the method here. purchase iap items there are two ui buttons (see figures 1 and 3) in our sample game, namely “buy super jump” and “upgrade player,” for purchasing consumable and non-consumable items, respectively. the variables for these two buttons are declared in the beginning of the start() method and two listener methods: onbuysuperjumpbutton() and onupgradeplayerbutton() are added at the end of the start() method of “player.cs” script. consequently, tapping on these buttons invokes the corresponding methods in the script. follow the steps below to complete in-app purchasing: to enable the “buy super jump” and the “upgrade player” buttons purchasing a super jump and a player upgrade, we need to instantiate the startpayment() method inside the button listeners with the corresponding item ids.void onbuysuperjumpbutton(){ //purchase a consumable item samsungiap.instance.startpayment("buysuperjump", "", onpayment); } void onupgradeplayerbutton(){ //purchase a non-consumable item samsungiap.instance.startpayment("buyupgradedplayer", "", onpayment); } after the payment processing is completed, the onpayment callback is triggered, which contains information about the purchased item, the transaction, and api call processing. we need to implement this callback method and act according to the item ids as in the following:void onpayment(purchasedinfo _purchaseinfo){ if(_purchaseinfo.errorinfo != null){ if(_purchaseinfo.errorinfo.errorcode == 0){ if(_purchaseinfo.results != null){ //your purchase is successful if(_purchaseinfo.results.mconsumableyn == "y"){ //consume the consumable items samsungiap.instance.consumepurchaseditems(_purchaseinfo.results.mpurchaseid, onconsume); } if(_purchaseinfo.results.mitemid == "buysuperjump"){ superjump++; } else if(_purchaseinfo.results.mitemid == "buyupgradedplayer"){ playermaterial = resources.load<material>("playermaterial"); meshrenderer meshrenderer = getcomponent<meshrenderer>(); meshrenderer.material = playermaterial; } } } } } for the consumepurchaseditems() method, we have already implemented the onconsume listener method. in this way, in-app purchasing is fully implemented for both consumable and non-consumable items. next, build the project, run it on your galaxy device, and check that the iap works flawlessly. in addition, you may update the apk of your game in seller portal and submit a beta version for more iap testing. see the test guide to learn more about testing. do not forget to switch the iap operation mode to operation_mode_production before submitting the game to be published. conclusion this tutorial explains the entire procedure of integrating the samsung iap unity plugin and using the iap functionalities for a sample game. therefore, we hope that you can make use of this tutorial and develop an in-app purchase enabled game for galaxy store using unity and sell your game items successfully to generate revenue. follow up this site has many resources for developers looking to build for and integrate with samsung devices and services. stay in touch with the latest news by creating a free account or by subscribing to our monthly newsletter. visit the marketing resources page for information on promoting and distributing your apps. finally, our developer forum is an excellent way to stay up-to-date on all things related to the galaxy ecosystem.
Md. Abulkalam Azad
We use cookies to improve your experience on our website and to show you relevant advertising. Manage you settings for our cookies below.
These cookies are essential as they enable you to move around the website. This category cannot be disabled.
These cookies collect information about how you use our website. for example which pages you visit most often. All information these cookies collect is used to improve how the website works.
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and tailor the website to provide enhanced features and content for you.
You have successfully updated your cookie preferences.