Skip to content

Commit

Permalink
Fix stop time in ExternalPlayer
Browse files Browse the repository at this point in the history
Previously, since the web client thought the external player was transcoding, due to a stubbed device profile, it added the transcoding offset to the current time on playback stop, sending the wrong value to the server. Simply marking all content as direct-playable fixes this.
Additionally, some timestamp handling issues related to ticks vs milliseconds were fixed.
  • Loading branch information
Maxr1998 authored and nielsvanvelzen committed Nov 30, 2021
1 parent 3a7e2c9 commit c123be1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
22 changes: 10 additions & 12 deletions app/src/main/assets/native/ExoPlayerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,15 @@ export class ExoPlayerPlugin {
}

async getDeviceProfile() {
var profile = {};
profile.Name = 'ExoPlayer Stub';
profile.MaxStreamingBitrate = 100000000;
profile.MaxStaticBitrate = 100000000;
profile.MusicStreamingTranscodingBitrate = 320000;

profile.DirectPlayProfiles = [];
profile.CodecProfiles = [];
profile.SubtitleProfiles = [];
profile.TranscodingProfiles = [];

return profile;
return {
Name: 'ExoPlayer Stub',
MaxStreamingBitrate: 100000000,
MaxStaticBitrate: 100000000,
MusicStreamingTranscodingBitrate: 320000,
DirectPlayProfiles: [{Type: 'Video'}, {Type: 'Audio'}],
CodecProfiles: [],
SubtitleProfiles: [],
TranscodingProfiles: []
};
}
}
35 changes: 18 additions & 17 deletions app/src/main/assets/native/ExternalPlayerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class ExternalPlayerPlugin {

// Disable orientation lock
this.isExternalPlayer = true;
// _currentTime is in milliseconds
this._currentTime = 0;
this._paused = true;
this._volume = 100;
Expand All @@ -41,7 +42,7 @@ export class ExternalPlayerPlugin {
}

async play(options) {
this._currentTime = (options.playerStartPositionTicks || 0) / 10000;
this._currentTime = options.playerStartPositionTicks / 10000 || 0;
this._paused = false;
this._currentSrc = options.url;
this._isIntro = options.item && options.item.ProviderIds && options.item.ProviderIds.hasOwnProperty("prerolls.video");
Expand Down Expand Up @@ -101,9 +102,8 @@ export class ExternalPlayerPlugin {
}

async notifyTimeUpdate(currentTime) {
// if no time provided handle like playback completed
currentTime = currentTime || this.playbackManager.duration(this);
currentTime = currentTime / 1000;
// Use duration (as if playback completed) if no time is provided
currentTime = currentTime || this.playbackManager.duration(this) / 10000;
this._timeUpdated = this._currentTime != currentTime;
this._currentTime = currentTime;
this.events.trigger(this, 'timeupdate');
Expand All @@ -119,8 +119,11 @@ export class ExternalPlayerPlugin {
this.notifyEnded();
}

/**
* Returns the currently known player time in milliseconds
*/
currentTime() {
return (this._currentTime || 0) * 1000;
return this._currentTime || 0;
}

async changeSubtitleStream(index) {
Expand All @@ -134,17 +137,15 @@ export class ExternalPlayerPlugin {
}

async getDeviceProfile() {
const profile = {};
profile.Name = 'Android External Player Stub';
profile.MaxStreamingBitrate = 100000000;
profile.MaxStaticBitrate = 100000000;
profile.MusicStreamingTranscodingBitrate = 320000;

profile.DirectPlayProfiles = [];
profile.CodecProfiles = [];
profile.SubtitleProfiles = [];
profile.TranscodingProfiles = [];

return profile;
return {
Name: 'Android External Player Stub',
MaxStreamingBitrate: 100000000,
MaxStaticBitrate: 100000000,
MusicStreamingTranscodingBitrate: 320000,
DirectPlayProfiles: [{Type: 'Video'}, {Type: 'Audio'}],
CodecProfiles: [],
SubtitleProfiles: [],
TranscodingProfiles: []
};
}
}

0 comments on commit c123be1

Please sign in to comment.