PlexConnect icon indicating copy to clipboard operation
PlexConnect copied to clipboard

We should capture the other play states and send them via timeline endpoint

Open elan opened this issue 13 years ago • 30 comments

At least loading (buffering in our state) and paused are interesting to us.

atv.player.playerStateChanged = function(newState, timeIntervalSec) 
{   
    /*
    atv.player.states.FastForwarding
    atv.player.states.Loading
    atv.player.states.Paused
    atv.player.states.Playing
    atv.player.states.Rewinding
    atv.player.states.Stopped
    */
}

elan avatar May 29 '13 03:05 elan

Hi Elan, What exactly should we be doing to handle the Paused state? Some people are reporting issues on the forum if they leave a video paused and then resume. I'm assuming there is some command we should be issuing to the transcoder to tell it the video is paused.

roidy avatar Jun 03 '13 18:06 roidy

Ah yes, there is a /ping endpoint (just like stop) which stops the session from timing out (in 180 seconds).

So when paused, hit the ping endpoint every 60 seconds or so. The session itself will be idle, so it won't take up CPU.

elan avatar Jun 03 '13 19:06 elan

Excellent, thanks. I'll look into it.

roidy avatar Jun 03 '13 20:06 roidy

So all I need to call is:

loadPage(addrPMS + '/video/:/transcode/universal/ping?session=' + atv.device.udid);

every 60 seconds or so?

roidy avatar Jun 03 '13 20:06 roidy

Yup, that should do it! (Only when paused, of course, although calling it during regular playback won't cause any issues...)

elan avatar Jun 03 '13 20:06 elan

Ok, thanks.

roidy avatar Jun 03 '13 20:06 roidy

Umm.. this may be harder than I expected, seems ATV javascript doesn't have the setTimeout functions :(

roidy avatar Jun 03 '13 20:06 roidy

Doh! If nothing else, they could call PlexConnect on pause/play and PlexConnect could take care of it.

elan avatar Jun 03 '13 20:06 elan

No, wait. All is not lost :) the ATV has it's own versions called:-

atv.setInterval and atv.clearInterval

roidy avatar Jun 03 '13 20:06 roidy

Ah nice! I spent some time before my first commit doing a bunch of for i in atv diving down and exploring the tree :)

elan avatar Jun 03 '13 20:06 elan

Nice.. I found them by doing a string search for "timer" in all the files I pulled from that sample-xml site :)

roidy avatar Jun 03 '13 20:06 roidy

Ah, nice. Love those samples. As as aside, do you know how to make it so that a page reloads when you navigate back to it (e.g. the On Deck screen)? Is there some magic in the XML I'm not aware of, or does it take an HTTP "no-cache" header, maybe?

elan avatar Jun 03 '13 20:06 elan

Which other states should we be handling? You mentioned loading (buffing).

roidy avatar Jun 03 '13 20:06 roidy

The ones the server supports are:

enum PlexPlayState
{
  PLAYING,
  PAUSED,
  BUFFERING,
  STOPPED
};

elan avatar Jun 03 '13 20:06 elan

Ah, nice. Love those samples. As as aside, do you know how to make it so that a page reloads when you >navigate back to it (e.g. the On Deck screen)? Is there some magic in the XML I'm not aware of, or does it take >an HTTP "no-cache" header, maybe?

I was using the following in my version of On Deck:-

<listWithPreview id="com.sample.menu-items-with-sections" volatile="true" onVolatileReload="reloadPMS_XML('{{getPath()}}')">

Set the top level item as volatile then every time you navigate back to the page the function in onVolatileReload is called, which I used to do just that, reload the xml. However I haven't had much luck getting it to work with the top nav bar. Maybe you'll have more luck.

roidy avatar Jun 03 '13 21:06 roidy

Have you seen the ATV xml schema file? It's a list of all the available xml elements and attributes. If not I'll post it somewhere for you.

roidy avatar Jun 03 '13 21:06 roidy

Ah no, I haven't! That would be great.

elan avatar Jun 03 '13 21:06 elan

The ones the server supports are:

Excellent, so the only one we're not handling is BUFFERING. Is there anything special we need to do here.

And I've forgot I've had a video paused for the last 15 minutes, testing the pause state.... It works perfectly :)

roidy avatar Jun 03 '13 21:06 roidy

Excellent! All you need to do on any state change is issue the /:/timeline request with appropriate update.

elan avatar Jun 03 '13 21:06 elan

Ah no, I haven't! That would be great.

Can I email it to you. It's a file ripped from a jailbroken ATV2 so I don't want to publically post it :) Or if you have a jailbroken ATV to hand you can rip it out yourself.

roidy avatar Jun 03 '13 21:06 roidy