| 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 // The PlayerUtils provides utility functions to binding common media events | 5 // The PlayerUtils provides utility functions to binding common media events |
| 6 // to specific player functions. It also provides functions to load media source | 6 // to specific player functions. It also provides functions to load media source |
| 7 // base on test configurations. | 7 // base on test configurations. |
| 8 var PlayerUtils = new function() { | 8 var PlayerUtils = new function() { |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 Utils.failTest(error, KEY_ERROR); | 78 Utils.failTest(error, KEY_ERROR); |
| 79 }); | 79 }); |
| 80 } | 80 } |
| 81 } catch (e) { | 81 } catch (e) { |
| 82 Utils.failTest(e); | 82 Utils.failTest(e); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 // TODO(sandersd): Stop registering 'needkey' after it is renamed to | 86 // TODO(sandersd): Stop registering 'needkey' after it is renamed to |
| 87 // 'encrypted'. | 87 // 'encrypted'. |
| 88 if (player.video.onencrypted) { | 88 player.video.addEventListener('encrypted', encrypted_handler); |
| 89 player.video.addEventListener('encrypted', encrypted_handler); | 89 player.video.addEventListener('needkey', encrypted_handler); |
| 90 } else { | |
| 91 player.video.addEventListener('needkey', encrypted_handler); | |
| 92 } | |
| 93 | 90 |
| 94 this.registerDefaultEventListeners(player); | 91 this.registerDefaultEventListeners(player); |
| 95 try { | 92 try { |
| 96 Utils.timeLog('Setting video media keys: ' + player.testConfig.keySystem); | 93 Utils.timeLog('Setting video media keys: ' + player.testConfig.keySystem); |
| 97 MediaKeys.create(player.testConfig.keySystem).then(function(mediaKeys) { | 94 MediaKeys.create(player.testConfig.keySystem).then(function(mediaKeys) { |
| 98 player.video.setMediaKeys(mediaKeys); | 95 player.video.setMediaKeys(mediaKeys); |
| 99 }).catch(function(error) { | 96 }).catch(function(error) { |
| 100 Utils.failTest(error, NOTSUPPORTEDERROR); | 97 Utils.failTest(error, NOTSUPPORTEDERROR); |
| 101 }); | 98 }); |
| 102 } catch (e) { | 99 } catch (e) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 default: | 190 default: |
| 194 Utils.timeLog(keySystem + ' is not a known key system'); | 191 Utils.timeLog(keySystem + ' is not a known key system'); |
| 195 if (usePrefixedEME) | 192 if (usePrefixedEME) |
| 196 return PrefixedClearKeyPlayer; | 193 return PrefixedClearKeyPlayer; |
| 197 return ClearKeyPlayer; | 194 return ClearKeyPlayer; |
| 198 } | 195 } |
| 199 } | 196 } |
| 200 var Player = getPlayerType(testConfig.keySystem); | 197 var Player = getPlayerType(testConfig.keySystem); |
| 201 return new Player(video, testConfig); | 198 return new Player(video, testConfig); |
| 202 }; | 199 }; |
| OLD | NEW |