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 24 matching lines...) Expand all Loading... | |
35 player.video.addEventListener(failingEvents[i], Utils.failTest); | 35 player.video.addEventListener(failingEvents[i], Utils.failTest); |
36 } | 36 } |
37 }; | 37 }; |
38 | 38 |
39 PlayerUtils.registerEMEEventListeners = function(player) { | 39 PlayerUtils.registerEMEEventListeners = function(player) { |
40 player.video.addEventListener('needkey', function(message) { | 40 player.video.addEventListener('needkey', function(message) { |
41 | 41 |
42 function addMediaKeySessionListeners(mediaKeySession) { | 42 function addMediaKeySessionListeners(mediaKeySession) { |
43 mediaKeySession.addEventListener('message', function(message) { | 43 mediaKeySession.addEventListener('message', function(message) { |
44 player.video.receivedKeyMessage = true; | 44 player.video.receivedKeyMessage = true; |
45 if (Utils.isHeartBeatMessage(message.message)) { | 45 if (Utils.isHeartBeatMessage( |
46 Utils.convertToUint8Array(message.message))) { | |
ddorwin
2014/07/20 22:35:05
Hide this in iHBM()?
jrummell
2014/07/23 22:30:05
Done.
| |
46 Utils.timeLog('MediaKeySession onMessage - heart beat', message); | 47 Utils.timeLog('MediaKeySession onMessage - heart beat', message); |
47 player.video.receivedHeartbeat = true; | 48 player.video.receivedHeartbeat = true; |
48 } | 49 } |
49 player.onMessage(message); | 50 player.onMessage(message); |
50 }); | 51 }); |
51 mediaKeySession.addEventListener('error', function(error) { | 52 mediaKeySession.addEventListener('error', function(error) { |
52 Utils.failTest(error, KEY_ERROR); | 53 Utils.failTest(error, KEY_ERROR); |
53 }); | 54 }); |
54 } | 55 } |
55 | 56 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 }); | 114 }); |
114 | 115 |
115 player.video.addEventListener('webkitkeyerror', function(error) { | 116 player.video.addEventListener('webkitkeyerror', function(error) { |
116 Utils.timeLog('onWebkitKeyError', error); | 117 Utils.timeLog('onWebkitKeyError', error); |
117 Utils.failTest(error, KEY_ERROR); | 118 Utils.failTest(error, KEY_ERROR); |
118 }); | 119 }); |
119 | 120 |
120 player.video.addEventListener('webkitkeymessage', function(message) { | 121 player.video.addEventListener('webkitkeymessage', function(message) { |
121 Utils.timeLog('onWebkitKeyMessage', message); | 122 Utils.timeLog('onWebkitKeyMessage', message); |
122 message.target.receivedKeyMessage = true; | 123 message.target.receivedKeyMessage = true; |
123 if (Utils.isHeartBeatMessage(message.message)) { | 124 if (Utils.isHeartBeatMessage(Utils.convertToUint8Array(message.message))) { |
124 Utils.timeLog('onWebkitKeyMessage - heart beat', message); | 125 Utils.timeLog('onWebkitKeyMessage - heart beat', message); |
125 message.target.receivedHeartbeat = true; | 126 message.target.receivedHeartbeat = true; |
126 } | 127 } |
127 }); | 128 }); |
128 this.registerDefaultEventListeners(player); | 129 this.registerDefaultEventListeners(player); |
129 }; | 130 }; |
130 | 131 |
131 PlayerUtils.setVideoSource = function(player) { | 132 PlayerUtils.setVideoSource = function(player) { |
132 if (player.testConfig.useMSE) { | 133 if (player.testConfig.useMSE) { |
133 Utils.timeLog('Loading media using MSE.'); | 134 Utils.timeLog('Loading media using MSE.'); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 default: | 178 default: |
178 Utils.timeLog(keySystem + ' is not a known key system'); | 179 Utils.timeLog(keySystem + ' is not a known key system'); |
179 if (usePrefixedEME) | 180 if (usePrefixedEME) |
180 return PrefixedClearKeyPlayer; | 181 return PrefixedClearKeyPlayer; |
181 return ClearKeyPlayer; | 182 return ClearKeyPlayer; |
182 } | 183 } |
183 } | 184 } |
184 var Player = getPlayerType(testConfig.keySystem); | 185 var Player = getPlayerType(testConfig.keySystem); |
185 return new Player(video, testConfig); | 186 return new Player(video, testConfig); |
186 }; | 187 }; |
OLD | NEW |