| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 }, | 114 }, |
| 115 | 115 |
| 116 /** | 116 /** |
| 117 * If this video is ended or not. | 117 * If this video is ended or not. |
| 118 * @type {boolean} | 118 * @type {boolean} |
| 119 */ | 119 */ |
| 120 get ended() { | 120 get ended() { |
| 121 if (!this.castMedia_) | 121 if (!this.castMedia_) |
| 122 return true; | 122 return true; |
| 123 | 123 |
| 124 return !this.playInProgress && | 124 return !this.playInProgress && |
| 125 this.castMedia_.idleReason === chrome.cast.media.IdleReason.FINISHED; | 125 this.castMedia_.idleReason === chrome.cast.media.IdleReason.FINISHED; |
| 126 }, | 126 }, |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * TimeRange object that represents the seekable ranges of the media | 129 * TimeRange object that represents the seekable ranges of the media |
| 130 * resource. | 130 * resource. |
| 131 * @type {TimeRanges} | 131 * @type {TimeRanges} |
| 132 */ | 132 */ |
| 133 get seekable() { | 133 get seekable() { |
| 134 return { | 134 return { |
| 135 length: 1, | 135 length: 1, |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 * @param {string} messageAsJson Content of message as json format. | 336 * @param {string} messageAsJson Content of message as json format. |
| 337 * @private | 337 * @private |
| 338 */ | 338 */ |
| 339 onMessage_: function(namespace, messageAsJson) { | 339 onMessage_: function(namespace, messageAsJson) { |
| 340 if (namespace !== CAST_MESSAGE_NAMESPACE || !messageAsJson) | 340 if (namespace !== CAST_MESSAGE_NAMESPACE || !messageAsJson) |
| 341 return; | 341 return; |
| 342 | 342 |
| 343 var message = JSON.parse(messageAsJson); | 343 var message = JSON.parse(messageAsJson); |
| 344 if (message['message'] === 'request-token') { | 344 if (message['message'] === 'request-token') { |
| 345 if (message['previousToken'] === this.token_) { | 345 if (message['previousToken'] === this.token_) { |
| 346 this.mediaManager_.getToken(true).then(function(token) { | 346 this.mediaManager_.getToken(true).then(function(token) { |
| 347 this.token_ = token; | 347 this.token_ = token; |
| 348 this.sendMessage_({message: 'push-token', token: token}); | 348 this.sendMessage_({message: 'push-token', token: token}); |
| 349 // TODO(yoshiki): Revokes the previous token. | 349 // TODO(yoshiki): Revokes the previous token. |
| 350 }.bind(this)).catch(function(error) { | 350 }.bind(this)).catch(function(error) { |
| 351 // Send an empty token as an error. | 351 // Send an empty token as an error. |
| 352 this.sendMessage_({message: 'push-token', token: ''}); | 352 this.sendMessage_({message: 'push-token', token: ''}); |
| 353 // TODO(yoshiki): Revokes the previous token. | 353 // TODO(yoshiki): Revokes the previous token. |
| 354 console.error(error.stack || error); | 354 console.error(error.stack || error); |
| 355 }); | 355 }); |
| 356 } else { | 356 } else { |
| 357 console.error( | 357 console.error( |
| 358 'New token is requested, but the previous token mismatches.'); | 358 'New token is requested, but the previous token mismatches.'); |
| 359 } | 359 } |
| 360 } else if (message['message'] === 'playback-error') { | 360 } else if (message['message'] === 'playback-error') { |
| 361 if (message['detail'] === 'src-not-supported') | 361 if (message['detail'] === 'src-not-supported') |
| 362 this.errorCode_ = MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED; | 362 this.errorCode_ = MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED; |
| 363 } | 363 } |
| 364 }, | 364 }, |
| 365 | 365 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 this.dispatchEvent(new Event('durationchange')); | 465 this.dispatchEvent(new Event('durationchange')); |
| 466 } | 466 } |
| 467 | 467 |
| 468 // Media is being unloaded. | 468 // Media is being unloaded. |
| 469 if (!alive) { | 469 if (!alive) { |
| 470 this.unloadMedia_(); | 470 this.unloadMedia_(); |
| 471 return; | 471 return; |
| 472 } | 472 } |
| 473 }, | 473 }, |
| 474 }; | 474 }; |
| OLD | NEW |