- It has been on the Mac for many years and is now available there as Fractal Architect 5 and Fractal Architect X. But the iOS and iPadOS app is not a.lite. app. It has the same rendering engine as its counterpart on MacOS and the files and the Lua scripts are 100% compatible between the different platforms. SHARING BETWEEN PLATFORMS.
- Anyone who wants to know, the lua file you need to copy is found under your current dir /src/lua – M.W. Felker Dec 17 '14 at 22:03 4 To make this possible I had to change /usr/bin/lua to /usr/local/bin/lua and it works fine. – rafaelmorais Sep 9 '16 at 9:38.
Learn about building games for macOS, iOS, watchOS, and tvOS with the latest Apple game technologies. Maximize the graphics and compute potential of your games with Metal, which provides the best access to the GPU on iOS, macOS, and tvOS. Learn more about Metal. Create smaller app bundles, enable faster downloads, and add up to 20 GB of.
This page contains example code. |
- 2Simple Examples
- 2.1URL translation
- 2.2Text Playlist Parsing
Introduction
Starting with version 0.9.0, VLC gives you the possible to implement your own playlist loading modules easily. Such modules can do stuff like:
- URL translation: You give it the youtube webpage URL and VLC starts playing the corresponding video;
- Text playlist parsing: You use some custom text playlist format.
Lua playlist scripts shipped with VLC are stored in the following directory:
- C:Program FilesVideoLANVLCluaplaylist on Windows;
- VLC.app/Contents/MacOS/share/lua/playlist/ on Mac OS X;
- /usr/share/vlc/lua/playlist/ on Linux.
You can add your own Lua playlist scripts in this directory or in your VLC's preferences folder 'lua/playlist' subdirectory on Windows or Mac OS X and in your local VLC shared data folder on Linux (~/.local/share/vlc/lua/playlist).
Simple Examples
URL translation
What we want to do
Let's say that we want VLC to open Google Video links automatically. Google Video pages have URLs like
to the URL of the corresponding Google Video Playlist file which is
Probe
The Lua script is going to be made of 2 functions. The first one is the probe() function. This function tells VLC if the Lua script should be used (function returns true) or not (function returns false). Here it would look like:
Lets analyse that function step by step. First we check that VLC is using HTTP. If it isn't (for example it's reading a file off your hard drive or a DVD), we don't want to trigger the Google Video URL translation. The vlc Lua object provides vlc.access which should be equal to string 'http'. Then we check that the URL is a Google Video page. This is easily done by trying to find the 'video.google.com/videoplay' string in vlc.path.
Note that the same function can be written as
Parse
If the probe() function returns true, VLC will use the parse() to ask for the new playlist item(s) which need to be added.
We create a new playlist item (a Lua table). We set the item's path to the appropriate string: 1/ we prepend 'http://' since the vlc.path string doesn't include that part of the original URL and 2/ we replace 'videoplay' by 'videogvp'.
We also set the new playlist item's name to 'Some Google video playlist'.
We then return the new playlist to VLC (a Lua table which basically represents a list of items).
A shorter version would be:
Saving that to a file
To make that script available to VLC, simply create a new something.lua file in one of the directories listed in the introduction (You should also remove the googlevideo.lua file shipped with VLC to make sure that it isn't used instead of your new script).
Text Playlist Parsing
In the previous example we translated a URL to another URL. This new URL redirects VLC to a Google Video Playlist which is basically a text file. This file needs to be read to get the final video's true URL. Here's what such a file would look like if you were to open it with a text editor:
Probe
The first thing we need to worry about is making sure that the file we're playing is a Google Video Playlist (GVP) file. We could rely on the URL, but that would prevent playing GVP files from our hard drive. Fortunately, the file's contents, especially the 'gvp_version:' string seem specific to GVP files. We'll thus try reading a bunch of characters from the beginning of the file and look for the 'gvp_version:' string.
The vlc.peek(<number of chars>) function asks VLC to return the first <number of chars> characters. If the string 'gvp_version:' isn't found in a file's first 512 characters, we're almost 100% sure that it's not a valid GVP file.
Parse
We now need to read information from the file to create our new playlist item. A simple version would only fetch the URL:
We read all the file's lines using the vlc.readline() function. If we encounter the line starting with 'url:' (string.match( line, 'url:' ) would match lines containing 'url:', while string.match( line, '^url:' ) only matches those starting with 'url:'), we use that as our new item's path.
If vlc.readline() returns nil, this means that we've finished reading the file so we break out of the while loop and return our new playlist.
This simple parse() function unfortunately discards all the other useful meta information available in the GVP file. Lets try to use it:
Getting the video's title works like the URL parameter.The duration is a bit more tricky. GVP uses times in milliseconds while VLC wants a time in seconds. We thus have to divide it by 1000.For the description, it works like the URL and title parameters except that a GVP file can have more than one description parameter. If we read more than one parameter we thus concatenate the different description lines.
Reference
Information about the VLC Lua scripts is available in your VLC installation in the lua subdirectory.
Scripts shipped with VLC
Building An App Lua On Macos Iphone
Scripts for popular playlist formats and video websites are available in the default VLC installer:
- dailymotion.lua: URL translation for Daily Motion video pages;
- googlevideo.lua: URL translation for Google Video video pages;
- metacafe.lua: URL translation for metacafe video pages and flash player;
- youtube.lua: URL translation for YouTube video pages and flash player (including fullscreen video URLs);
- youtube_hompage.lua: Parse YouTube homepage and browse page.
Useful links
Please read the Documentation Editing Guidelines before you edit the documentation