Multi-DRM integration sample for Samsung Tizen TV application
This document explains how to play PallyCon Multi-DRM
content on Samsung Smart TV(Tizen)
.
There are two ways to play PallyCon Multi-DRM content on Tizen OS, and we provide samples for you to test.
- Playback using AVPlay API : PallyConTizen-AVPlay Sample
- Playback using HTML5 Player (Shaka) : PallyConTizen-HTMLShaka Sample
- Tizen 4.0 and later
- The sample in this document was tested on LS32BM702UKXKR(Tizen 6.5).
- The emulator does not support DRM, so you must have a physical TV device.
- Download Tizen Studio and install it following the installation guide.
- Run Packager Manager, which was installed together with Tizen Studio installation, and install the items below.
- Tizen SDK tools
- TV Extensions-X.X
- TV Extension Tools
- Install Samsung Certificate Extension and create Certification Profile
- For more information about your TV's Tizen version, supported media, etc., please refer to the General Specifications on our homepage.
The Tizen SDK provides a PlayerAVPlayDRM sample that uses webapis.avplay. The
PlayerAVPlayDRM
sample implements the functions required for DRM playback, including the webapis.avplay.setDrm() function. For thePlayerAVPlayDRM
sample, all source files are in the same path. In order to run thePlayerAVPlayDRM
sample as a Tizen Studio project, you must edit theindex.html
file and change the paths to the.js file
and.css file
.
PallyConTizen-AVPlay
Sample was implemented by referring to Playback Using AVPlay inWeb Application
onSmart TV
on Samsung developer site.
PallyConTizen-AVPlay
is a sample modified to reflect the above content so that it can be used in Tizen Studio.
-
You can test it by changing the value of the
drms
variable in themain.js
file included inPallyConTizen-AVPlay
toPallyCon Multi-DRM
information as follows.// main.js ... var drms = { PLAYREADY: { name: 'PlayReady', url: 'https://playready-dash-content-url/stream.mpd', licenseServer: 'https://license-global.pallycon.com/ri/licenseManager.do', customData: 'PallyCon Multi-DRM License Request Token' }, WIDEVINE: { name: 'Widevine', url: 'https://widevine-dash-content-url/stream.mpd', licenseServer: 'https://license-global.pallycon.com/ri/licenseManager.do', customData: 'PallyCon Multi-DRM License Request Token' } }; ...
-
Set PallyCon Multi-DRM information through the
setPlayready
andsetWidevine
functions in thevideoPlayer.js
file.-
// videoPlayer.js setPlayready: function () { var drmParam = { DeleteLicenseAfterUse: true }; if (chosenDrm.licenseServer !== '' && chosenDrm.licenseServer !== undefined) { drmParam.LicenseServer = chosenDrm.licenseServer; } if (chosenDrm.customData !== '' && chosenDrm.customData !== undefined) { drmParam.CustomData = chosenDrm.customData; } try { webapis.avplay.setDrm("PLAYREADY", "SetProperties", JSON.stringify(drmParam)); } catch (e) { log(e.name); } }
-
// videoPlayer.js setWidevine: function () { var PrepareSuccessCallback = function () { webapis.avplay.play(); }; var drmParam = {}; drmParam.AppSession = "app session ID"; drmParam.DataType = "MPEG-DASH"; try { webapis.avplay.setDrm("WIDEVINE_CDM", "SetProperties", JSON.stringify(drmParam)); webapis.avplay.prepareAsync(PrepareSuccessCallback); } catch (e) { log(e.name); } } // webapis.avplay.setListener(AVPlayPlaybackCallback); AVPlayPlaybackCallback.ondrmevent: function (drmEvent, drmData) { ... if (drmData.name == "Challenge" && drmEvent == "WIDEVINE_CDM") { var message = atob(drmData.challenge); // The challenge data is base64 encoded type. var buf = new Uint8Array(message.length); for (var i = 0; i < message.length; ++i) buf[i] = message.charCodeAt(i); var xmlhttp = new XMLHttpRequest(); xmlhttp.responseType = "arraybuffer"; xmlhttp.open("POST", chosenDrm.licenseServer); xmlhttp.setRequestHeader("pallycon-customdata-v2", chosenDrm.customData); xmlhttp.onload = function (e) { if (this.status == 200) { if (this.response) { const base64Response = btoa(new Uint8Array(this.response) .reduce(function (data, byte) { return data + String.fromCharCode(byte) }, '')); var licenseParam = drmData.session_id + "PARAM_START_POSITION" + base64Response + "PARAM_START_POSITION"; webapis.avplay.setDrm("WIDEVINE_CDM", "widevine_license_data", licenseParam); } } }; xmlhttp.send(buf); } else if (drmData.name == "DrmError") { // error handling log('DRM Error: ' + drmData.name + '::::') } },
-
-
If you play 4K video, you must set
SET_MODE_4K
.// videoPlayer.js set4K: function () { webapis.avplay.setStreamingProperty("SET_MODE_4K", "true"); },
-
PallyConTizen-AVPlay
follows LICENSE.txt of PlayerAVPlayDRM sample. -
When running PallyConTizen-AVPlay in Tizen Studio, the directory name and project name must be
PallyConTizen-AVPlay
.- If you use a different name, the project will not open properly.
- Since the distributed compressed file name is
PallyConTizen-AVPlay
, in a normal environment, just uncompress the file without changing the file name.
-
If you inevitably use a different name, you must modify the
PallyConTizen-AVPlay
value in the.project
andconfig.xml
files in PallyConTizen-AVPlay.
Shaka Player is an Google open-source JavaScript library for adaptive media. It plays adaptive media formats (such as DASH, HLS and MSS) in a browser, without using plugins or Flash. Instead, Shaka Player uses the open web standards MediaSource Extensions and Encrypted Media Extensions.
-
You can test it by changing the value of the
playerConfig
variable in themain.js
file included inPallyConTizen-HTMLShaka
toPallyCon Multi-DRM
information as follows.// main.js var playerConfig = [ ... { // PallyCon Multi-DRM Widevine or PlayReady Content manifest: 'https://widevine-dash-content-url/stream.mpd', description: 'PallyCon Contents', drmServers: { 'com.widevine.alpha': 'https://license-global.pallycon.com/ri/licenseManager.do' // or 'com.microsoft.playready': 'https://license-global.pallycon.com/ri/licenseManager.do' } } ];
-
Set the licence acquisition token in the
initPlayer()
function of themain.js
file.// main.js function initPlayer() { player = new window.shaka.Player(videoEl); ... // set PallyCon Multi-DRM Token player.getNetworkingEngine().registerRequestFilter(function (type, request) { // Only add headers to license requests: if (type == shaka.net.NetworkingEngine.RequestType.LICENSE) { console.log("request :" + request.body); // PallyCon License Request Token request.headers['pallycon-customdata-v2'] = 'PallyCon Multi-DRM License Request Token'; } }); }
-
PallyConTizen-HTMLShaka
follows LICENSE.txt of SampleWebApps-PlayerHTMLShaka. -
To use
Shaka Player
on Tizen, you need to specify in your content security policy in yourconfig.xml
file.// config.xml <tizen:content-security-policy>script-src 'self' 'unsafe-inline' ./assets/shaka-player.compiled.js blob: data:</tizen:content-security-policy>
-
For more information on Security and Privilege in Tizen, see the Tizen Developer page.