How to resume the video programmatically
#1
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 ?
Reply
#2
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
Reply
#3
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()
Reply
#4
xbmc.executebuiltin() with the correct command. Not sure what it is, but look at the confluence skins player controls.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#5
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
Reply
#6
I was to curious and try'ed it immediately ...
Code:
xbmc.executebuiltin('Player.Paused')
returns always None to me.
Reply
#7
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.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#8
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.
Reply
#9
Oh, then you want xbmc.getCondVisibilty("player.paused")
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#10
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()
Reply
#11
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=JSO...I/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}
Reply
#12
(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.
Reply
#13
(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..
Reply

Logout Mark Read Team Forum Stats Members Help
How to resume the video programmatically0