Always direct play items, if possible

This commit is contained in:
tomkat83 2016-04-11 18:57:20 +02:00
parent b9016a0acd
commit 4ca321faea
2 changed files with 32 additions and 24 deletions

View file

@ -1226,7 +1226,7 @@ class API():
or None or None
""" """
try: try:
res = self.item[0][0].attrib.get('file') res = self.item[0][self.part].attrib.get('file')
except: except:
res = None res = None
if res: if res:
@ -1869,7 +1869,7 @@ class API():
Transcode Video support; returns the URL to get a media started Transcode Video support; returns the URL to get a media started
Input: Input:
action 'DirectPlay', 'DirectStream' or 'Transcode' action 'DirectStream' or 'Transcode'
quality: { quality: {
'videoResolution': e.g. '1024x768', 'videoResolution': e.g. '1024x768',
@ -1885,7 +1885,7 @@ class API():
xargs = clientinfo.ClientInfo().getXArgsDeviceInfo() xargs = clientinfo.ClientInfo().getXArgsDeviceInfo()
# For DirectPlay, path/key of PART is needed # For DirectPlay, path/key of PART is needed
if action == "DirectPlay": if action == "DirectStream":
path = self.item[0][self.part].attrib['key'] path = self.item[0][self.part].attrib['key']
url = self.server + path url = self.server + path
# e.g. Trailers already feature an '?'! # e.g. Trailers already feature an '?'!

View file

@ -41,21 +41,19 @@ class PlayUtils():
window = utils.window window = utils.window
self.API.setPartNumber(partNumber) self.API.setPartNumber(partNumber)
playurl = None playurl = self.isDirectPlay()
if self.isDirectPlay(): if playurl:
log("File is direct playing.", 1) log("File is direct playing.", 1)
playurl = self.API.getTranscodeVideoPath('DirectPlay')
playurl = playurl.encode('utf-8') playurl = playurl.encode('utf-8')
# Set playmethod property # Set playmethod property
window('emby_%s.playmethod' % playurl, "DirectPlay") window('emby_%s.playmethod' % playurl, "DirectPlay")
# Currently no direct streaming possible - needs investigation elif self.isDirectStream():
# elif self.isDirectStream(): self.logMsg("File is direct streaming.", 1)
# self.logMsg("File is direct streaming.", 1) playurl = self.API.getTranscodeVideoPath('DirectStream').encode('utf-8')
# playurl = self.API.getTranscodeVideoPath('DirectStream') # Set playmethod property
# # Set playmethod property utils.window('emby_%s.playmethod' % playurl, "DirectStream")
# utils.window('emby_%s.playmethod' % playurl, "DirectStream")
elif self.isTranscoding(): elif self.isTranscoding():
log("File is transcoding.", 1) log("File is transcoding.", 1)
@ -64,9 +62,9 @@ class PlayUtils():
'videoResolution': self.getResolution(), 'videoResolution': self.getResolution(),
'videoQuality': '100' 'videoQuality': '100'
} }
playurl = self.API.getTranscodeVideoPath('Transcode', playurl = self.API.getTranscodeVideoPath(
quality=quality) 'Transcode',
playurl = playurl.encode('utf-8') quality=quality).encode('utf-8')
# Set playmethod property # Set playmethod property
window('emby_%s.playmethod' % playurl, value="Transcode") window('emby_%s.playmethod' % playurl, value="Transcode")
@ -89,6 +87,9 @@ class PlayUtils():
return playurl return playurl
def isDirectPlay(self): def isDirectPlay(self):
"""
Returns the path/playurl if successful, False otherwise
"""
# Requirement: Filesystem, Accessible path # Requirement: Filesystem, Accessible path
if utils.settings('playFromStream') == "true": if utils.settings('playFromStream') == "true":
@ -99,7 +100,22 @@ class PlayUtils():
if self.h265enabled(): if self.h265enabled():
return False return False
return True path = self.API.getFilePath()
# Assign network protocol
if path.startswith('\\\\'):
path = path.replace('\\\\', 'smb://')
path = path.replace('\\', '/')
# Plex returns Windows paths as e.g. 'c:\slfkjelf\slfje\file.mkv'
elif '\\' in path:
path = path.replace('\\', '\\\\')
if xbmcvfs.exists(path):
self.logMsg('Kodi can access file %s - direct playing' % path, 2)
return path
else:
self.logMsg('Kodi cannot access file %s - no direct play'
% path, 2)
return False
def directPlay(self): def directPlay(self):
@ -182,14 +198,6 @@ class PlayUtils():
if not self.h265enabled(): if not self.h265enabled():
return False return False
# Requirement: BitRate, supported encoding
# canDirectStream = item['MediaSources'][0]['SupportsDirectStream']
# Plex: always able?!?
canDirectStream = True
# Make sure the server supports it
if not canDirectStream:
return False
# Verify the bitrate # Verify the bitrate
if not self.isNetworkSufficient(): if not self.isNetworkSufficient():
self.logMsg( self.logMsg(