1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // EMEApp is responsible for starting playback on the eme_player.html page.
6 // It selects the suitable player based on key system and other test options.
7 function EMEApp(testConfig
) {
9 this.testConfig_
= testConfig
;
10 this.updateDocument(testConfig
);
13 EMEApp
.prototype.createPlayer = function() {
14 // Load document test configuration.
15 this.updateTestConfig();
17 Utils
.timeLog('Delete old video tag.');
23 this.video_
= document
.createElement('video');
24 this.video_
.controls
= true;
25 this.video_
.preload
= true;
26 this.video_
.width
= 848;
27 this.video_
.height
= 480;
28 var videoSpan
= document
.getElementById(VIDEO_ELEMENT_ID
);
30 videoSpan
.appendChild(this.video_
);
32 document
.body
.appendChild(this.video_
);
34 var videoPlayer
= PlayerUtils
.createPlayer(this.video_
, this.testConfig_
);
36 Utils
.timeLog('Cannot create a media player.');
39 Utils
.timeLog('Using ' + videoPlayer
.constructor.name
);
40 if (this.testConfig_
.runFPS
)
41 FPSObserver
.observe(this.video_
);
47 EMEApp
.prototype.updateDocument = function(testConfig
) {
48 // Update document lists with test configuration values.
49 Utils
.addOptions(KEYSYSTEM_ELEMENT_ID
, KEY_SYSTEMS
);
50 Utils
.addOptions(MEDIA_TYPE_ELEMENT_ID
, MEDIA_TYPES
);
51 Utils
.addOptions(USE_PREFIXED_EME_ID
, EME_VERSIONS_OPTIONS
,
52 EME_DISABLED_OPTIONS
);
53 document
.getElementById(MEDIA_FILE_ELEMENT_ID
).value
=
54 testConfig
.mediaFile
|| DEFAULT_MEDIA_FILE
;
55 document
.getElementById(LICENSE_SERVER_ELEMENT_ID
).value
=
56 testConfig
.licenseServerURL
|| DEFAULT_LICENSE_SERVER
;
57 if (testConfig
.keySystem
)
58 Utils
.ensureOptionInList(KEYSYSTEM_ELEMENT_ID
, testConfig
.keySystem
);
59 if (testConfig
.mediaType
)
60 Utils
.ensureOptionInList(MEDIA_TYPE_ELEMENT_ID
, testConfig
.mediaType
);
61 document
.getElementById(USE_MSE_ELEMENT_ID
).value
= testConfig
.useMSE
;
62 if (testConfig
.usePrefixedEME
)
63 document
.getElementById(USE_PREFIXED_EME_ID
).value
= EME_PREFIXED_VERSION
;
66 EMEApp
.prototype.updateTestConfig = function() {
67 // Reload test configuration from document.
68 this.testConfig_
.mediaFile
=
69 document
.getElementById(MEDIA_FILE_ELEMENT_ID
).value
;
70 this.testConfig_
.keySystem
=
71 document
.getElementById(KEYSYSTEM_ELEMENT_ID
).value
;
72 this.testConfig_
.mediaType
=
73 document
.getElementById(MEDIA_TYPE_ELEMENT_ID
).value
;
74 this.testConfig_
.useMSE
=
75 document
.getElementById(USE_MSE_ELEMENT_ID
).value
== 'true';
76 this.testConfig_
.usePrefixedEME
= (
77 document
.getElementById(USE_PREFIXED_EME_ID
).value
==
78 EME_PREFIXED_VERSION
);
79 this.testConfig_
.licenseServerURL
=
80 document
.getElementById(LICENSE_SERVER_ELEMENT_ID
).value
;