Initial port of skip ahead. Want to convert slplayer version to event
driver rather than polling
This commit is contained in:
parent
403328e1c5
commit
27180eb570
|
@ -390,34 +390,38 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
WAIT_FOR_MOVEMENT: (startTime) => new Promise((resolve) => {
|
WAIT_FOR_MOVEMENT: ({ dispatch }, startTime) => new Promise((resolve) => {
|
||||||
// TODO: fix this
|
// TODO: fix this
|
||||||
let time = 500;
|
let time = 500;
|
||||||
if (this.clientIdentifier === 'PTPLAYER9PLUS10') {
|
if (this.clientIdentifier === 'PTPLAYER9PLUS10') {
|
||||||
time = 50;
|
time = 50;
|
||||||
}
|
}
|
||||||
const timer = setInterval(async () => {
|
const timer = setInterval(async () => {
|
||||||
const now = await this.getTimeline();
|
const timeline = await dispatch('POLL_CLIENT');
|
||||||
if (now.time !== startTime) {
|
if (timeline.time !== startTime) {
|
||||||
console.log('Player has movement!');
|
console.log('Player has movement!');
|
||||||
resolve();
|
resolve();
|
||||||
|
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
}
|
}
|
||||||
}, time);
|
}, time);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
SKIP_AHEAD: async (current, duration) => {
|
SKIP_AHEAD: async ({ getters, dispatch }, { current, duration }) => {
|
||||||
// TODO: lol this is broken fix pls
|
// TODO: lol this is broken fix pls
|
||||||
const startedAt = Date.now();
|
const startedAt = Date.now();
|
||||||
const now = this.lastTimelineObject.time;
|
const now = getters.GET_PLEX_CLIENT_TIMELINE.time;
|
||||||
await this.seekTo(current + duration);
|
await dispatch('SEEK_TO', current + duration);
|
||||||
await this.waitForMovement(now);
|
await dispatch('WAIT_FOR_MOVEMENT', now);
|
||||||
|
|
||||||
// The client is now ready
|
// The client is now ready
|
||||||
await this.pressPause();
|
await dispatch('PRESS_PAUSE');
|
||||||
|
|
||||||
// Calculate how long it took to get to our ready state
|
// Calculate how long it took to get to our ready state
|
||||||
const elapsed = Date.now() - startedAt;
|
const elapsed = Date.now() - startedAt;
|
||||||
await delay(duration - elapsed);
|
await delay(duration - elapsed);
|
||||||
await this.pressPlay();
|
|
||||||
|
await dispatch('PRESS_PLAY');
|
||||||
},
|
},
|
||||||
|
|
||||||
SOFT_SEEK: ({ getters, dispatch }, offset) => {
|
SOFT_SEEK: ({ getters, dispatch }, offset) => {
|
||||||
|
|
Loading…
Reference in New Issue