Kodi Community Forum
How to resume the video programmatically - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: How to resume the video programmatically (/showthread.php?tid=179187)



How to resume the video programmatically - patrik.fatoric - 2013-11-29

Hello,

I made an XBMC script that interacts with the video being played.
I have the requirements to pause and resume the video again.

I happens that after xbmc.Player().pause() the player pause but after calling
xbmc.Player().play() he won't resume programmatically.

I can resume him manually pressing a play button but nothing else.

Am I missing something ?


RE: How to resume the video programmatically - shellshark - 2013-11-30

Im currently looking for this, too.

As there seems no xbmc.Player isPaused function, i could not write a resume function.

I've also try'ed:
* to use isPlayingVideo - put this also returnes True if playback is paused.
* to create a xbmc.Player subclass - here i could use the onPlayBackPaused callback - but this seems not to work in xbmc.service addons

So, ... is there anyway check if the current playback is paused?

Thank you,
Frank


RE: How to resume the video programmatically - shellshark - 2013-11-30

On more information: this is my current workaround ...

Code:
def is_playback_paused():
    start_time = xbmc.Player().getTime()
    time.sleep(1)
    if xbmc.Player().getTime() != start_time:
        return False
    else:
        return True

def resume_playback():
    if is_playback_paused():
        xbmc.Player().pause()



RE: How to resume the video programmatically - Nuka1195 - 2013-11-30

xbmc.executebuiltin() with the correct command. Not sure what it is, but look at the confluence skins player controls.


RE: How to resume the video programmatically - shellshark - 2013-12-01

Uh, ok.

Thanks for this advice ... just found this list http://wiki.xbmc.org/?title=List_of_Boolean_Conditions where Player.Paused is listed. I will take a look if it works as aspected tomorrow.

Thanks,
Frank


RE: How to resume the video programmatically - shellshark - 2013-12-01

I was to curious and try'ed it immediately ...
Code:
xbmc.executebuiltin('Player.Paused')
returns always None to me.


RE: How to resume the video programmatically - Nuka1195 - 2013-12-01

look in confluences PlayerControls.xml

PHP Code:
xbmc.executebuiltin('XBMC.PlayerControl(Play)'

should play or pause the player depending on what it's currently doing. I think.


RE: How to resume the video programmatically - shellshark - 2013-12-01

This can be achieved with
Code:
xbmc.Player().pause()
This pauses the video and resumes it if its paused.

The problem is, if i dont know if the video is paused i cant be sure if i resume or pause it.

My addon pauses the playback if you receive a phone call and should resume it when you end the call. If someone resumes playback while im on the phone, the playback will pause when i hang up. If i knew the pause status i could prevent this case.


RE: How to resume the video programmatically - Nuka1195 - 2013-12-01

Oh, then you want xbmc.getCondVisibilty("player.paused")


RE: How to resume the video programmatically - shellshark - 2013-12-01

Thank you very much Big Grin!

It works and was exactly what i was looking for.

For everyone else who looks for it:
Code:
def is_playback_paused():
    return bool(xbmc.getCondVisibility("Player.Paused"))

def resume_playback():
    if is_playback_paused():
        xbmc.Player().pause()



RE: How to resume the video programmatically - patrik.fatoric - 2013-12-02

It looks like that calling a JSON-RPC API by TCP at port 9090 work for pause and resume.
http://wiki.xbmc.org/index.php?title=JSON-RPC_API/Examples

You can try this ... Run XBMC
Run Telnet 127.0.0.1 9090
and paste
{"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": 1 }, "id": 1}


RE: How to resume the video programmatically - spoyser - 2013-12-04

(2013-12-01, 20:29)shellshark Wrote: Thank you very much Big Grin!

It works and was exactly what i was looking for.

For everyone else who looks for it:
Code:
def is_playback_paused():
    return bool(xbmc.getCondVisibility("Player.Paused"))

def resume_playback():
    if is_playback_paused():
        xbmc.Player().pause()

Just what I needed for the Muzu addon, so many thanks for that, can't believe it isn't a property on xbmc.Player though.


RE: How to resume the video programmatically - NordishByNature - 2013-12-04

(2013-12-01, 20:29)shellshark Wrote: Thank you very much Big Grin!

It works and was exactly what i was looking for.

For everyone else who looks for it:
Code:
def is_playback_paused():
    return bool(xbmc.getCondVisibility("Player.Paused"))

def resume_playback():
    if is_playback_paused():
        xbmc.Player().pause()

Nice piece of code! Will use it in my addons! Thanks..