| 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 /** | 7 /** |
| 8 * Interval for updating media info (in ms). | 8 * Interval for updating media info (in ms). |
| 9 * @type {number} | 9 * @type {number} |
| 10 * @const | 10 * @const |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 }, | 113 }, |
| 114 | 114 |
| 115 /** | 115 /** |
| 116 * If this video is ended or not. | 116 * If this video is ended or not. |
| 117 * @type {boolean} | 117 * @type {boolean} |
| 118 */ | 118 */ |
| 119 get ended() { | 119 get ended() { |
| 120 if (!this.castMedia_) | 120 if (!this.castMedia_) |
| 121 return true; | 121 return true; |
| 122 | 122 |
| 123 return !this.playInProgress && | 123 return !this.playInProgress && |
| 124 this.castMedia_.idleReason === chrome.cast.media.IdleReason.FINISHED; | 124 this.castMedia_.idleReason === chrome.cast.media.IdleReason.FINISHED; |
| 125 }, | 125 }, |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * TimeRange object that represents the seekable ranges of the media | 128 * TimeRange object that represents the seekable ranges of the media |
| 129 * resource. | 129 * resource. |
| 130 * @type {TimeRanges} | 130 * @type {TimeRanges} |
| 131 */ | 131 */ |
| 132 get seekable() { | 132 get seekable() { |
| 133 return { | 133 return { |
| 134 length: 1, | 134 length: 1, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 * @param {string} messageAsJson Content of message as json format. | 322 * @param {string} messageAsJson Content of message as json format. |
| 323 * @private | 323 * @private |
| 324 */ | 324 */ |
| 325 onMessage_: function(namespace, messageAsJson) { | 325 onMessage_: function(namespace, messageAsJson) { |
| 326 if (namespace !== CAST_MESSAGE_NAMESPACE || !messageAsJson) | 326 if (namespace !== CAST_MESSAGE_NAMESPACE || !messageAsJson) |
| 327 return; | 327 return; |
| 328 | 328 |
| 329 var message = JSON.parse(messageAsJson); | 329 var message = JSON.parse(messageAsJson); |
| 330 if (message['message'] === 'request-token') { | 330 if (message['message'] === 'request-token') { |
| 331 if (message['previousToken'] === this.token_) { | 331 if (message['previousToken'] === this.token_) { |
| 332 this.mediaManager_.getToken(true).then(function(token) { | 332 this.mediaManager_.getToken(true).then(function(token) { |
| 333 this.token_ = token; | 333 this.token_ = token; |
| 334 this.sendMessage_({message: 'push-token', token: token}); | 334 this.sendMessage_({message: 'push-token', token: token}); |
| 335 // TODO(yoshiki): Revokes the previous token. | 335 // TODO(yoshiki): Revokes the previous token. |
| 336 }.bind(this)).catch(function(error) { | 336 }.bind(this)).catch(function(error) { |
| 337 // Send an empty token as an error. | 337 // Send an empty token as an error. |
| 338 this.sendMessage_({message: 'push-token', token: ''}); | 338 this.sendMessage_({message: 'push-token', token: ''}); |
| 339 // TODO(yoshiki): Revokes the previous token. | 339 // TODO(yoshiki): Revokes the previous token. |
| 340 console.error(error.stack || error); | 340 console.error(error.stack || error); |
| 341 }); | 341 }); |
| 342 } else { | 342 } else { |
| 343 console.error( | 343 console.error( |
| 344 'New token is requested, but the previous token mismatches.'); | 344 'New token is requested, but the previous token mismatches.'); |
| 345 } | 345 } |
| 346 } else if (message['message'] === 'playback-error') { | 346 } else if (message['message'] === 'playback-error') { |
| 347 if (message['detail'] === 'src-not-supported') | 347 if (message['detail'] === 'src-not-supported') |
| 348 this.errorCode_ = MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED; | 348 this.errorCode_ = MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED; |
| 349 } | 349 } |
| 350 }, | 350 }, |
| 351 | 351 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 this.dispatchEvent(new Event('durationchange')); | 436 this.dispatchEvent(new Event('durationchange')); |
| 437 } | 437 } |
| 438 | 438 |
| 439 // Media is being unloaded. | 439 // Media is being unloaded. |
| 440 if (!alive) { | 440 if (!alive) { |
| 441 this.unloadMedia_(); | 441 this.unloadMedia_(); |
| 442 return; | 442 return; |
| 443 } | 443 } |
| 444 }, | 444 }, |
| 445 }; | 445 }; |
| OLD | NEW |