Monitoring TV channel change
#1
I'm developing a service add-on that needs to do stuff when a TV channel is changed.

I thought I'd be able to wait with onPlayBackStarted() in the Player class but it doesn't seem to wait/block.

Here is my code to test:

Code:
player = xbmc.Player()

while True:
  xbmc.log("foo")
  if player.onPlayBackStarted():
    xbmc.log("Changed to: " + player.getPlayingFile())

It seems that onPlayBackStarted() is not blocking and it is returning false, because the above just prints "foo" repeatedly.
Reply
#2
I have this working now. It looks like you have to inherit the Player class and override onPlayBackStarted(). Then somehow this method is fired on all objects that implement it...anyone know how Kodi/Python does that? Sounds similar to delegates in C#?

However, I have a new problem. The method is firing when I first start playing a TV channel, but then doesn't fire again when I change channel, even though the "file" returned by getPlayingFile() has changed (it starts with pvr://...).

Anyone have any ideas on how to capture that event when a channel is changed?

I've noticed that in kodi.log, something like this is output when channel is changed:

NOTICE: PVRManager - PerformChannelSwitch - switched to channel '7 Digital'

As a last resort, I could somehow monitor the log file for this pattern, but would be a bit messy...
Reply

Logout Mark Read Team Forum Stats Members Help
Monitoring TV channel change0