mirror of
https://github.com/jellyfin/jellycon.git
synced 2024-11-27 16:20:44 +00:00
use the xbmc player to play back item from remote websocketr calls
This commit is contained in:
parent
9af636251e
commit
17bfdae660
@ -7,11 +7,14 @@ import xbmcaddon
|
||||
import json
|
||||
import threading
|
||||
import websocket
|
||||
import time
|
||||
|
||||
from clientinfo import ClientInformation
|
||||
from downloadutils import DownloadUtils
|
||||
from simple_logging import SimpleLogging
|
||||
from utils import PlayUtils
|
||||
|
||||
downloadUtils = DownloadUtils()
|
||||
log = SimpleLogging("EmbyCon." + __name__)
|
||||
|
||||
class WebSocketThread(threading.Thread):
|
||||
@ -115,23 +118,56 @@ class WebSocketThread(threading.Thread):
|
||||
|
||||
startPositionTicks = data.get("StartPositionTicks")
|
||||
log.info("Playing Media With ID : " + itemIds[0])
|
||||
log.info("StartPositionTicks : " + str(startPositionTicks))
|
||||
|
||||
addonSettings = xbmcaddon.Addon(id='plugin.video.embycon')
|
||||
mb3Host = addonSettings.getSetting('ipaddress')
|
||||
mb3Port = addonSettings.getSetting('port')
|
||||
|
||||
url = mb3Host + ":" + mb3Port + ',;' + itemIds[0]
|
||||
if(startPositionTicks == None):
|
||||
url += ",;" + "-1"
|
||||
else:
|
||||
url += ",;" + str(startPositionTicks)
|
||||
|
||||
playUrl = "plugin://plugin.video.embycon/?url=" + url + '&mode=PLAY'
|
||||
playUrl = playUrl.replace("\\\\","smb://")
|
||||
playUrl = playUrl.replace("\\","/")
|
||||
|
||||
xbmc.Player().play(playUrl)
|
||||
|
||||
server = addonSettings.getSetting('ipaddress') + ":" + addonSettings.getSetting('port')
|
||||
userid = downloadUtils.getUserId()
|
||||
item_id = itemIds[0]
|
||||
|
||||
downloadUrl = "http://" + server + "/emby/Users/" + userid + "/Items/" + item_id + "?format=json"
|
||||
jsonData = downloadUtils.downloadUrl(
|
||||
downloadUrl,
|
||||
suppress=False,
|
||||
popup=1)
|
||||
result = json.loads(jsonData)
|
||||
|
||||
playurl = PlayUtils().getPlayUrl(item_id, result)
|
||||
log.info("Websocket Play URL: " + playurl)
|
||||
WINDOW = xbmcgui.Window(10000)
|
||||
WINDOW.setProperty("playback_url_" + playurl, item_id)
|
||||
|
||||
#thumbPath = downloadUtils.getArtwork(result, "Primary")
|
||||
#listItem = xbmcgui.ListItem(path=playurl, iconImage=thumbPath, thumbnailImage=thumbPath)
|
||||
|
||||
xbmc.Player().play(playurl)
|
||||
|
||||
if startPositionTicks == None or startPositionTicks == 0:
|
||||
return
|
||||
|
||||
# resume
|
||||
count = 0
|
||||
while not xbmc.Player().isPlaying():
|
||||
log.info("Not playing yet...sleep for 1 sec")
|
||||
count = count + 1
|
||||
if count >= 10:
|
||||
log.info("Waited for 10 seconds and noting is playing")
|
||||
return
|
||||
else:
|
||||
time.sleep(1)
|
||||
|
||||
seekTime = (startPositionTicks / 1000) / 10000
|
||||
jumpBackSec = int(addonSettings.getSetting("resumeJumpBack"))
|
||||
seekToTime = seekTime - jumpBackSec
|
||||
log.info("Seeking to position: " + str(seekToTime))
|
||||
while xbmc.Player().getTime() < (seekToTime - 5):
|
||||
xbmc.Player().pause
|
||||
xbmc.sleep(100)
|
||||
xbmc.Player().seekTime(seekToTime)
|
||||
xbmc.sleep(100)
|
||||
xbmc.Player().play()
|
||||
|
||||
|
||||
elif(messageType != None and messageType == "Playstate"):
|
||||
command = data.get("Command")
|
||||
if(command != None and command == "Stop"):
|
||||
|
Loading…
Reference in New Issue
Block a user