Curiosity is bliss    Archive    Feed    About    Search

Julien Couvreur's programming blog and more

One-click video streaming from home server


Kitty with remote

I have some video files on a home server, which I want to watch on my laptop in the living room with the least possible hassle. The files are accessible thru HTTP. They can be played using MPlayer (thru MPUI on Windows) and VLC, which can stream videos over HTTP.

But the step from finding the video using my browser to opening the video in one of these media players involves an annoying copy and paste operation.

I wrote the One-Click Video Streaming Greasemonkey script to solve this. I can now start playing videos with a single click on the directory listing page in my browser.
The script adds a "one-click play" icon next to each video in the directory listings. Clicking that icon launches a media player, automatically opening the corresponding video stream.

Note that when you install the script, you need to specific the url patterns that should trigger this script. In my case, that's the root url for my media server.

If you are curious about how this script works, here's the gist.
First, notice that if you create a playlist file containing the url to a video as the single line, opening that file will get the url loaded by the media player.
Then, realize that you can generate playlist "files" on the client-side (avoiding any server-side code change) using data: urls.
Finally, get the script to identify all the video links (extension ".avi", in the current implementation), generate and insert a data: url next to each one.
That's it.

Obviously, this solution is still a one-off. There are many scenarios that are similar in nature having to do with either specific URI schemes or mime-types, which call for a more generic solution.
For example, one-click subscription to RSS feeds in your favorite aggregator, composing/sending of email from mailto: links in Gmail, or downloading of ed2k: links by a remote instance of Emule.
Some cool stuff around this problem is coming in Firefox 3, but that will be the topic of another post.


The script contains
onclick=\"deleteFile('" + link.href + "')

but I can't see deleteFile defined anywhere. What gives?

Posted by: splintor (September 17, 2007 02:18 PM) ______________________________________

That's just a commented line, which I copied from another script. That other script lets me delete a file directly from browser by adding a delete icon next to each entry in the listing.
I'll go ahead and remove that comment.
Thanks for picking that up.

Posted by: Julien (September 19, 2007 09:34 AM)
comments powered by Disqus