Skip to content

Commit

Permalink
Fix Continue From Last Position in Shell
Browse files Browse the repository at this point in the history
  • Loading branch information
jaruba committed Oct 24, 2024
1 parent f6eb1e3 commit 092a971
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/ShellVideo/ShellVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ function ShellVideo(options) {
var events = new EventEmitter();
var destroyed = false;
var stream = null;
var continueFrom = 0;

var avgDuration = 0;
var minClipDuration = 30;
Expand Down Expand Up @@ -117,11 +116,6 @@ function ShellVideo(options) {
}
case 'time-pos': {
props[args.name] = Math.round(args.data*1000);
if(continueFrom) {
ipc.send('mpv-set-prop', ['time-pos', continueFrom]);
props[args.name] = Math.round(continueFrom);
continueFrom = 0;
}
break;
}
case 'sub-scale': {
Expand Down Expand Up @@ -310,7 +304,6 @@ function ShellVideo(options) {
if (commandArgs && commandArgs.stream && typeof commandArgs.stream.url === 'string') {
stream = commandArgs.stream;
onPropChanged('stream');
continueFrom = commandArgs.time !== null && isFinite(commandArgs.time) ? parseInt(commandArgs.time, 10) / 1000 : 0;

setBackground(false);

Expand All @@ -327,7 +320,10 @@ function ShellVideo(options) {
ipc.send('mpv-set-prop', ['input-defalt-bindings', separateWindow]);
ipc.send('mpv-set-prop', ['input-vo-keyboard', separateWindow]);

ipc.send('mpv-command', ['loadfile', stream.url]);
if (commandArgs.time !== null && isFinite(commandArgs.time))
ipc.send('mpv-command', ['loadfile', stream.url, 'replace', 'start=+'+Math.floor(parseInt(commandArgs.time, 10)/1000)]);
else
ipc.send('mpv-command', ['loadfile', stream.url]);
ipc.send('mpv-set-prop', ['pause', false]);
ipc.send('mpv-set-prop', ['speed', props.speed]);
ipc.send('mpv-set-prop', ['aid', props.aid]);
Expand Down Expand Up @@ -362,7 +358,6 @@ function ShellVideo(options) {
aid: null,
sid: null,
};
continueFrom = 0;
avgDuration = 0;
ipc.send('mpv-command', ['stop']);
onPropChanged('loaded');
Expand Down

0 comments on commit 092a971

Please sign in to comment.