Prefer a subtitle/audio track for series
This commit is contained in:
parent
cedad518b1
commit
832450755b
|
@ -196,8 +196,8 @@
|
||||||
// Below are options chosen for each copy
|
// Below are options chosen for each copy
|
||||||
chosenMediaIndex: 0, // The index of the item we want to play
|
chosenMediaIndex: 0, // The index of the item we want to play
|
||||||
chosenQuality: JSON.parse(window['localStorage'].getItem('PTPLAYERQUALITY')) || 'Original', // The quality profile
|
chosenQuality: JSON.parse(window['localStorage'].getItem('PTPLAYERQUALITY')) || 'Original', // The quality profile
|
||||||
chosenSubtitleIndex: 0, // Subtitle track index
|
chosenSubtitleIndex: null, // Subtitle track index
|
||||||
chosenAudioTrackIndex: 0, // Audio track index
|
chosenAudioTrackIndex: null, // Audio track index
|
||||||
sources: [],
|
sources: [],
|
||||||
|
|
||||||
// Player status
|
// Player status
|
||||||
|
@ -230,12 +230,26 @@
|
||||||
this.$store.commit('setSettingPTPLAYERQUALITY',this.chosenQuality)
|
this.$store.commit('setSettingPTPLAYERQUALITY',this.chosenQuality)
|
||||||
},
|
},
|
||||||
chosenMediaIndex: function () {
|
chosenMediaIndex: function () {
|
||||||
|
|
||||||
this.chosenSubtitleIndex = 0
|
this.chosenSubtitleIndex = 0
|
||||||
this.chosenAudioTrackIndex = 0
|
this.chosenAudioTrackIndex = 0
|
||||||
this.changedPlaying(false)
|
this.changedPlaying(false)
|
||||||
},
|
},
|
||||||
chosenAudioTrackIndex: function () {
|
chosenAudioTrackIndex: function () {
|
||||||
//console.log('Audio track change')
|
|
||||||
|
if (!this.chosenAudioTrackIndex){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.log('Audio track change')
|
||||||
|
if (this.playingMetadata && this.playingMetadata.type == 'episode') {
|
||||||
|
// We should save this preference for this series in our localStorage
|
||||||
|
|
||||||
|
let seriesKey = this.playingMetadata.grandparentKey
|
||||||
|
let languageCode = this.playingMetadata.Media[this.chosenMediaIndex].Part[0].Stream[this.chosenAudioTrackIndex].languageCode
|
||||||
|
console.log('Our prefered audio track for ' + seriesKey + ' is now ' + languageCode)
|
||||||
|
this.savePrefence('audio',seriesKey,languageCode)
|
||||||
|
|
||||||
|
}
|
||||||
var that = this
|
var that = this
|
||||||
let audioStreamID = this.playingMetadata.Media[this.chosenMediaIndex].Part[0].Stream[this.chosenAudioTrackIndex].id
|
let audioStreamID = this.playingMetadata.Media[this.chosenMediaIndex].Part[0].Stream[this.chosenAudioTrackIndex].id
|
||||||
let baseparams = this.getSourceByLabel(this.chosenQuality).params
|
let baseparams = this.getSourceByLabel(this.chosenQuality).params
|
||||||
|
@ -271,6 +285,19 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
chosenSubtitleIndex: function () {
|
chosenSubtitleIndex: function () {
|
||||||
|
if (!this.chosenSubtitleIndex){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.log('Audio track change')
|
||||||
|
if (this.playingMetadata && this.playingMetadata.type == 'episode') {
|
||||||
|
// We should save this preference for this series in our localStorage
|
||||||
|
|
||||||
|
let seriesKey = this.playingMetadata.grandparentKey
|
||||||
|
let languageCode = this.playingMetadata.Media[this.chosenMediaIndex].Part[0].Stream[this.chosenSubtitleIndex].languageCode
|
||||||
|
console.log('Our prefered subtitle track for ' + seriesKey + ' is now ' + languageCode)
|
||||||
|
this.savePrefence('subs',seriesKey,languageCode)
|
||||||
|
|
||||||
|
}
|
||||||
//console.log('Subtitle track change')
|
//console.log('Subtitle track change')
|
||||||
var that = this
|
var that = this
|
||||||
let subtitleStreamID = 0
|
let subtitleStreamID = 0
|
||||||
|
@ -350,7 +377,22 @@
|
||||||
text: current.language + ' (' + current.codec + ' ' + current.audioChannelLayout + ')'
|
text: current.language + ' (' + current.codec + ' ' + current.audioChannelLayout + ')'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return audioTracks
|
||||||
|
},
|
||||||
|
audioTracks () {
|
||||||
|
let audioTracks = []
|
||||||
|
if (!this.playingMetadata) {
|
||||||
|
return audioTracks
|
||||||
|
}
|
||||||
|
if (this.playingMetadata.Media[this.chosenMediaIndex].Part[0].Stream.length == 1) {
|
||||||
|
return audioTracks
|
||||||
|
}
|
||||||
|
for (let i = 0; i < this.playingMetadata.Media[this.chosenMediaIndex].Part[0].Stream.length; i++) {
|
||||||
|
let current = this.playingMetadata.Media[this.chosenMediaIndex].Part[0].Stream[i]
|
||||||
|
if (current.streamType == 2) {
|
||||||
|
audioTracks.push(current)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return audioTracks
|
return audioTracks
|
||||||
},
|
},
|
||||||
|
@ -376,7 +418,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return subtitleTracks
|
||||||
|
},
|
||||||
|
subtitleTracks () {
|
||||||
|
let subtitleTracks = []
|
||||||
|
if (!this.playingMetadata) {
|
||||||
|
return subtitleTracks
|
||||||
|
}
|
||||||
|
if (this.playingMetadata.Media[this.chosenMediaIndex].Part[0].Stream.length == 1) {
|
||||||
|
return subtitleTracks
|
||||||
|
}
|
||||||
|
for (let i = 0; i < this.playingMetadata.Media[this.chosenMediaIndex].Part[0].Stream.length; i++) {
|
||||||
|
let current = this.playingMetadata.Media[this.chosenMediaIndex].Part[0].Stream[i]
|
||||||
|
if (current.streamType == 3) {
|
||||||
|
subtitleTracks.push(current)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return subtitleTracks
|
return subtitleTracks
|
||||||
},
|
},
|
||||||
qualitiesSelect () {
|
qualitiesSelect () {
|
||||||
|
@ -404,9 +462,59 @@
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
|
getInitAudioTrackIndex: function (){
|
||||||
|
console.log('Fetching audio track')
|
||||||
|
// Load preferences from file
|
||||||
|
if (!this.playingMetadata || this.playingMetadata.type != 'episode'){
|
||||||
|
console.log('Error with playingMetadata or content type when fetching audio track preference')
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
let prefLanguage = this.getPreference('audio',this.playingMetadata.grandparentKey)
|
||||||
|
console.log('Our audio preference for this series is ' + prefLanguage)
|
||||||
|
let tracks = this.playingMetadata.Media[this.chosenMediaIndex].Part[0].Stream
|
||||||
|
console.log('Tracks: ', tracks)
|
||||||
|
for (let i = 0; i < tracks.length; i++){
|
||||||
|
if (prefLanguage == tracks[i].languageCode && tracks[i].streamType == 2){
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('No preference for ' + this.playingMetadata.grandparentKey)
|
||||||
|
},
|
||||||
|
getInitSubtitleTrackIndex: function (){
|
||||||
|
console.log('Fetching subtitle track')
|
||||||
|
// Load preferences from file
|
||||||
|
if (!this.playingMetadata || this.playingMetadata.type != 'episode'){
|
||||||
|
console.log('Error with playingMetadata or content type when fetching subtitle track preference', this.playingMetadata.type, this.playingMetadata)
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
let tracks = this.playingMetadata.Media[this.chosenMediaIndex].Part[0].Stream
|
||||||
|
let prefLanguage = this.getPreference('subs',this.playingMetadata.grandparentKey)
|
||||||
|
console.log('Our subtitle preference for this series is ' + prefLanguage)
|
||||||
|
for (let i = 0; i < tracks.length; i++){
|
||||||
|
if (prefLanguage == tracks[i].languageCode && tracks[i].streamType == 3){
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('No preference for ' + this.playingMetadata.grandparentKey)
|
||||||
|
},
|
||||||
openModal () {
|
openModal () {
|
||||||
return this.$refs.playersettingsModal.open()
|
return this.$refs.playersettingsModal.open()
|
||||||
},
|
},
|
||||||
|
savePrefence (type, ratingKey, preference){
|
||||||
|
let oldSettings = JSON.parse(localStorage.getItem('PTPLAYERPREFS-' + type))
|
||||||
|
if (!oldSettings){
|
||||||
|
oldSettings = {}
|
||||||
|
}
|
||||||
|
oldSettings[ratingKey] = preference
|
||||||
|
localStorage.setItem('PTPLAYERPREFS-' + type, JSON.stringify(oldSettings))
|
||||||
|
},
|
||||||
|
getPreference (type, ratingKey){
|
||||||
|
let oldSettings = JSON.parse(localStorage.getItem('PTPLAYERPREFS-' + type))
|
||||||
|
if (!oldSettings){
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return oldSettings[ratingKey]
|
||||||
|
},
|
||||||
generateSources () {
|
generateSources () {
|
||||||
var that = this
|
var that = this
|
||||||
let qualityTemplate = function (label, resolution, bitrate, videoQuality) {
|
let qualityTemplate = function (label, resolution, bitrate, videoQuality) {
|
||||||
|
@ -478,18 +586,27 @@
|
||||||
|
|
||||||
function req () {
|
function req () {
|
||||||
that.sources = that.generateSources()
|
that.sources = that.generateSources()
|
||||||
request(that.getSourceByLabel(that.chosenQuality).initUrl, function (error, response, body) {
|
var options = {
|
||||||
parseXMLString(body, function (err, result) {
|
headers: {
|
||||||
|
accept: 'application/json'
|
||||||
|
},
|
||||||
|
url: that.getSourceByLabel(that.chosenQuality).initUrl
|
||||||
|
}
|
||||||
|
request(options, function (error, response, body) {
|
||||||
|
if (error){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
that.ready = true
|
||||||
|
that.transcodeSessionMetadata = body
|
||||||
|
/*parseXMLString(body, function (err, result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
that.ready = false
|
that.ready = false
|
||||||
}
|
}
|
||||||
that.ready = true
|
|
||||||
that.transcodeSessionMetadata = result
|
|
||||||
|
|
||||||
})
|
})
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
|
||||||
}
|
}*/
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,9 +617,13 @@
|
||||||
}
|
}
|
||||||
if (changeItem) {
|
if (changeItem) {
|
||||||
this.playingMetadata = null
|
this.playingMetadata = null
|
||||||
this.chosenServer.getMediaByRatingKey(this.chosenKey, function (result) {
|
this.chosenServer.getMediaByRatingKey(this.chosenKey, (result) => {
|
||||||
//console.log(result)
|
//console.log(result)
|
||||||
that.playingMetadata = result
|
this.playingMetadata = result
|
||||||
|
this.chosenAudioTrackIndex = this.getInitAudioTrackIndex()
|
||||||
|
this.chosenSubtitleIndex = this.getInitSubtitleTrackIndex()
|
||||||
|
|
||||||
|
|
||||||
req()
|
req()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
@ -573,7 +694,7 @@
|
||||||
location = 'lan'
|
location = 'lan'
|
||||||
}
|
}
|
||||||
let params = {
|
let params = {
|
||||||
hasMDE: 1,
|
hasMDE: 0,
|
||||||
path: this.playingMetadata.key,
|
path: this.playingMetadata.key,
|
||||||
mediaIndex: this.chosenMediaIndex,
|
mediaIndex: this.chosenMediaIndex,
|
||||||
partIndex: 0,
|
partIndex: 0,
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
props: ['server', 'metadata', 'initialOffset', 'src', 'initUrl', 'stopUrl', 'params', 'sources'],
|
props: ['server', 'metadata', 'initialOffset', 'src', 'initUrl', 'stopUrl', 'params', 'sources'],
|
||||||
created () {
|
created () {
|
||||||
|
|
||||||
|
},
|
||||||
|
beforeDestroy: function(){
|
||||||
|
this.$store.commit('SET_DECISIONBLOCKED', false)
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
@ -397,7 +400,6 @@
|
||||||
console.log(player)
|
console.log(player)
|
||||||
},
|
},
|
||||||
playerStateChanged (playerCurrentState) {
|
playerStateChanged (playerCurrentState) {
|
||||||
console.log("Setting volume to " + this.player.volume() || 0)
|
|
||||||
this.$store.commit('setSettingPTPLAYERVOLUME', this.player.volume() || 0)
|
this.$store.commit('setSettingPTPLAYERVOLUME', this.player.volume() || 0)
|
||||||
this.bufferedTill = Math.round(this.player.buffered().end(0) * 1000)
|
this.bufferedTill = Math.round(this.player.buffered().end(0) * 1000)
|
||||||
this.duration = Math.round(this.player.duration() * 1000)
|
this.duration = Math.round(this.player.duration() * 1000)
|
||||||
|
|
|
@ -271,6 +271,7 @@ const mutations = {
|
||||||
state.blockAutoPlay = value
|
state.blockAutoPlay = value
|
||||||
},
|
},
|
||||||
SET_DECISIONBLOCKED (state, value) {
|
SET_DECISIONBLOCKED (state, value) {
|
||||||
|
console.log('Setting decisionBlocked to ' + value)
|
||||||
state.decisionBlocked = value
|
state.decisionBlocked = value
|
||||||
},
|
},
|
||||||
REFRESH_PLEXDEVICES (state) {
|
REFRESH_PLEXDEVICES (state) {
|
||||||
|
|
Loading…
Reference in New Issue