Take into account item type for direct stream

Video and audio
This commit is contained in:
angelblue05 2015-08-20 09:15:37 -05:00
parent e24d982c36
commit 53fbbffa75
3 changed files with 11 additions and 14 deletions

View file

@ -204,7 +204,7 @@ def getThemeMedia():
if playback == "DirectPlay": if playback == "DirectPlay":
playurl = playUtils.directPlay(theme) playurl = playUtils.directPlay(theme)
else: else:
playurl = playUtils.directStream(result, server, theme[u'Id'], "ThemeVideo") playurl = playUtils.directStream(result, server, theme[u'Id'], "Video")
pathstowrite += ('<file>%s</file>' % playurl.encode('utf-8')) pathstowrite += ('<file>%s</file>' % playurl.encode('utf-8'))
# Check if the item has theme songs and add them # Check if the item has theme songs and add them

View file

@ -31,12 +31,17 @@ class PlayUtils():
className = self.__class__.__name__ className = self.__class__.__name__
utils.logMsg("%s %s" % (self.addonName, className), msg, int(lvl)) utils.logMsg("%s %s" % (self.addonName, className), msg, int(lvl))
def getPlayUrl(self, server, id, result): def getPlayUrl(self, server, id, result, type):
WINDOW = self.WINDOW WINDOW = self.WINDOW
username = WINDOW.getProperty('currUser') username = WINDOW.getProperty('currUser')
server = WINDOW.getProperty('server%s' % username) server = WINDOW.getProperty('server%s' % username)
if "Audio" in type:
type = "Audio"
else:
type = "Video"
if self.isDirectPlay(result,True): if self.isDirectPlay(result,True):
# Try direct play # Try direct play
playurl = self.directPlay(result) playurl = self.directPlay(result)
@ -46,7 +51,7 @@ class PlayUtils():
elif self.isDirectStream(result): elif self.isDirectStream(result):
# Try direct stream # Try direct stream
playurl = self.directStream(result, server, id) playurl = self.directStream(result, server, id, type)
if playurl: if playurl:
self.logMsg("File is direct streaming.", 1) self.logMsg("File is direct streaming.", 1)
WINDOW.setProperty("%splaymethod" % playurl, "DirectStream") WINDOW.setProperty("%splaymethod" % playurl, "DirectStream")
@ -161,18 +166,9 @@ class PlayUtils():
def directStream(self, result, server, id, type = "Video"): def directStream(self, result, server, id, type = "Video"):
try: try:
if "ThemeVideo" in type: if "Video" in type:
playurl ="%s/mediabrowser/Videos/%s/stream?static=true" % (server, id) playurl ="%s/mediabrowser/Videos/%s/stream?static=true" % (server, id)
elif "Video" in type:
playurl = "%s/mediabrowser/Videos/%s/stream?static=true" % (server, id)
# Verify audio and subtitles
mediaSources = result[u'MediaSources']
if mediaSources[0].get('DefaultAudioStreamIndex') != None:
playurl = "%s&AudioStreamIndex=%s" % (playurl, mediaSources[0].get('DefaultAudioStreamIndex'))
if mediaSources[0].get('DefaultSubtitleStreamIndex') != None:
playurl = "%s&SubtitleStreamIndex=%s" % (playurl, mediaSources[0].get('DefaultSubtitleStreamIndex'))
elif "Audio" in type: elif "Audio" in type:
playurl = "%s/mediabrowser/Audio/%s/stream.mp3" % (server, id) playurl = "%s/mediabrowser/Audio/%s/stream.mp3" % (server, id)

View file

@ -46,6 +46,7 @@ class PlaybackUtils():
try: try:
id = result["Id"] id = result["Id"]
type = result['Type']
except: except:
return return
@ -90,7 +91,7 @@ class PlaybackUtils():
# Let's play the playlist # Let's play the playlist
return self.AddToPlaylist(itemsToPlay) return self.AddToPlaylist(itemsToPlay)
playurl = PlayUtils().getPlayUrl(server, id, result) playurl = PlayUtils().getPlayUrl(server, id, result, type)
if playurl == False or WINDOW.getProperty('playurlFalse') == "true": if playurl == False or WINDOW.getProperty('playurlFalse') == "true":
WINDOW.clearProperty('playurlFalse') WINDOW.clearProperty('playurlFalse')
xbmc.log("Failed to retrieve the playback path/url.") xbmc.log("Failed to retrieve the playback path/url.")