Skip to content

Commit

Permalink
Fix support for playlists in external player
Browse files Browse the repository at this point in the history
Only allow intros, a single item to play and stop as there is no way to stop a playlist from an external player.
  • Loading branch information
CarlosOlivo committed Dec 17, 2020
1 parent 122448f commit fc08a5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions app/src/main/assets/native-10.6/externalplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ define(['appSettings', 'events', 'playbackManager'], function (appSettings, even
self._paused = true;
self._volume = 100;
self._currentSrc = null;
self._isIntro = false;

self.canPlayMediaType = function (mediaType) {
return mediaType === 'Video';
};

self.canPlayItem = function (item, playOptions) {
var mediaSource = item.MediaSources && item.MediaSources[0];
return window.ExternalPlayer.isEnabled() && mediaSource && mediaSource.SupportsDirectStream;
return window.ExternalPlayer.isEnabled();
};

self.supportsPlayMethod = function (playMethod, item) {
Expand All @@ -46,6 +46,9 @@ define(['appSettings', 'events', 'playbackManager'], function (appSettings, even
self._currentTime = (options.playerStartPositionTicks || 0) / 10000;
self._paused = false;
self._currentSrc = options.url;
self._isIntro = typeof options.item != "undefined" &&
typeof options.item.ProviderIds != "undefined" &&
options.item.ProviderIds.hasOwnProperty("prerolls.video");
window.ExternalPlayer.initPlayer(JSON.stringify(options));
resolve();
});
Expand Down Expand Up @@ -112,6 +115,7 @@ define(['appSettings', 'events', 'playbackManager'], function (appSettings, even
src: self._currentSrc
};

playbackManager._playNextAfterEnded = self._isIntro;
events.trigger(self, 'stopped', [stopInfo]);
self._currentSrc = self._currentTime = null;
});
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/assets/native-10.7/ExternalPlayerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class ExternalPlayerPlugin {
this._paused = true;
this._volume = 100;
this._currentSrc = null;
this._isIntro = false;

this._externalPlayer = window['ExternalPlayer'];
}
Expand All @@ -33,8 +34,7 @@ export class ExternalPlayerPlugin {
}

canPlayItem(item, playOptions) {
var mediaSource = item.MediaSources && item.MediaSources[0];
return this._externalPlayer.isEnabled() && mediaSource && mediaSource.SupportsDirectStream;
return this._externalPlayer.isEnabled();
}

supportsPlayMethod(playMethod, item) {
Expand All @@ -49,6 +49,9 @@ export class ExternalPlayerPlugin {
this._currentTime = (options.playerStartPositionTicks || 0) / 10000;
this._paused = false;
this._currentSrc = options.url;
this._isIntro = typeof options.item != "undefined" &&
typeof options.item.ProviderIds != "undefined" &&
options.item.ProviderIds.hasOwnProperty("prerolls.video");
this._externalPlayer.initPlayer(JSON.stringify(options));
}

Expand Down Expand Up @@ -97,6 +100,7 @@ export class ExternalPlayerPlugin {
src: this._currentSrc
};

this.playbackManager._playNextAfterEnded = this._isIntro;
this.events.trigger(this, 'stopped', [stopInfo]);
this._currentSrc = this._currentTime = null;
}
Expand Down

0 comments on commit fc08a5d

Please sign in to comment.