Chromium Code Reviews| 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.play = function() { | 11 TestApp.loadPlayer = 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_.src = ''; | 14 this.video_.pause(); |
| 15 this.video_.remove(); | 15 this.video_.remove(); |
| 16 delete(this.video_); | |
| 16 } | 17 } |
| 17 | 18 |
| 18 this.video_ = document.createElement('video'); | 19 this.video_ = document.createElement('video'); |
| 19 this.video_.controls = true; | 20 this.video_.controls = true; |
| 20 this.video_.preload = true; | 21 this.video_.preload = true; |
| 21 this.video_.width = 848; | 22 this.video_.width = 848; |
| 22 this.video_.height = 480; | 23 this.video_.height = 480; |
| 23 | 24 |
| 24 // Check if the key system is supported. | 25 // Check if the key system is supported. |
| 25 var videoPlayer = this.getPlayer(); | 26 var videoPlayer = this.getPlayer(); |
| 26 if (!videoPlayer) { | 27 if (!videoPlayer) { |
| 27 Utils.timeLog('Cannot create a media player.'); | 28 Utils.timeLog('Cannot create a media player.'); |
| 28 return; | 29 return; |
| 29 } | 30 } |
| 30 Utils.timeLog('Using ' + videoPlayer.constructor.name); | 31 Utils.timeLog('Using ' + videoPlayer.constructor.name); |
| 31 var videoSpan = document.getElementById(VIDEO_ELEMENT_ID); | 32 var videoSpan = document.getElementById(VIDEO_ELEMENT_ID); |
| 32 videoSpan.appendChild(this.video_); | 33 if (videoSpan) |
| 34 videoSpan.appendChild(this.video_); | |
| 35 else | |
| 36 document.body.appendChild(this.video_); | |
| 33 videoPlayer.init(this.video_); | 37 videoPlayer.init(this.video_); |
| 34 | 38 |
| 35 FPSObserver.observe(this.video_); | 39 if (TestConfig.runFPS) |
| 40 FPSObserver.observe(this.video_); | |
| 41 | |
| 36 this.video_.play(); | 42 this.video_.play(); |
| 43 return this.video_; | |
| 37 }; | 44 }; |
| 38 | 45 |
| 39 TestApp.getPlayer = function() { | 46 TestApp.getPlayer = function() { |
| 47 // Update keySystem if using prefixed Clear Key since it is not available in | |
|
jrummell
2014/05/29 21:45:05
s/available in/available/
shadi
2014/05/31 00:31:37
Done.
| |
| 48 // as a separate key system to choose from; however it can be set in query. | |
| 49 var usePrefixedEME = TestConfig.usePrefixedEME; | |
| 50 if (TestConfig.keySystem == CLEARKEY && usePrefixedEME) | |
| 51 TestConfig.keySystem = PREFIXED_CLEARKEY; | |
| 40 var keySystem = TestConfig.keySystem; | 52 var keySystem = TestConfig.keySystem; |
| 41 var usePrefixedEME = TestConfig.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) | |
| 46 TestConfig.keySystem = PREFIXED_CLEARKEY; | |
| 47 | 53 |
| 48 switch (keySystem) { | 54 switch (keySystem) { |
| 49 case WIDEVINE_KEYSYSTEM: | 55 case WIDEVINE_KEYSYSTEM: |
| 50 if (usePrefixedEME) | 56 if (usePrefixedEME) |
| 51 return new PrefixedWidevinePlayer(); | 57 return new PrefixedWidevinePlayer(); |
| 52 return new WidevinePlayer(); | 58 return new WidevinePlayer(); |
| 59 case PREFIXED_CLEARKEY: | |
| 60 return new PrefixedClearKeyPlayer(); | |
| 53 case EXTERNAL_CLEARKEY: | 61 case EXTERNAL_CLEARKEY: |
| 54 case CLEARKEY: | 62 case CLEARKEY: |
| 55 if (usePrefixedEME) | 63 if (usePrefixedEME) |
| 56 return new PrefixedClearKeyPlayer(); | 64 return new PrefixedClearKeyPlayer(); |
| 57 return new ClearKeyPlayer(); | 65 return new ClearKeyPlayer(); |
| 58 default: | 66 default: |
| 59 Utils.timeLog(keySystem + ' is not a supported system yet.'); | 67 Utils.timeLog(keySystem + ' is not a known key system'); |
| 60 return null; | 68 if (usePrefixedEME) |
| 69 return new PrefixedClearKeyPlayer(); | |
|
jrummell
2014/05/29 21:45:05
Should you be setting TestConfig.keySystem here, o
shadi
2014/05/31 00:31:37
Yes, I added these to support key systems as "org.
| |
| 70 return new ClearKeyPlayer(); | |
| 61 } | 71 } |
| 62 }; | 72 }; |
| OLD | NEW |