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 // TestApp is responsible for starting playback on the page. It selects the
6 // suitable player to use based on key system and other test variables.
7 var TestApp = new function() {
11 TestApp.play = function() {
13 Utils.timeLog('Delete old video tag.');
18 this.video_ = document.createElement('video');
19 this.video_.controls = true;
20 this.video_.preload = true;
21 this.video_.width = 848;
22 this.video_.height = 480;
24 // Check if the key system is supported.
25 var videoPlayer = this.getPlayer();
27 Utils.timeLog('Cannot create a media player.');
30 Utils.timeLog('Using ' + videoPlayer.constructor.name);
31 var videoSpan = document.getElementById(VIDEO_ELEMENT_ID);
32 videoSpan.appendChild(this.video_);
33 videoPlayer.init(this.video_);
35 FPSObserver.observe(this.video_);
39 TestApp.getPlayer = function() {
40 var keySystem = TestConfig.keySystem;
41 var usePrefixedEME = TestConfig.usePrefixedEME;
43 // Update keySystem if using prefixed Clear Key since it is not available in
44 // as a separate key system to choose from.
45 if (keySystem == CLEARKEY && usePrefixedEME)
46 TestConfig.keySystem = PREFIXED_CLEARKEY;
49 case WIDEVINE_KEYSYSTEM:
51 return new PrefixedWidevinePlayer();
52 return new WidevinePlayer();
53 case EXTERNAL_CLEARKEY:
56 return new PrefixedClearKeyPlayer();
57 return new ClearKeyPlayer();
59 Utils.timeLog(keySystem + ' is not a supported system yet.');