PlexSettings fixed and ptplayer playback options

This commit is contained in:
samcm 2017-06-19 17:09:50 +10:00
parent c534970e1a
commit b16f2aceeb
4 changed files with 134 additions and 153 deletions

View File

@ -271,26 +271,29 @@ module.exports = function () {
let playables = [] let playables = []
let j = 0 let j = 0
let validServers = 0 let validServers = this.servers.length
for (let i in blockedServers){
if (blockedServers[i].enabled){
validServers++
}
}
if (blockedServers){ if (blockedServers){
this.servers.forEach((server) => { for (let i = 0; i < blockedServers.length; i++ ){
if (!blockedServers[server.clientIdentifier]){ if (this.getServerById(blockedServers[i])){
validServers++ validServers--
} }
}) }
} }
if (validServers == 0){ if (validServers == 0){
return callback(false) return callback(false)
} }
for (let i = 0; i < this.servers.length; i++) { for (let i = 0; i < this.servers.length; i++) {
var server = this.servers[i] var server = this.servers[i]
if (blockedServers[server.clientIdentifier] && !blockedServers[server.clientIdentifier].enabled){ let blocked = false
console.log('Server: ' + server.name + ' is blocked - not searching') if (blockedServers){
for (let i = 0; i < blockedServers.length; i++ ){
if (blockedServers[i] == server.clientIdentifier){
console.log('Server: ' + server.name + ' is blocked - not searching')
blocked = true
}
}
}
if (blocked){
continue continue
} }
server.search(hostData.rawTitle, function (results, _server) { server.search(hostData.rawTitle, function (results, _server) {

View File

@ -1,10 +1,22 @@
<template> <template>
<div> <div>
<h6>Autoplay Plex Servers</h6> <h6>Blocked Plex Servers</h6>
<small>Used for autoplay functionality. Use this list to block PlexTogether from searching certain servers when attempting to autoplay content.</small> <small>Used for autoplay functionality. Use this list to block PlexTogether from searching certain servers when attempting to autoplay content.</small>
<div v-if="plex && plex.gotDevices && plex.servers"> <v-layout row wrap>
<v-switch v-for="server in checked" :key="server" :label="server.name" v-model="checked" :value="server" light warning></v-switch> <v-flex xs12>
</div> <v-select
label="Select"
v-bind:items="localServersList"
v-model="blockedServers"
item-value="id"
item-text="name"
multiple
light
hint="Blocked Servers"
persistent-hint
></v-select>
</v-flex>
</v-layout>
</div> </div>
</template> </template>
@ -14,57 +26,15 @@
name: 'plexsettings', name: 'plexsettings',
data () { data () {
return { return {
blockedServers: this.$store.getters.getSettingBLOCKEDSERVERS || []
} }
}, },
mounted() {
this.$nextTick(function() {
console.log('hey')
this.checked = this.getlocalServersList()
})
},
methods: { methods: {
updateServer(id,servername,value){
let storedSettings = this.$store.getters.getSettingBLOCKEDSERVERS || {}
if (storedSettings[id]){
// Server already exists in settings
storedSettings[id].enabled = value
} else {
storedSettings[id] = {
enabled: value,
name: servername,
id: id,
source: 'setting'
}
}
this.$store.commit('setSettingBLOCKEDSERVERS', storedSettings)
},
getlocalServersList () {
let servers = []
if (this.$store.getters.getSettingBLOCKEDSERVERS) {
for (let i in this.$store.getters.getSettingBLOCKEDSERVERS){
servers.push(this.$store.getters.getSettingBLOCKEDSERVERS[i])
}
}
console.log(this.$store.state.plex)
this.$store.state.plex.servers.forEach((server) => {
if (this.$store.getters.getSettingBLOCKEDSERVERS && this.$store.getters.getSettingBLOCKEDSERVERS[server.clientIdentifier]){
return
}
servers.push({
name: server.name,
id: server.clientIdentifier,
enabled: true,
source: 'api'
})
})
return servers
}
}, },
watch: { watch: {
plex: () => { blockedServers: function() {
console.log('Change') this.$store.commit('setSettingBLOCKEDSERVERS', this.blockedServers)
setTimeout(() => {
},25)
} }
}, },
computed: { computed: {
@ -74,47 +44,34 @@
context: function () { context: function () {
return this.$store return this.$store
}, },
logo: function () { localServersList: function() {
return 'static/plexlogo.png' let servers = []
}, if (!this.plex || !this.plex.servers){
checked: { return servers
get () { }
let servers = [] this.plex.servers.forEach((server) => {
if (this.$store.getters.getSettingBLOCKEDSERVERS) { if (this.$store.getters.getSettingBLOCKEDSERVERS && this.$store.getters.getSettingBLOCKEDSERVERS[server.clientIdentifier]){
for (let i in this.$store.getters.getSettingBLOCKEDSERVERS){
servers.push(this.$store.getters.getSettingBLOCKEDSERVERS[i])
}
}
this.$store.state.plex.servers.forEach((server) => {
if (this.$store.getters.getSettingBLOCKEDSERVERS && this.$store.getters.getSettingBLOCKEDSERVERS[server.clientIdentifier]){
return
}
servers.push({ servers.push({
name: server.name, name: server.name,
id: server.clientIdentifier, id: server.clientIdentifier,
enabled: true,
source: 'api'
}) })
}) return
return servers
},
set (newsettings) {
console.log(newsettings)
let storedSettings = this.$store.getters.getSettingBLOCKEDSERVERS || {}
if (storedSettings[id]){
// Server already exists in settings
storedSettings[id].enabled = value
} else {
storedSettings[id] = {
enabled: value,
name: servername,
id: id,
source: 'setting'
}
} }
//this.$store.commit('setSettingBLOCKEDSERVERS', storedSettings) servers.push({
} name: server.name,
id: server.clientIdentifier,
})
})
return servers
},
logo: function () {
return 'static/plexlogo.png'
}, },
}, },
mounted: function () {
// Create event listeners
}
} }
</script> </script>

View File

@ -14,55 +14,72 @@
:initialOffset="offset" :initialOffset="offset"
:createdAt="playerCreatedAt" :createdAt="playerCreatedAt"
></videoplayer> ></videoplayer>
<v-dialog> <v-dialog v-model="dialog">
<h2> Playback Settings </h2> <v-card>
<div v-if="playingMetadata && chosenServer" class="input-field col l12 s12 testDropdown"> <v-card-row>
<v-select name="select" <v-card-title>Playback Settings </v-card-title>
id="select" </v-card-row>
v-model="chosenMediaIndex" <v-card-row>
:items="mediaIndexSelect" <v-card-text>
></v-select>
<label for="select">Version</label> <v-select
</div> v-model="chosenQuality"
<div v-if="playingMetadata && chosenServer" class="input-field col l12 s12 testDropdown"> :items="qualitiesSelect"
<v-select name="select" light
id="select" item-text="text"
v-model="chosenQuality" item-value="id"
:items="qualitiesSelect" persistent-hint
></v-select> label="Quality"
<label for="select">Quality</label> hint="Select a different quality"
</div> ></v-select>
<div v-if="playingMetadata && chosenServer" class="input-field col l12 s12 testDropdown"> <v-select
<v-select name="select" v-model="chosenAudioTrackIndex"
id="select" :select-text="'Default'"
v-model="chosenAudioTrackIndex" label="Audio track"
:select-text="'Default'" item-text="text"
:items="audioTrackSelect" item-value="id"
></v-select> light
<label for="select">Audio</label> persistent-hint
</div> hint="Select a different audio track"
<div v-if="playingMetadata && chosenServer" class="input-field col l12 s12 testDropdown"> :items="audioTrackSelect"
<v-select name="select" ></v-select>
id="select" <v-select
v-model="chosenSubtitleIndex" light
:select-text="'Default'" persistent-hint
:items="subtitleTrackSelect" label="Subtitles"
></v-select> item-text="text"
<label for="select">Subtitles</label> item-value="id"
</div> hint="Select a different subtitle track"
<div class="row"> v-model="chosenSubtitleIndex"
<div class="col l12 s12"> :select-text="'Default'"
<v-btn class="center" style="background-color: #d32f2f" v-on:click.native="stopPlayback()">Stop playback :items="subtitleTrackSelect"
</v-btn> ></v-select>
</div> <v-select
</div> v-if="mediaIndexSelect.length > 1"
light
persistent-hint
item-text="text"
item-value="id"
hint="Select a different version of the content you're playing"
v-model="chosenMediaIndex"
label="Version"
:items="mediaIndexSelect"
></v-select>
</v-card-text>
</v-card-row>
<v-card-row actions>
<v-btn class="blue--text darken-1" flat @click.native="dialog = false">Close</v-btn>
</v-card-row>
</v-card>
</v-dialog> </v-dialog>
<div class="row" v-if="playingMetadata && chosenServer"> <v-layout v-if="playingMetadata && chosenServer" row justify-center>
<div class="col l4 offset-l4 s12 center" style="padding-top:1%"> <v-flex md2>
<v-btn class="center" style="background-color: #E5A00D" v-on:click.native="stopPlayback()">Stop playback <v-btn primary light v-on:click.native.stop="dialog = !dialog">Playback Settings</v-btn>
</v-btn> </v-flex>
</div> <v-flex md2>
</div> <v-btn error light v-on:click.native="stopPlayback()">Stop playback</v-btn>
</v-flex>
</v-layout>
</div> </div>
</template> </template>
@ -196,7 +213,8 @@
transcodeSessionMetadata: {}, transcodeSessionMetadata: {},
// Browser // Browser
browser: this.getBrowser() browser: this.getBrowser(),
dialog: false
} }
}, },
watch: { watch: {

View File

@ -633,12 +633,15 @@ const plexTogether = {
state.decisionBlocked = true state.decisionBlocked = true
let blockedServers = rootState.BLOCKEDSERVERS let blockedServers = rootState.BLOCKEDSERVERS
let validServers = 0 let validServers = rootState.plex.servers.length
for (let i in blockedServers){ if (blockedServers){
if (blockedServers[i].enabled){ for (let i = 0; i < blockedServers.length; i++ ){
validServers++ if (rootState.plex.getServerById(blockedServers[i])){
validServers--
}
} }
} }
sendNotification('Searching ' + validServers + ' Plex Servers for "' + hostTimeline.rawTitle + '"') sendNotification('Searching ' + validServers + ' Plex Servers for "' + hostTimeline.rawTitle + '"')
rootState.plex.playContentAutomatically(rootState.chosenClient, hostTimeline, blockedServers, function (result) { rootState.plex.playContentAutomatically(rootState.chosenClient, hostTimeline, blockedServers, function (result) {
console.log('Auto play result: ' + result) console.log('Auto play result: ' + result)