Skip to content

Commit

Permalink
Fix miloproductionsinc#9 Try to keep the media up to date by forcing …
Browse files Browse the repository at this point in the history
…it to be an empty array whenever media doesn't exist (instead of setting mediaSessionId to 'invalidated').
  • Loading branch information
Lindsay-Needs-Sleep committed Jan 25, 2020
1 parent 2cb3b33 commit a668f07
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions www/chrome.cast.js
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,6 @@ chrome.cast.Session.prototype._update = function (obj) {
this.receiver = null;
}

// Empty media
if (obj.media && obj.media.length > 0) {
this._updateMedia(obj.media[0]);
} else {
Expand All @@ -871,7 +870,7 @@ chrome.cast.Session.prototype._update = function (obj) {
* new Media information in obj.
*/
chrome.cast.Session.prototype._updateMedia = function (obj) {
if (!obj) {
if (this.media && (!obj || JSON.stringify(obj) === '{}')) {
this.media.splice(0, _session.media.length);
return;
}
Expand All @@ -888,8 +887,7 @@ chrome.cast.Session.prototype._updateMedia = function (obj) {
* adds the new Media object described by media.
*/
chrome.cast.Session.prototype._loadNewMedia = function (media) {
// Invalidate and remove previous
this._getMedia().mediaSessionId = 'invalidated';
// Remove previous media
this._updateMedia(null);
// Add the new media object
this._updateMedia(media);
Expand All @@ -909,7 +907,7 @@ chrome.cast.Session.prototype._emitMediaListener = function () {
};

chrome.cast.Session.prototype._getMedia = function () {
return this.media[0];
return this.media && this.media[0];
};

/**
Expand Down

0 comments on commit a668f07

Please sign in to comment.