Please note that all the code changes that need to be made are shown below and indicated by the tags MediaMelon Start and MediaMelon End. Snippets of surrounding code is also provided to act as placeholders and to help you find the right place to insert MediaMelon’s integration code.
Fig 1 describes how the Toast plugin integrates and interacts with the underlying SmartTV platforms (Samsung or LG). Toast is an abstraction layer that makes it simple to write applications for Samsung and LG SmartTVs using a common set of APIs.
The top-most layer in Fig 1 shows the application layer where you can write your apps using Toast’s APIs. In this layer, MediaMelon Player SDK is integrated making it a single integration step irrespective of the underlying SmartTV platform.
In the middle layer, there are platform-specific Toast files which the top-level APIs interact with. Here, certain MediaMelon-specific changes are needed to propagate events and metrics that are not passed-through by Toast.
The final level is the platform level (specific to each SmartTV platform) and this is un-touched by Media Melon’s SmartSight Player SDK integration.
Step-by-Step integration guide.
Github links for working with Cordova Toast Plugin :
2. The following changes/additions are to be made in order to integrate with MediaMelon SmartSight Player SDK:
At the application level:
1) www/index.html
2) js/media.js
At the Toast level
1) toast.js [sectv-tizen platform only]
Application-level changes
→ www/index.html:
Include <mmsmartstreaming-toast-sdk.js> in the index.html. We use a wrapper to load the SDK - so that, if there is an error in loading the SDK, the application will not be affected and playback will continue.
You can also provide the assetID, assetName, videoID, and custom tags as shown below while setting source information. Please use the mmVideoAssetInfo structure to provide this information.
And then initialize as shown below:
.....addControlBar();// MediaMelon Startvar mmVideoAssetInfo = {"assetName":"ASSETNAME_STRING","assetId":"ASSETID_STRING","videoId":"VIDEOID_STRING","contentType":"Genre of the content (episode, movies, etc)","drmProtection":"DRM type used (Widevine, Playready, etc)","episodeNumber":"Episode Number, e.g., 2 or E2","season":"Season number of the Series Title, e.g, 2 or S2","seriesTitle":"Series Title","customTags":{"key1":"VALUE_STRING1","key2":"VALUE_STRING2","key3":"VALUE_STRING3" } }toastMMPlugin.initialize(mediaSourceURL, mmVideoAssetInfo);// MediaMelon Endmedia.setListener({onevent:function(evt) {// MediaMelon StarttoastMMPlugin.onToastEvent(evt);// MediaMelon Endswitch(evt.type) {case'STATE':.....
Add the call for reporting error to the Toast Plugin and just before media.play(), call the reportUserInitiatedPlayback()api.
..... }, onerror:function (err) {console.error('MediaError is occured: '+JSON.stringify(err));document.getElementById('log').innerHTML ='MediaError is occured';// MediaMelon StarttoastMMPlugin.onToastError(err);// MediaMelon End } });// MediaMelon StarttoastMMPlugin.reportUserInitiatedPlayback();// MediaMelon Endmedia.play();//You don't have to call setScreenSaver Method. It is configurated by toast.avplay.}.....
Toast-level changes
→ toast.js:
Please make the following changes toast.js for supporting bitrate change notifications. (Applicable for sectv-tizen platform only.)