Accurate color reporting

This commit is contained in:
Sam 2018-07-15 19:36:23 +10:00
parent cac570f493
commit 946790cb21
3 changed files with 19 additions and 6 deletions

View File

@ -374,11 +374,15 @@ const actions = {
if (!state.synclounge.lastHostTimeline || isNaN(state.synclounge.lastHostTimeline.time)) {
status = 'error'
} else {
let difference = Math.abs(state.chosenClient.lastTimelineObject.time - state.synclounge.lastHostTimeline.time)
if (difference > 1500 && difference < state.settings.SYNCFLEXABILITY) {
status = 'ok'
let hostAge = Math.abs(new Date().getTime() - state.synclounge.lastHostTimeline.recievedAt)
let hostTime = 0 + state.synclounge.lastHostTimeline.time
console.log('Adding hosttime', hostAge)
if (state.synclounge.lastHostTimeline.playerState === 'playing') {
hostTime = parseInt(hostTime) + parseInt(hostAge)
}
if (difference > 3000) {
let difference = Math.abs(data.time - (hostTime))
console.log('Reporting a difference of', difference)
if (difference > state.settings.SYNCFLEXABILITY) {
status = 'notok'
}
}

View File

@ -28,6 +28,8 @@ module.exports = function PlexClient () {
this.events = new EventEmitter()
this.labels = []
this.lastSyncCommand = 0
this.userData = null
// Latest objects for reference in the future
@ -243,11 +245,16 @@ module.exports = function PlexClient () {
}
return this.seekTo(time)
}
this.sync = function (hostTimeline, SYNCFLEXABILITY, SYNCMODE) {
this.sync = function (hostTimeline, SYNCFLEXABILITY, SYNCMODE, POLLINTERVAL) {
return new Promise(async (resolve, reject) => {
if (this.clientIdentifier === 'PTPLAYER9PLUS10') {
await this.getTimeline()
}
let lastCommandTime = Math.abs(this.lastSyncCommand - new Date().getTime())
if (this.lastSyncCommand && this.clientIdentifier !== 'PTPLAYER9PLUS10' && lastCommandTime < POLLINTERVAL) {
console.log('Too soon for another sync command', lastCommandTime)
return reject(new Error('Too soon for another sync command'))
}
let lagTime = Math.abs(hostTimeline.recievedAt - new Date().getTime())
if (lagTime) {
console.log('Adding lag time of', lagTime)
@ -264,6 +271,7 @@ module.exports = function PlexClient () {
if (parseInt(difference) > parseInt(SYNCFLEXABILITY) || (bothPaused && difference > 10)) {
// We need to seek!
console.log('STORE: we need to seek as we are out by', difference)
this.lastSyncCommand = new Date().getTime()
// Decide what seeking method we want to use
if (SYNCMODE === 'cleanseek' || hostTimeline.playerState === 'paused') {
return resolve(await this.cleanSeek(hostTimeline.time))
@ -329,6 +337,7 @@ module.exports = function PlexClient () {
// Now that we've built our params, it's time to hit the client api
console.log('Sending command')
await this.hitApi(command, params, this.chosenConnection)
await this.waitForMovement()
console.log('PlayMedia DONE')
resolve(true)
})

View File

@ -354,7 +354,7 @@ export default {
}
}
try {
await rootState.chosenClient.sync(data, rootState.settings.SYNCFLEXABILITY, rootState.settings.SYNCMODE)
await rootState.chosenClient.sync(data, rootState.settings.SYNCFLEXABILITY, rootState.settings.SYNCMODE, rootState.settings.CLIENTPOLLINTERVAL)
} catch (e) {
return resolve()
}