use an xbmc.Monitor to monitor for playback events instead of the home window property
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<addon id="plugin.video.embycon"
|
||||
name="EmbyCon"
|
||||
version="1.4.18"
|
||||
version="1.4.19"
|
||||
provider-name="Team B">
|
||||
<requires>
|
||||
<import addon="xbmc.python" version="2.24.0"/>
|
||||
|
||||
@@ -9,6 +9,7 @@ import pstats
|
||||
import json
|
||||
import StringIO
|
||||
import encodings
|
||||
import binascii
|
||||
|
||||
import xbmcplugin
|
||||
import xbmcgui
|
||||
@@ -889,9 +890,17 @@ def PLAY(params):
|
||||
play_info["use_default"] = use_default
|
||||
play_data = json.dumps(play_info)
|
||||
|
||||
home_window = HomeWindow()
|
||||
home_window.setProperty("item_id", item_id)
|
||||
home_window.setProperty("play_item_message", play_data)
|
||||
source_id = "embycon"
|
||||
signal = "embycon_play_action"
|
||||
hex_string = binascii.hexlify(play_data)
|
||||
data = '\\"[\\"{0}\\"]\\"'.format(hex_string)
|
||||
command = 'XBMC.NotifyAll({0}.SIGNAL,{1},{2})'.format(source_id, signal, data)
|
||||
log.debug("Sending playback action: {0}", command)
|
||||
xbmc.executebuiltin(command)
|
||||
|
||||
#home_window = HomeWindow()
|
||||
#home_window.setProperty("item_id", item_id)
|
||||
#home_window.setProperty("play_item_message", play_data)
|
||||
|
||||
#xbmcgui.Dialog().notification("EmbyCon", "Starting Playback")
|
||||
|
||||
|
||||
33
service.py
33
service.py
@@ -7,6 +7,7 @@ import xbmcgui
|
||||
import time
|
||||
import json
|
||||
import traceback
|
||||
import binascii
|
||||
|
||||
from resources.lib.error import catch_except
|
||||
from resources.lib.downloadutils import DownloadUtils
|
||||
@@ -277,7 +278,29 @@ class Service(xbmc.Player):
|
||||
sendProgress()
|
||||
|
||||
|
||||
class PlaybackService(xbmc.Monitor):
|
||||
|
||||
def onNotification(self, sender, method, data):
|
||||
log.debug("PlaybackService:onNotification:{0}:{1}:{2}", sender, method, data)
|
||||
if sender[-7:] != '.SIGNAL':
|
||||
return
|
||||
|
||||
signal = method.split('.', 1)[-1]
|
||||
if signal != "embycon_play_action":
|
||||
return
|
||||
|
||||
data_json = json.loads(data)
|
||||
hex_data = data_json[0]
|
||||
log.debug("PlaybackService:onNotification:{0}", hex_data)
|
||||
decoded_data = binascii.unhexlify(hex_data)
|
||||
play_info = json.loads(decoded_data)
|
||||
playFile(play_info)
|
||||
|
||||
|
||||
# set up all the services
|
||||
monitor = Service()
|
||||
playback_service = PlaybackService()
|
||||
|
||||
home_window = HomeWindow()
|
||||
last_progress_update = time.time()
|
||||
last_content_check = time.time()
|
||||
@@ -327,11 +350,11 @@ while not xbmc.abortRequested:
|
||||
sendProgress()
|
||||
else:
|
||||
# if we have a play item them trigger playback
|
||||
play_data = home_window.getProperty("play_item_message")
|
||||
if play_data:
|
||||
home_window.clearProperty("play_item_message")
|
||||
play_info = json.loads(play_data)
|
||||
playFile(play_info)
|
||||
#play_data = home_window.getProperty("play_item_message")
|
||||
#if play_data:
|
||||
# home_window.clearProperty("play_item_message")
|
||||
# play_info = json.loads(play_data)
|
||||
# playFile(play_info)
|
||||
|
||||
# if not playing every 60 seonds check for new widget content
|
||||
if (time.time() - last_content_check) > 60:
|
||||
|
||||
Reference in New Issue
Block a user