| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 }); | 50 }); |
| 51 mediaKeySession.addEventListener('error', function(error) { | 51 mediaKeySession.addEventListener('error', function(error) { |
| 52 Utils.failTest(error, KEY_ERROR); | 52 Utils.failTest(error, KEY_ERROR); |
| 53 }); | 53 }); |
| 54 } | 54 } |
| 55 | 55 |
| 56 Utils.timeLog('Creating new media key session for contentType: ' + | 56 Utils.timeLog('Creating new media key session for contentType: ' + |
| 57 message.contentType + ', initData: ' + | 57 message.contentType + ', initData: ' + |
| 58 Utils.getHexString(message.initData)); | 58 Utils.getHexString(message.initData)); |
| 59 try { | 59 try { |
| 60 var session = message.target.mediaKeys.createSession( | 60 if (message.target.mediaKeys.createSession.length == 0) { |
| 61 message.contentType, message.initData); | 61 // FIXME(jrummell): Remove this test (and else branch) once blink |
| 62 session.then(addMediaKeySessionListeners) | 62 // uses the new API. |
| 63 var session = message.target.mediaKeys.createSession(); |
| 64 addMediaKeySessionListeners(session); |
| 65 session.generateRequest(message.contentType, message.initData) |
| 63 .catch(function(error) { | 66 .catch(function(error) { |
| 64 Utils.failTest(error, KEY_ERROR); | 67 Utils.failTest(error, KEY_ERROR); |
| 65 }); | 68 }); |
| 69 } else { |
| 70 var session = message.target.mediaKeys.createSession( |
| 71 message.contentType, message.initData); |
| 72 session.then(addMediaKeySessionListeners) |
| 73 .catch(function(error) { |
| 74 Utils.failTest(error, KEY_ERROR); |
| 75 }); |
| 76 } |
| 66 } catch (e) { | 77 } catch (e) { |
| 67 Utils.failTest(e); | 78 Utils.failTest(e); |
| 68 } | 79 } |
| 69 }); | 80 }); |
| 70 this.registerDefaultEventListeners(player); | 81 this.registerDefaultEventListeners(player); |
| 71 try { | 82 try { |
| 72 Utils.timeLog('Setting video media keys: ' + player.testConfig.keySystem); | 83 Utils.timeLog('Setting video media keys: ' + player.testConfig.keySystem); |
| 73 MediaKeys.create(player.testConfig.keySystem).then(function(mediaKeys) { | 84 MediaKeys.create(player.testConfig.keySystem).then(function(mediaKeys) { |
| 74 player.video.setMediaKeys(mediaKeys); | 85 player.video.setMediaKeys(mediaKeys); |
| 75 }).catch(function(error) { | 86 }).catch(function(error) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 default: | 180 default: |
| 170 Utils.timeLog(keySystem + ' is not a known key system'); | 181 Utils.timeLog(keySystem + ' is not a known key system'); |
| 171 if (usePrefixedEME) | 182 if (usePrefixedEME) |
| 172 return PrefixedClearKeyPlayer; | 183 return PrefixedClearKeyPlayer; |
| 173 return ClearKeyPlayer; | 184 return ClearKeyPlayer; |
| 174 } | 185 } |
| 175 } | 186 } |
| 176 var Player = getPlayerType(testConfig.keySystem); | 187 var Player = getPlayerType(testConfig.keySystem); |
| 177 return new Player(video, testConfig); | 188 return new Player(video, testConfig); |
| 178 }; | 189 }; |
| OLD | NEW |