Sign up here and you can log into the forum!

What happens when you pause then play a video?

Discussion, features, plugins--everything about zoster's UMSP UPnP Media Server software

What happens when you pause then play a video?   

Postby kmk » Fri Mar 29, 2013 10:10 pm


I've created a umsp plugin for my parents.

The company who provides the service provides a web-based service so I was able to create a proxy to play their videos.

While testing the plugin, I've found a problem.

Use case is..

1. Play a video
2. Pause it
3. Play it again
4. The video plays a little bit more then hangs.

I've used _log functions to dump out headers from proxy.php, but it looks like WDTV doesn't request anything when you simply pause then play again.

In order to debug this bug, I would like to know..what exactly happens when you pause then play a video.
Posts: 33
Joined: Thu Jul 22, 2010 2:07 pm

Re: What happens when you pause then play a video?   

Postby mad_ady » Sun Mar 31, 2013 10:25 pm

Your description is correct.

The following thing happens: your proxy just makes sure to extract the actual video URL, maybe send back some HTTP headers and pass the actual HTTP stream unchanged to the player. When you call fpassthru() you actually terminate your proxy code and pass the buffer off to the player.

Now, when you pause a video there is nothing spectacular going on between the client and the server. The client will continue to request data from the server until it fills up its buffer (we're talking about the ~2M playback buffer in the WDTV). When the buffer is filled, the TCP connection is kept alive for a while, but if there is no traffic going on it will be closed usually by the remote side. You can try to send the server the HTTP header "Connection: Keep-Alive", but as far as I know public web servers will close such connections automatically after a while.

So, when that timer expires, the remote side will send a TCP FIN request or a TCP RST and close the connection. You are still able to play what's left of your buffer, but the player will think it has finished its job and quit once the buffer is empty.

You can pause a video and resume it if the pause is not longer than the expire interval (you'll need to try it out to see what's the correct value for you).

I don't know any ways to force the connection to be kept - you would need to constantly transfer data over that TCP socket. You could theoretically do it from the proxy - e.g. have the proxy download the file and play from the downloaded file instead, but it's messy and you can't FF until you have the whole file...
User avatar
Posts: 4573
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: What happens when you pause then play a video?   

Postby kmk » Thu Apr 04, 2013 1:12 am

Thank you for the insight mad_ady!

I will try a proxy server just for fun :)

Thank you so much!
Posts: 33
Joined: Thu Jul 22, 2010 2:07 pm

Return to UMSP Media Server

Who is online

Users browsing this forum: No registered users and 2 guests