4
<title>Unity Webapps QML test: MediaPlayer</title>
8
var MEDIAPLAYER_STATE_PLAYING = 0;
9
var MEDIAPLAYER_STATE_PAUSED = 1;
13
unity.MediaPlayer.setCanGoNext(true);
14
unity.MediaPlayer.setCanGoPrevious(true);
15
unity.MediaPlayer.setCanPlay(true);
16
unity.MediaPlayer.setPlaybackState(MEDIAPLAYER_STATE_PAUSED);
18
unity.MediaPlayer.setTrack({ album: "MyAlbum", title: "MyTitle", artist: "MyArtist" });
20
document.getElementById('status').innerHTML = 'mediaplayer-updated';
23
document.addEventListener('ubuntu-webapps-api-ready', function () {
24
console.log('ubuntu-webapps-api-ready received');
26
unity = window.external.getUnityObject('1.0');
28
unity.init({name: 'unity-webapps-qml-', domain: 'launcher', onInit: onInit, iconUrl: 'icon://myicon'});
31
function dispatchApiCall (target, name, args) {
32
var names = name.split('.');
34
function (prev, cur) {
35
return (typeof prev[cur] == "function") ? (function(prev, cur) { return prev[cur].bind(prev); })(prev, cur) : prev[cur];
36
}, target).apply (null, args);
39
document.addEventListener('unity-webapps-do-call', function(e) {
40
var action = JSON.parse(e.detail);
42
if (action.with_callback) {
43
callback = function (response) {
44
var e = new CustomEvent ("unity-webapps-do-call-response", {"detail": response});
45
document.dispatchEvent (e);
47
action.args.push(callback);
49
dispatchApiCall(unity, action.name, action.args);
61
<h1>THE CONTENT IS VISIBLE</h1>
64
<!-- Used as a communication status (to avoid races) between the app & the test -->
65
<div id="status"></div>