changed playback a bit
This commit is contained in:
parent
702eec810a
commit
f6cd5c9744
5 changed files with 74 additions and 31 deletions
|
@ -27,10 +27,8 @@ except:
|
|||
id=None
|
||||
|
||||
if mode != None and mode == "play":
|
||||
pass
|
||||
#PlaybackUtils().PLAY(id)
|
||||
#WINDOW.setProperty('GUIPLAY', str(id)) # set window prop
|
||||
#xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, None)
|
||||
xbmcplugin.endOfDirectory(int(sys.argv[1]),True,False,True)
|
||||
WINDOW.setProperty('GUIPLAY', str(id)) # set window prop
|
||||
elif sys.argv[1] == "reset":
|
||||
utils.reset()
|
||||
else:
|
||||
|
|
|
@ -149,19 +149,23 @@ class DownloadUtils():
|
|||
|
||||
self.logMsg("=== ENTER downloadUrl ===", 2)
|
||||
|
||||
WINDOW = self.WINDOW
|
||||
WINDOW = xbmcgui.Window( 10000 )
|
||||
timeout = self.timeout
|
||||
default_link = ""
|
||||
|
||||
username = WINDOW.getProperty('currUser')
|
||||
userId = WINDOW.getProperty('userId%s' % username)
|
||||
server = WINDOW.getProperty('server%s' % username)
|
||||
url = url.replace("{server}", server, 1)
|
||||
url = url.replace("{UserId}", userId, 1)
|
||||
#url = "%s&api_key=%s" % (url, self.token)
|
||||
|
||||
# If user is authenticated
|
||||
if (authenticate):
|
||||
# Get requests session
|
||||
s = self.s
|
||||
# Replace for the real values and append api_key
|
||||
url = url.replace("{server}", self.server, 1)
|
||||
url = url.replace("{UserId}", self.userId, 1)
|
||||
#url = "%s&api_key=%s" % (url, self.token)
|
||||
|
||||
|
||||
self.logMsg("URL: %s" % url, 2)
|
||||
# Prepare request
|
||||
if type == "GET":
|
||||
|
|
|
@ -53,8 +53,57 @@ class Kodi_Monitor(xbmc.Monitor):
|
|||
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % embyid
|
||||
result = downloadUtils.downloadUrl(url)
|
||||
|
||||
#launch playbackutils
|
||||
PlaybackUtils().PLAY(result)
|
||||
userData = result[u'UserData']
|
||||
|
||||
playurl = PlayUtils().getPlayUrl(server, embyid, result)
|
||||
thumbPath = API().getArtwork(result, "Primary")
|
||||
|
||||
watchedurl = "%s/mediabrowser/Users/%s/PlayedItems/%s" % (server, userid, embyid)
|
||||
positionurl = "%s/mediabrowser/Users/%s/PlayingItems/%s" % (server, userid, embyid)
|
||||
deleteurl = "%s/mediabrowser/Items/%s" % (server, embyid)
|
||||
|
||||
listItem = xbmcgui.ListItem(path=playurl, iconImage=thumbPath, thumbnailImage=thumbPath)
|
||||
self.setListItemProps(server, id, listItem, result)
|
||||
|
||||
# Can not play virtual items
|
||||
if (result.get("LocationType") == "Virtual"):
|
||||
xbmcgui.Dialog().ok(self.language(30128), self.language(30129))
|
||||
|
||||
# set the current playing info
|
||||
WINDOW.setProperty(playurl+"watchedurl", watchedurl)
|
||||
WINDOW.setProperty(playurl+"positionurl", positionurl)
|
||||
WINDOW.setProperty(playurl+"deleteurl", "")
|
||||
WINDOW.setProperty(playurl+"deleteurl", deleteurl)
|
||||
if result[u'Type']=="Episode":
|
||||
WINDOW.setProperty(playurl+"refresh_id", result[u'SeriesId'])
|
||||
else:
|
||||
WINDOW.setProperty(playurl+"refresh_id", embyid)
|
||||
|
||||
WINDOW.setProperty(playurl+"runtimeticks", str(result[u'RunTimeTicks']))
|
||||
WINDOW.setProperty(playurl+"type", result[u'Type'])
|
||||
WINDOW.setProperty(playurl+"item_id", embyid)
|
||||
|
||||
if PlayUtils().isDirectPlay(result) == True:
|
||||
playMethod = "DirectPlay"
|
||||
else:
|
||||
playMethod = "Transcode"
|
||||
|
||||
WINDOW.setProperty(playurl+"playmethod", playMethod)
|
||||
|
||||
if result.get("Type")=="Episode":
|
||||
WINDOW.setProperty(playurl+"refresh_id", result.get("SeriesId"))
|
||||
else:
|
||||
WINDOW.setProperty(playurl+"refresh_id", id)
|
||||
|
||||
mediaSources = result[u'MediaSources']
|
||||
if(mediaSources != None):
|
||||
if mediaSources[0].get('DefaultAudioStreamIndex') != None:
|
||||
WINDOW.setProperty(playurl+"AudioStreamIndex", str(mediaSources[0][u'DefaultAudioStreamIndex']))
|
||||
if mediaSources[0].get('DefaultSubtitleStreamIndex') != None:
|
||||
WINDOW.setProperty(playurl+"SubtitleStreamIndex", str(mediaSources[0][u'DefaultSubtitleStreamIndex']))
|
||||
|
||||
# start the playback
|
||||
PlaybackUtils().PLAY(id)
|
||||
|
||||
if method == "VideoLibrary.OnUpdate":
|
||||
jsondata = json.loads(data)
|
||||
|
|
|
@ -62,22 +62,8 @@ class PlaybackUtils():
|
|||
# seekTime = int(round(kodiItem['resume'].get("position")))
|
||||
|
||||
playurl = PlayUtils().getPlayUrl(server, id, result)
|
||||
|
||||
isStrmFile = False
|
||||
thumbPath = API().getArtwork(result, "Primary")
|
||||
|
||||
#workaround for when the file to play is a strm file itself
|
||||
if playurl.endswith(".strm"):
|
||||
isStrmFile = True
|
||||
tempPath = os.path.join(addondir,"library","temp.strm")
|
||||
xbmcvfs.copy(playurl, tempPath)
|
||||
sfile = open(tempPath, 'r')
|
||||
playurl = sfile.readline()
|
||||
sfile.close()
|
||||
xbmcvfs.delete(tempPath)
|
||||
WINDOW.setProperty("virtualstrm", id)
|
||||
WINDOW.setProperty("virtualstrmtype", result.get("Type"))
|
||||
|
||||
listItem = xbmcgui.ListItem(path=playurl, iconImage=thumbPath, thumbnailImage=thumbPath)
|
||||
self.setListItemProps(server, id, listItem, result)
|
||||
|
||||
|
@ -130,9 +116,7 @@ class PlaybackUtils():
|
|||
if mediaSources[0].get('DefaultSubtitleStreamIndex') != None:
|
||||
WINDOW.setProperty(playurl+"SubtitleStreamIndex", str(mediaSources[0].get('DefaultSubtitleStreamIndex')))
|
||||
|
||||
#this launches the playback
|
||||
#artwork only works with both resolvedurl and player command
|
||||
#xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem)
|
||||
#launch the playback
|
||||
xbmc.Player().play(playurl,listItem)
|
||||
|
||||
def setArt(self, list,name,path):
|
||||
|
|
14
service.py
14
service.py
|
@ -68,11 +68,19 @@ class Service():
|
|||
if self.KodiMonitor.waitForAbort(1):
|
||||
# Abort was requested while waiting. We should exit
|
||||
break
|
||||
|
||||
|
||||
#detection that file needs to be playback
|
||||
if WINDOW.getProperty("GUIPLAY") != "":
|
||||
downloadUtils = DownloadUtils()
|
||||
id = WINDOW.getProperty("GUIPLAY")
|
||||
WINDOW.setProperty("GUIPLAY", "")
|
||||
PlaybackUtils().PLAY(id)
|
||||
WINDOW = xbmcgui.Window( 10000 )
|
||||
username = WINDOW.getProperty('currUser')
|
||||
userid = WINDOW.getProperty('userId%s' % username)
|
||||
server = WINDOW.getProperty('server%s' % username)
|
||||
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % id
|
||||
result = downloadUtils.downloadUrl(url)
|
||||
PlaybackUtils().PLAY(result)
|
||||
|
||||
if xbmc.Player().isPlaying():
|
||||
try:
|
||||
|
@ -122,7 +130,7 @@ class Service():
|
|||
if(libSync):
|
||||
startupComplete = True
|
||||
else:
|
||||
if self.KodiMonitor.waitForAbort(10):
|
||||
if self.KodiMonitor.waitForAbort(1):
|
||||
# Abort was requested while waiting. We should exit
|
||||
break
|
||||
WebSocketThread().processPendingActions()
|
||||
|
|
Loading…
Reference in a new issue