Follow up for audio subs pref

This commit is contained in:
angelblue05 2015-06-11 03:17:48 -05:00
parent 983978dc33
commit 4d28f2a878
2 changed files with 18 additions and 5 deletions

View file

@ -43,8 +43,8 @@ class Player( xbmc.Player ):
settings = None settings = None
playStats = {} playStats = {}
audioPref = addon.getSetting('Audiopref') audioPref = "default"
subsPref = addon.getSetting('Subspref') subsPref = "default"
def __init__( self, *args ): def __init__( self, *args ):
@ -54,7 +54,11 @@ class Player( xbmc.Player ):
def logMsg(self, msg, lvl=1): def logMsg(self, msg, lvl=1):
self.className = self.__class__.__name__ self.className = self.__class__.__name__
utils.logMsg("%s %s" % (self.addonName, self.className), msg, int(lvl)) utils.logMsg("%s %s" % (self.addonName, self.className), msg, int(lvl))
def setAudioSubsPref(self, audio, subs):
self.audioPref = audio
self.subsPref = subs
def hasData(self, data): def hasData(self, data):
if(data == None or len(data) == 0 or data == "None"): if(data == None or len(data) == 0 or data == "None"):
@ -223,7 +227,6 @@ class Player( xbmc.Player ):
def onPlayBackStarted( self ): def onPlayBackStarted( self ):
# Will be called when xbmc starts playing a file # Will be called when xbmc starts playing a file
WINDOW = self.WINDOW WINDOW = self.WINDOW
self.addon = xbmcaddon.Addon(id=self.addonId)
addon = self.addon addon = self.addon
xbmcplayer = self.xbmcplayer xbmcplayer = self.xbmcplayer
self.stopAll() self.stopAll()
@ -240,9 +243,14 @@ class Player( xbmc.Player ):
# Set audio and subtitles automatically # Set audio and subtitles automatically
# Following Emby user preference. # Following Emby user preference.
if playMethod == "DirectPlay" or playMethod == "DirectStream": if self.audioPref == "default" and self.subsPref == "default":
self.logMsg("No Emby user preferences found.", 2)
# Emby user preferences are not set.
pass
elif playMethod == "DirectPlay" or playMethod == "DirectStream":
# Only currently compatible with DirectPlay. # Only currently compatible with DirectPlay.
# Tested on plugin://, unsure about direct paths. # Tested on plugin://, unsure about direct paths.
self.logMsg("Audio Pref: %s Subtitles Pref: %s" % (self.audioPref, self.subsPref), 1)
audiotracks = xbmcplayer.getAvailableAudioStreams() audiotracks = xbmcplayer.getAvailableAudioStreams()
subs = xbmcplayer.getAvailableSubtitleStreams() subs = xbmcplayer.getAvailableSubtitleStreams()
self.logMsg("%s %s" % (audiotracks, subs), 1) self.logMsg("%s %s" % (audiotracks, subs), 1)

View file

@ -15,6 +15,7 @@ import KodiMonitor
import Utils as utils import Utils as utils
from ClientInformation import ClientInformation from ClientInformation import ClientInformation
from DownloadUtils import DownloadUtils from DownloadUtils import DownloadUtils
from Player import Player
class UserClient(threading.Thread): class UserClient(threading.Thread):
@ -152,6 +153,7 @@ class UserClient(threading.Thread):
def setUserPref(self): def setUserPref(self):
player = Player()
server = self.getServer() server = self.getServer()
userId = self.getUserId() userId = self.getUserId()
addon = self.addon addon = self.addon
@ -164,6 +166,9 @@ class UserClient(threading.Thread):
addon.setSetting('Audiopref', audio) addon.setSetting('Audiopref', audio)
addon.setSetting('Subspref', subs) addon.setSetting('Subspref', subs)
# Set the setting in Player
player.setAudioSubsPref(audio.encode('utf-8'), subs.encode('utf-8'))
self.logMsg("Audio preference: %s" % audio, 2) self.logMsg("Audio preference: %s" % audio, 2)
self.logMsg("Subtitles preference: %s" % subs, 2) self.logMsg("Subtitles preference: %s" % subs, 2)