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_);
43 return videoPlayer.init().then(function(result) { return videoPlayer; });
46 EMEApp.prototype.updateDocument = function(testConfig) {
47 // Update document lists with test configuration values.
48 Utils.addOptions(KEYSYSTEM_ELEMENT_ID, KEY_SYSTEMS);
49 Utils.addOptions(MEDIA_TYPE_ELEMENT_ID, MEDIA_TYPES);
50 Utils.addOptions(USE_PREFIXED_EME_ID, EME_VERSIONS_OPTIONS,
51 EME_DISABLED_OPTIONS);
52 document.getElementById(MEDIA_FILE_ELEMENT_ID).value =
53 testConfig.mediaFile || DEFAULT_MEDIA_FILE;
54 document.getElementById(LICENSE_SERVER_ELEMENT_ID).value =
55 testConfig.licenseServerURL || DEFAULT_LICENSE_SERVER;
56 if (testConfig.keySystem)
57 Utils.ensureOptionInList(KEYSYSTEM_ELEMENT_ID, testConfig.keySystem);
58 if (testConfig.mediaType)
59 Utils.ensureOptionInList(MEDIA_TYPE_ELEMENT_ID, testConfig.mediaType);
60 document.getElementById(USE_MSE_ELEMENT_ID).value = testConfig.useMSE;
61 if (testConfig.usePrefixedEME)
62 document.getElementById(USE_PREFIXED_EME_ID).value = EME_PREFIXED_VERSION;
65 EMEApp.prototype.updateTestConfig = function() {
66 // Reload test configuration from document.
67 this.testConfig_.mediaFile =
68 document.getElementById(MEDIA_FILE_ELEMENT_ID).value;
69 this.testConfig_.keySystem =
70 document.getElementById(KEYSYSTEM_ELEMENT_ID).value;
71 this.testConfig_.mediaType =
72 document.getElementById(MEDIA_TYPE_ELEMENT_ID).value;
73 this.testConfig_.useMSE =
74 document.getElementById(USE_MSE_ELEMENT_ID).value == 'true';
75 this.testConfig_.usePrefixedEME = (
76 document.getElementById(USE_PREFIXED_EME_ID).value ==
77 EME_PREFIXED_VERSION);
78 this.testConfig_.licenseServerURL =
79 document.getElementById(LICENSE_SERVER_ELEMENT_ID).value;