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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 // This hack prevents a bug on the cast extension. | 7 // This hack prevents a bug on the cast extension. |
8 // TODO(yoshiki): Remove this once the cast extension supports Chrome apps. | 8 // TODO(yoshiki): Remove this once the cast extension supports Chrome apps. |
9 // Although localStorage in Chrome app is not supported, but it's used in the | 9 // Although localStorage in Chrome app is not supported, but it's used in the |
10 // cast extension. This line prevents an exception on using localStorage. | 10 // cast extension. This line prevents an exception on using localStorage. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 onReceiver); | 76 onReceiver); |
77 chrome.cast.initialize(apiConfig, onInitSuccess, onError); | 77 chrome.cast.initialize(apiConfig, onInitSuccess, onError); |
78 } | 78 } |
79 | 79 |
80 /** | 80 /** |
81 * @param {chrome.cast.ReceiverAvailability} availability Availability of casts. | 81 * @param {chrome.cast.ReceiverAvailability} availability Availability of casts. |
82 * @param {Array.<Object>} receivers List of casts. | 82 * @param {Array.<Object>} receivers List of casts. |
83 */ | 83 */ |
84 function onReceiver(availability, receivers) { | 84 function onReceiver(availability, receivers) { |
85 if (availability === chrome.cast.ReceiverAvailability.AVAILABLE) { | 85 if (availability === chrome.cast.ReceiverAvailability.AVAILABLE) { |
| 86 if (!receivers) { |
| 87 console.error('Receiver list is empty.'); |
| 88 receivers = []; |
| 89 } |
| 90 |
86 player.setCastList(receivers); | 91 player.setCastList(receivers); |
87 } else if (availability == chrome.cast.ReceiverAvailability.UNAVAILABLE) { | 92 } else if (availability == chrome.cast.ReceiverAvailability.UNAVAILABLE) { |
88 player.setCastList([]); | 93 player.setCastList([]); |
89 } else { | 94 } else { |
90 console.error('Unexpected response in onReceiver.', arguments); | 95 console.error('Unexpected response in onReceiver.', arguments); |
91 player.setCastList([]); | 96 player.setCastList([]); |
92 } | 97 } |
93 } | 98 } |
OLD | NEW |