More syncing improvements

This commit is contained in:
Sam 2018-05-25 17:00:47 +10:00
parent 543f25f990
commit c154defae7
5 changed files with 29 additions and 38 deletions

View File

@ -16,6 +16,7 @@
"babel-eslint": "^8.2.2",
"body-parser": "^1.18.2",
"cors": "^2.8.3",
"git-rev": "^0.2.1",
"jsonfile": "^4.0.0",
"sails-disk": "^1.0.1",
"socket.io": "^2.0.3",

View File

@ -94,6 +94,8 @@
<div class="headline">{{ server.name }}</div>
<div style="opacity:0.8"> v{{ server.productVersion }}</div>
<div>Owned by {{ ownerOfServer(server) }}</div>
<div v-if="!isConnectable(server)" class="red--text">Unable to connect</div>
<div v-if="!isConnectable(server)" class="red--text" style="font-size: 10px">Try disabling your adblocker</div>
</div>
</v-flex>
</v-layout>
@ -101,29 +103,6 @@
</v-card>
</router-link>
</v-flex>
<v-flex xs12 lg4 md6 xl3 v-for="device in plex.all_devices" v-if="!isConnectable(device) && device.provides.indexOf('server') != -1" :key="device.machineIdentifier" class="pa-2">
<v-card class="white--text" horizontal height="10em" style="cursor: pointer; z-index: 0; background: rgba(0,0,0,0.4);">
<v-container fluid grid-list-lg>
<v-layout row>
<v-flex xs4>
<v-card-media
:src="logos.plex.standard"
height="110px"
contain
></v-card-media>
</v-flex>
<v-flex xs8>
<div>
<div class="headline">{{ device.name }}</div>
<div style="opacity:0.8"> v{{ device.productVersion }}</div>
<div>Owned by {{ ownerOfServer(device) }}</div>
<div v-if="!isConnectable(device)" class="red--text">Unable to connect</div>
</div>
</v-flex>
</v-layout>
</v-container>
</v-card>
</v-flex>
</v-layout>
</div>
</div>

View File

@ -7,7 +7,7 @@
</v-layout>
<div v-if="contents">
<v-card v-if="contents" horizontal :img="getArtUrl" style="height: 80vh" class="darken-2 white--text">
<div style="background-color: rgba(0, 0, 0, 0.4); height: 100%">
<div style=" height: 100%">
<v-container style="background-color: rgba(0, 0, 0, 0.8); height: 100%" fluid>
<v-layout row wrap>
<v-flex xs12 md3>

View File

@ -22,7 +22,7 @@
<v-flex class="pl-3">
<v-container class="pa-0" fill-height>
<v-layout column wrap justify-space-apart>
<v-flex>
<v-flex>
<h1>{{ getTitle(playingMetadata) }}</h1>
</v-flex>
<v-flex>
@ -35,14 +35,14 @@
</v-container>
</v-flex>
</v-layout>
<v-layout row wrap style="position: absolute; top: 0; right: 0; z-index: 2" class="pa-3 hidden-xs-only">
<v-layout row wrap style="position: absolute; top: 0; right: 0; z-index: 2" class="pa-3 hidden-xs-only">
<v-flex class="text-xs-right pa-1">
<div class="hidden-xs-only">
<v-tooltip bottom color="accent" v-if="me && me.role !== 'host'">
<v-icon slot="activator" color="white" class="clickable" :disabled="manualSyncQueued" v-on:click="doManualSync">compare_arrows</v-icon>
Manual Sync
</v-tooltip>
<v-icon slot="activator" color="white" class="clickable pl-3" v-on:click="dialog = !dialog">settings</v-icon>
</v-tooltip>
<v-icon slot="activator" color="white" class="clickable pl-3" v-on:click="dialog = !dialog">settings</v-icon>
<router-link to="/browse" slot="activator">
<v-icon color="white" class="pl-3" v-on:click.native="stopPlayback()">close</v-icon>
</router-link>
@ -113,7 +113,7 @@
<v-flex class="pl-2">
<v-container class="pa-0" fill-height>
<v-layout column wrap justify-space-apart>
<v-flex>
<v-flex>
<h1>{{ getTitle(playingMetadata) }}</h1>
</v-flex>
<v-flex>
@ -172,13 +172,14 @@ export default {
if (this.destroyed) {
return
}
console.log('Got command', data.command)
if (data.command === '/player/timeline/poll') {
let key = this.chosenKey
let ratingKey = null
if (key) {
ratingKey = '/library/metadata/' + key
}
let machineIdentifier = null
if (this.chosenServer) {
machineIdentifier = this.chosenServer.clientIdentifier
@ -193,12 +194,16 @@ export default {
state: this.playerstatus
}
this.lastSentTimeline = playerdata
this.eventbus.$emit('ptplayer-poll', (time) => {
console.log('Poll time was out by', Math.abs(time - this.playertime))
playerdata.time = time
this.playertime = time
if (this.playerTime) {
this.eventbus.$emit('ptplayer-poll', (time) => {
console.log('Poll time was out by', Math.abs(time - this.playertime))
playerdata.time = time
this.playertime = time
data.callback(playerdata)
})
} else {
data.callback(playerdata)
})
}
return
}
if (data.command === '/player/playback/play') {

View File

@ -97,7 +97,7 @@ module.exports = function PlexClient () {
}
var _url = connection.uri + command + '?' + query
this.setValue('commandId', this.commandId + 1)
var options = PlexAuth.getClientApiOptions(_url, this.clientIdentifier, this.uuid, 5000)
var options = PlexAuth.getClientApiOptions(_url, this.clientIdentifier, this.uuid, 5000)
axios.get(connection.uri + command, {
params,
headers: options.headers
@ -204,13 +204,17 @@ module.exports = function PlexClient () {
}
this.waitForMovement = function (startTime) {
return new Promise((resolve, reject) => {
let time = 500
if (this.clientIdentifier === 'PTPLAYER9PLUS10') {
time = 10
}
let timer = setInterval(async () => {
let now = await this.getTimeline()
if (now.time !== startTime) {
resolve()
clearInterval(timer)
}
}, 500)
}, time)
})
}
this.skipAhead = function (current, duration) {
@ -238,7 +242,9 @@ module.exports = function PlexClient () {
const difference = Math.abs((parseInt(this.lastTimelineObject.time)) - parseInt(hostTimeline.time))
console.log('Difference', difference)
if (parseInt(difference) > parseInt(SYNCFLEXABILITY)) {
let bothPaused = hostTimeline.playerState === 'paused' && this.lastTimelineObject.state === 'paused'
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)
// Decide what seeking method we want to use