Has anyone considered...

Discuss your Lua playlist, album art and interface scripts.
NoMoreNicksLeft
Blank Cone
Blank Cone
Posts: 21
Joined: 06 Aug 2012 19:39

Has anyone considered...

Postby NoMoreNicksLeft » 08 Aug 2012 18:10

That VLC has (most of) the features to allow the creation of what you might call "virtual television channels"?

You can add permanent items to the playlist sidebar (service discovery modules). And you can add playlist scripts capable of parsing html/xml/rss for video files. If you created a web application that outputs a page with a link to a video file and a link to the "next video" page, then the playlist script would parse and add both those entries. When the video finishes playing and VLC moves on to the "next video" link, the playlist script takes over again, downloads that, and parses the video and next-video link once again.

On the webserver, you could configure it such that it simply won't give you the next video link until say 8:00pm, so people who want to skip ahead would only be able to do so until the end of the video. Supposing you wanted to do that, of course.

There are a few minor detail features missing, but nothing that would prevent it from working altogether.

NoMoreNicksLeft
Blank Cone
Blank Cone
Posts: 21
Joined: 06 Aug 2012 19:39

Re: Has anyone considered...

Postby NoMoreNicksLeft » 10 Aug 2012 07:44

Well, I've tinkered a bit since my initial post. I have the following lua playlist script installed:

Code: Select all

-- Probe function. function probe() if vlc.access ~= "http" and vlc.access ~= "https" then return false end site = string.find( vlc.path, "spacepotato" ) if site == nil then return false end return true end -- Parse function. function parse() dhead = "\27[1;35mspacepotato.lua debug: " dtail = "\27[0m" -- vlc.msg.dbg( dhead .. 'the path is - ' .. vlc.path .. dtail ) -- We need to clear the playlist first, if possible. --vlc.playlist.clear() local t = {} local i = 1 while true do line = vlc.readline() if not line then break end if string.match( line, "x%-derp='true' " ) then _,_,link,duration,title = string.find( line, "x%-link='(http.-)' x%-duration='(%d+)' title='(.-)'" ) t[i] = { path = link; name = title; duration = duration } i = i + 1 end end return t end
Nothing special there, of course. Then I have the following PHP page up on my machine:

Code: Select all

<html> <head></head> <body> <h1>The Space Potato Channel</h1> <p> The Space Potato Channel is designed to be used with <a href='http://www.videolan.org/'>Videolan Media Player<a/>. Download it now if you don't already have it installed. If you do, open it now, press Control-N, and paste this address into the prompt to begin watching. </p> <?php $dbh = pg_connect("host=localhost port=5434 dbname=derp user=xxxx password=xxxxx"); if (!$dbh) die("Error in connection: " . pg_last_error()); $result = pg_query($dbh, "select uri, extract(epoch from duration), title " . "from derp.channel " . "where now() < (start + duration) " . "and now() >= start " . "order by start limit 1" ) or die('Query failed: ' . pg_last_error()); $row = pg_fetch_array($result); if ($row[0]) print "\t\t<a x-derp='true' x-link='" . $row[0] . "' x-duration='" . $row[1] . "' title='" . $row[2] . "' />\n"; else print "\t\t<a x-derp='true' x-link='http://localhost/~john/spacepotato/images/testcards/rca_testcard.jpg' x-duration='10' title='Please Stand By' />\n"; pg_free_result($result); pg_close($dbh); ?> <a x-derp='true' x-link='http://localhost/~john/spacepotato/index.php' x-duration='10' title=' ' /> </body> </html>
All this does is put up a simple html page with two links that the lua script can parse. The first link is to any arbitrary video, and the second link is self-referential back to the same php page so that when it finishes the video it reloads itself. However, on reload the database call selects a new video link based on the time (or, if no database record corresponds to that time it links in the old RCA test pattern image).

There are some issues... it seems VLC doesn't cache that image, so if you have the test pattern up for 60 minutes, it will bang on the webserver 360 times (every 10 seconds it will reload). I can't seem to figure out how to force VLC to seek to the middle of a video if someone loads the url after its scheduled time either. And it would be nice to clear the playlist each time, so it just doesn't fill up with junk... but vlc.playlist.clear() seems to not be available from within playlist scripts (ugh).

I had it running half a dozen videos from all over the internet one after another, and whenever I'd stop or put the start time wrong into the database, it'd switch to the "please stand by".

All that's really needed is for VLC to prompt the user to install the lua script whenever they go to that page, and I think I almost know how that would have to work too. Is anyone even interested in this stuff?

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Has anyone considered...

Postby Jean-Baptiste Kempf » 10 Aug 2012 11:37

Of course, it is doable.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 7 guests