How to do something once after every play in a service addon?
#1
Question 
Hey everyone

I'm on my first Kodi service development and trying to figure out how I can catch that the user stopped or paused the playback (or when the tv show episode ended), to do some things once after every time something has been played?

This is my current structure:
python:

class Service():

    def __init__(self, *args):
        self.skipped = False    

    def ServiceEntryPoint(self):
        monitor = xbmc.Monitor()       

        while not monitor.abortRequested():        
        
            if xbmc.Player().isPlaying():
                
                #doing some things here, while playing a movie
                
            if monitor.waitForAbort(5):
                break


I know that there are callback functions like onPlayBackStopped() and so on, but I have no clue on how to implement them in a service?

Thanks in advance for your help Smile
Reply
#2
(2022-04-02, 23:30)Pandohra Wrote: Hey everyone

I'm on my first Kodi service development and trying to figure out how I can catch that the user stopped or paused the playback (or when the tv show episode ended), to do some things once after every time something has been played?

This is my current structure:
python:

class Service():

    def __init__(self, *args):
        self.skipped = False    

    def ServiceEntryPoint(self):
        monitor = xbmc.Monitor()       

        while not monitor.abortRequested():        
        
            if xbmc.Player().isPlaying():
                
                #doing some things here, while playing a movie
                
            if monitor.waitForAbort(5):
                break


I know that there are callback functions like onPlayBackStopped() and so on, but I have no clue on how to implement them in a service?

Thanks in advance for your help Smile

This might help.  It's a service addon I wrote which has what you are looking for.  Take a look and feel fee to ask questions.  There are a few ways to do this but I find a working example is a great place to start.  You are on the right track with your code.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#3
(2022-04-03, 00:57)jbinkley60 Wrote:
(2022-04-02, 23:30)Pandohra Wrote: Hey everyone

I'm on my first Kodi service development and trying to figure out how I can catch that the user stopped or paused the playback (or when the tv show episode ended), to do some things once after every time something has been played?

This is my current structure:
python:

class Service():

    def __init__(self, *args):
        self.skipped = False    

    def ServiceEntryPoint(self):
        monitor = xbmc.Monitor()       

        while not monitor.abortRequested():        
        
            if xbmc.Player().isPlaying():
                
                #doing some things here, while playing a movie
                
            if monitor.waitForAbort(5):
                break


I know that there are callback functions like onPlayBackStopped() and so on, but I have no clue on how to implement them in a service?

Thanks in advance for your help Smile

This might help.  It's a service addon I wrote which has what you are looking for.  Take a look and feel fee to ask questions.  There are a few ways to do this but I find a working example is a great place to start.  You are on the right track with your code.


Jeff

That's amazing, thank you so much! That was exactly the help I needed.

Cheers!
Reply
#4
(2022-04-03, 12:17)Pandohra Wrote:
(2022-04-03, 00:57)jbinkley60 Wrote:
(2022-04-02, 23:30)Pandohra Wrote: Hey everyone

I'm on my first Kodi service development and trying to figure out how I can catch that the user stopped or paused the playback (or when the tv show episode ended), to do some things once after every time something has been played?

This is my current structure:
python:

class Service():

    def __init__(self, *args):
        self.skipped = False    

    def ServiceEntryPoint(self):
        monitor = xbmc.Monitor()       

        while not monitor.abortRequested():        
        
            if xbmc.Player().isPlaying():
                
                #doing some things here, while playing a movie
                
            if monitor.waitForAbort(5):
                break


I know that there are callback functions like onPlayBackStopped() and so on, but I have no clue on how to implement them in a service?

Thanks in advance for your help Smile

This might help.  It's a service addon I wrote which has what you are looking for.  Take a look and feel fee to ask questions.  There are a few ways to do this but I find a working example is a great place to start.  You are on the right track with your code.


Jeff

That's amazing, thank you so much! That was exactly the help I needed.

Cheers!

Glad to help.  I'll be traveling this week so if you have any questions my response time may be a bit slow.


Good luck,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply

Logout Mark Read Team Forum Stats Members Help
How to do something once after every play in a service addon?0