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 session.generateRequest(message.initDataType, message.initData) | 78 session.generateRequest(message.initDataType, message.initData) |
79 .catch(function(error) { Utils.failTest(error, KEY_ERROR); }); | 79 .catch(function(error) { Utils.failTest(error, KEY_ERROR); }); |
80 } | 80 } |
81 } catch (e) { | 81 } catch (e) { |
82 Utils.failTest(e); | 82 Utils.failTest(e); |
83 } | 83 } |
84 }); | 84 }); |
85 | 85 |
86 this.registerDefaultEventListeners(player); | 86 this.registerDefaultEventListeners(player); |
87 Utils.timeLog('Setting video media keys: ' + player.testConfig.keySystem); | 87 Utils.timeLog('Setting video media keys: ' + player.testConfig.keySystem); |
| 88 var persistentState = player.testConfig.sessionToLoad ? "required" |
| 89 : "optional"; |
88 return navigator.requestMediaKeySystemAccess( | 90 return navigator.requestMediaKeySystemAccess( |
89 player.testConfig.keySystem, [{}]) | 91 player.testConfig.keySystem, [{persistentState: persistentState}]) |
90 .then(function(access) { return access.createMediaKeys(); }) | 92 .then(function(access) { return access.createMediaKeys(); }) |
91 .then(function(mediaKeys) { | 93 .then(function(mediaKeys) { |
92 return player.video.setMediaKeys(mediaKeys); | 94 return player.video.setMediaKeys(mediaKeys); |
93 }) | 95 }) |
94 .then(function(result) { return player; }) | 96 .then(function(result) { return player; }) |
95 .catch(function(error) { Utils.failTest(error, NOTSUPPORTEDERROR); }); | 97 .catch(function(error) { Utils.failTest(error, NOTSUPPORTEDERROR); }); |
96 }; | 98 }; |
97 | 99 |
98 // Register the necessary event handlers needed when playing encrypted content | 100 // Register the necessary event handlers needed when playing encrypted content |
99 // using the prefixed API. Even though the prefixed API is all synchronous, | 101 // using the prefixed API. Even though the prefixed API is all synchronous, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 default: | 192 default: |
191 Utils.timeLog(keySystem + ' is not a known key system'); | 193 Utils.timeLog(keySystem + ' is not a known key system'); |
192 if (usePrefixedEME) | 194 if (usePrefixedEME) |
193 return PrefixedClearKeyPlayer; | 195 return PrefixedClearKeyPlayer; |
194 return ClearKeyPlayer; | 196 return ClearKeyPlayer; |
195 } | 197 } |
196 } | 198 } |
197 var Player = getPlayerType(testConfig.keySystem); | 199 var Player = getPlayerType(testConfig.keySystem); |
198 return new Player(video, testConfig); | 200 return new Player(video, testConfig); |
199 }; | 201 }; |
OLD | NEW |