| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // TestApp is responsible for starting playback on the page. It selects the | 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. | 6 // suitable player to use based on key system and other test variables. |
| 7 var TestApp = new function() { | 7 var TestApp = new function() { |
| 8 this.video_ = null; | 8 this.video_ = null; |
| 9 } | 9 } |
| 10 | 10 |
| 11 TestApp.loadPlayer = function() { | 11 TestApp.play = function() { |
| 12 if (this.video_) { | 12 if (this.video_) { |
| 13 Utils.timeLog('Delete old video tag.'); | 13 Utils.timeLog('Delete old video tag.'); |
| 14 this.video_.pause(); | 14 this.video_.src = ''; |
| 15 this.video_.remove(); | 15 this.video_.remove(); |
| 16 delete(this.video_); | |
| 17 } | 16 } |
| 18 | 17 |
| 19 this.video_ = document.createElement('video'); | 18 this.video_ = document.createElement('video'); |
| 20 this.video_.controls = true; | 19 this.video_.controls = true; |
| 21 this.video_.preload = true; | 20 this.video_.preload = true; |
| 22 this.video_.width = 848; | 21 this.video_.width = 848; |
| 23 this.video_.height = 480; | 22 this.video_.height = 480; |
| 24 | 23 |
| 25 // Check if the key system is supported. | 24 // Check if the key system is supported. |
| 26 var videoPlayer = this.getPlayer(); | 25 var videoPlayer = this.getPlayer(); |
| 27 if (!videoPlayer) { | 26 if (!videoPlayer) { |
| 28 Utils.timeLog('Cannot create a media player.'); | 27 Utils.timeLog('Cannot create a media player.'); |
| 29 return; | 28 return; |
| 30 } | 29 } |
| 31 Utils.timeLog('Using ' + videoPlayer.constructor.name); | 30 Utils.timeLog('Using ' + videoPlayer.constructor.name); |
| 32 var videoSpan = document.getElementById(VIDEO_ELEMENT_ID); | 31 var videoSpan = document.getElementById(VIDEO_ELEMENT_ID); |
| 33 if (videoSpan) | 32 videoSpan.appendChild(this.video_); |
| 34 videoSpan.appendChild(this.video_); | |
| 35 else | |
| 36 document.body.appendChild(this.video_); | |
| 37 videoPlayer.init(this.video_); | 33 videoPlayer.init(this.video_); |
| 38 | 34 |
| 39 if (TestConfig.runFPS) | 35 FPSObserver.observe(this.video_); |
| 40 FPSObserver.observe(this.video_); | |
| 41 | |
| 42 this.video_.play(); | 36 this.video_.play(); |
| 43 return this.video_; | |
| 44 }; | 37 }; |
| 45 | 38 |
| 46 TestApp.getPlayer = function() { | 39 TestApp.getPlayer = function() { |
| 47 // Update keySystem if using prefixed Clear Key since it is not available as a | 40 var keySystem = TestConfig.keySystem; |
| 48 // separate key system to choose from; however it can be set in URL query. | |
| 49 var usePrefixedEME = TestConfig.usePrefixedEME; | 41 var usePrefixedEME = TestConfig.usePrefixedEME; |
| 50 if (TestConfig.keySystem == CLEARKEY && usePrefixedEME) | 42 |
| 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) |
| 51 TestConfig.keySystem = PREFIXED_CLEARKEY; | 46 TestConfig.keySystem = PREFIXED_CLEARKEY; |
| 52 var keySystem = TestConfig.keySystem; | |
| 53 | 47 |
| 54 switch (keySystem) { | 48 switch (keySystem) { |
| 55 case WIDEVINE_KEYSYSTEM: | 49 case WIDEVINE_KEYSYSTEM: |
| 56 if (usePrefixedEME) | 50 if (usePrefixedEME) |
| 57 return new PrefixedWidevinePlayer(); | 51 return new PrefixedWidevinePlayer(); |
| 58 return new WidevinePlayer(); | 52 return new WidevinePlayer(); |
| 59 case PREFIXED_CLEARKEY: | |
| 60 return new PrefixedClearKeyPlayer(); | |
| 61 case EXTERNAL_CLEARKEY: | 53 case EXTERNAL_CLEARKEY: |
| 62 case CLEARKEY: | 54 case CLEARKEY: |
| 63 if (usePrefixedEME) | 55 if (usePrefixedEME) |
| 64 return new PrefixedClearKeyPlayer(); | 56 return new PrefixedClearKeyPlayer(); |
| 65 return new ClearKeyPlayer(); | 57 return new ClearKeyPlayer(); |
| 66 case FILE_IO_TEST_KEYSYSTEM: | |
| 67 if (usePrefixedEME) | |
| 68 return new FileIOTestPlayer(); | |
| 69 default: | 58 default: |
| 70 Utils.timeLog(keySystem + ' is not a known key system'); | 59 Utils.timeLog(keySystem + ' is not a supported system yet.'); |
| 71 if (usePrefixedEME) | 60 return null; |
| 72 return new PrefixedClearKeyPlayer(); | |
| 73 return new ClearKeyPlayer(); | |
| 74 } | 61 } |
| 75 }; | 62 }; |
| OLD | NEW |