Kodi Community Forum

Full Version: Execute user tasks for Kodi events (callbacks ver2)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
The "onPlayBackStarted" event on leia seems to be called once after reboot, after that it's not called anymore.
Is this a Leia bug or an addon bug? Would be nice to get an update.
The "onPlayBackResumed" event works fine, so I need to pause and resume every video, as this calls the same smarthome functions here.

Best regards,
Marc
The fact is that kodi Callbacks is no longer working on Leia and it seems that KenV99 has abandoned the project. So we have to hope that someone takes the KenV99 project.
Leia. What’s this crash is about?

2019-03-13 18:22:46.963 T:3186619248 NOTICE: $$$ [kodi.callbacks] - Settings read
2019-03-13 18:22:46.965 T:3186619248 NOTICE: $$$ [kodi.callbacks] - Dispatcher initialized
2019-03-13 18:22:46.970 T:3186619248 NOTICE: $$$ [kodi.callbacks] - Subscriber for event: onPlayBackStarted, task: T1 created
2019-03-13 18:22:46.977 T:3186619248 NOTICE: $$$ [kodi.callbacks] - Player Publisher initialized
2019-03-13 18:22:46.981 T:3186619248 NOTICE: $$$ [kodi.callbacks] - Dispatcher started
2019-03-13 18:22:46.984 T:3186619248 NOTICE: $$$ [kodi.callbacks] - Publisher(s) started
2019-03-13 18:22:57.971 T:4094574512 NOTICE: VideoPlayer::OpenFile: videodb://inprogresstvshows/94/-2/1995?season=-2&tvshowid=94
2019-03-13 18:22:57.972 T:3151532912 NOTICE: Creating InputStream
2019-03-13 18:22:57.975 T:3151532912 NOTICE: Creating Demuxer
2019-03-13 18:22:57.994 T:3171939184 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.IndexError'>
Error Contents: list index out of range
Traceback (most recent call last):
File "/storage/.kodi/addons/script.service.kodi.callbacks/resources/lib/publishers/player.py", line 331, in onPlayBackStarted
self.getInfo()
File "/storage/.kodi/addons/script.service.kodi.callbacks/resources/lib/publishers/player.py", line 267, in getInfo
playerid = player['result'][0]['playerid']
IndexError: list index out of range
-->End of Python script error report<--
(2019-03-13, 17:24)i3laze Wrote: [ -> ]What’s this crash is about?

Without really knowing the plugin or your configuration it looks like no player could be loaded from the configuration. Whatever a player may be here...

You could try to edit line 269 in file /storage/.kodi/addons/script.service.kodi.callbacks/resources/lib/publishers/player.py into
except (IndexError, KeyError):
instead of
except KeyError:

Maybe this helps.
Here's the deal.. /storage/.kodi/addons/script.service.kodi.callbacks/resources/lib/publishers/player.py Line 258:
while tries < 8 and self.isPlaying() is False:
   xbmc.sleep(250)

Seems isPlaying() returns True (thus no delay occurs), but player actually haven’t initialized yet.

I've added extra xbmc.sleep(1000) delay below and now JSON-query returns Player data successfully.
Eventually Callbacks then fires tasks.

P.S. Warnings in log are related to add-on config parsed badly.. it also affects add-on Settings displayed crappy.
So, I changed xbmc.sleep to (1000). Now it will reliably update the status when watching anything on the PVR (Myth), it will sometimes update the status when starting a TV show, but it will never update the status when starting a movie. I'm stumped.
Hello,

I'm trying too to use the "onPlayBackStarted" event but it doesn't work well...

But I identified a systematic behavior : it works ONLY when you run a video that interrupts another one playing.

if you start a video with no video playing in background, it doesn't work.

If this can help someone to debug the plugin, it would be very helpful !!

Thanks
I have a little question by the way, I'm not sure to understand well how this addon works.

When I choose "onPlayBackStarted", I can only transmit the variables that are listed below ?
(%li, %wi, %fn, %ti,...)

Or I can transmit another variable ?
I need to transmit the information of number of channels of the media playing (2.0 or 5.1 for example)

Is it possible with this add-on ?
OK,

I was able to do it with a python script with the line :

NbreCanaux = xbmc.getInfoLabel('VideoPlayer.AudioChannels')

No need for variable substitution... and I realize that thanks to that wonderful addon, I think it's possible to access to almost anything in Kodi !!

Now If someone can fix that little bug (post #247), that would be amazing Smile
Thanks
@KenV99 are you still around ? any plan on fixing the addon for Leia ?
Hoping someone here can help me with some basic use. I'm trying to use callbacks to play background music in the menus and pause/play when I start stop a movie.

I started trying to to use a builtin command like this..

)]

and although I don't get any errors, I also don't hear any music either. Do I have my syntax wrong?
uhmmm, I guess I can't edit posts, here is my command to try and play songs in a directory..

PlayMedia(C:/Media/Music/LondonSymphonyOrchestra/JohnWilliamsALifeInMusic,[isdir])
(2019-03-22, 22:09)jeffkjolley Wrote: [ -> ]So, I changed xbmc.sleep to (1000). Now it will reliably update the status when watching anything on the PVR (Myth), it will sometimes update the status when starting a TV show, but it will never update the status when starting a movie. I'm stumped.

Looks like the “while tries < 8“ doesn’t fire in Leia at all.
So it’s not about changing but adding extra line with xbmc.sleep(1000).
Try also 2000 (2 sec) or more - maybe your CPU is a bit choking on playback start.
(2019-04-08, 06:42)i3laze Wrote: [ -> ]
(2019-03-22, 22:09)jeffkjolley Wrote: [ -> ]So, I changed xbmc.sleep to (1000). Now it will reliably update the status when watching anything on the PVR (Myth), it will sometimes update the status when starting a TV show, but it will never update the status when starting a movie. I'm stumped.

Looks like the “while tries < 8“ doesn’t fire in Leia at all.
So it’s not about changing but adding extra line with xbmc.sleep(1000).
Try also 2000 (2 sec) or more - maybe your CPU is a bit choking on playback start. 
Not working here unfortunately...
Tried with several values, till 5000....
Nothing happens when a video starts.

BUT as I mentioned in #247, it ALWAYS works when a video interrupts another !
(2019-04-08, 22:26)badsheep Wrote: [ -> ]Not working here unfortunately...
Tried with several values, till 5000....
Nothing happens when a video starts.

BUT as I mentioned in #247, it ALWAYS works when a video interrupts another ! 
 Can confirm. I've tried all suggested workarounds and can only get the callback to fire by starting a video while one is already playing. Very weird.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21