?Pause video, play a playlist, Unpause?

Discuss your Lua playlist, album art and interface scripts.
ultramatahai
New Cone
New Cone
Posts: 2
Joined: 29 Sep 2013 06:26

?Pause video, play a playlist, Unpause?

Postby ultramatahai » 29 Sep 2013 06:34

I was looking for some way that I could pause a main video at certain time, and play another minor video and when that second video ends, the previous (the main) video unpauses and after awhile the main video pauses again and activates a third video and so on until the long main video has ended. All videos are on the harddisk. I realized lua scripting is the best way I can do this. I'm not totally unfamiliar with programming, but I was wondering if someone could give me a shell to work with.

ultramatahai
New Cone
New Cone
Posts: 2
Joined: 29 Sep 2013 06:26

Re: ?Pause video, play a playlist, Unpause?

Postby ultramatahai » 29 Sep 2013 23:53

All I wanted was a way that I could watch two tv shows/movies in different languages synced by one subtitle, say french dubbed show together with english version. I wanted the french video to play only when they speak, while the english video plays the whole duration.



I've solved the problem by combining xml and xspf. I've downloaded java-xmlbuilder jar file from http://code.google.com/p/java-xmlbuilde ... ampleUsage. Then I used it together with this java program that I wrote:

Code: Select all

import java.io.FileOutputStream; import java.io.PrintWriter; import java.util.Properties; import com.jamesmurty.utils.*; public class Subbing { public static void main(String[] args) throws Exception{ Properties outputProperties = new Properties(); PrintWriter writer = new PrintWriter(new FileOutputStream("projects.xspf")); String[] locations = new String[] { "file:///C:/Users/***/Downloads/***/BreakingBad English.mp4", "file:///C:/Users/***/Downloads/***/BreakingBad French.mp4"}; String[] Str = new String[] { "Dialogue: 0,0:03:36.75,0:03:39.29,Default,,0000,0000,000DD", "Dialogue: 0,0:04:01.78,0:04:03.05,Default,,0000,0000,000DD", "Dialogue: 0,0:04:25.67,0:04:26.87,Default,,0000,0000,000DD", }; String Str2 = ""; XMLBuilder builder = XMLBuilder.create("playlist") .a("versiom", "1") .a("xmlns", "http://xspf.org/ns/0/") .a("xmlns:vlc", "http://www.videolan.org/vlc/playlist/ns/0/") .e("title") .t("Liste de lecture").up() .e("trackList"); for(int i=1; i < Str.length ; i++){ String firstnew = Str[i].substring(12, 22); String secondnew = Str[i].substring(23, 33); double firsthour = Double.parseDouble(firstnew.substring(0, 1)); double firstmin = Double.parseDouble(firstnew.substring(2, 4)); double firstsec = Double.parseDouble(firstnew.substring(5, 10)); double firstval = firsthour*60*60 + firstmin*60 + firstsec; double secondhour = Double.parseDouble(secondnew.substring(0, 1)); double secondmin = Double.parseDouble(secondnew.substring(2, 4)); double secondsec = Double.parseDouble(secondnew.substring(5, 10)); double secondval = secondhour*60*60 + secondmin*60 + secondsec; String firstold = Str[i-1].substring(12, 22); double oldhour = Double.parseDouble(firstold.substring(0, 1)); double oldmin = Double.parseDouble(firstold.substring(2, 4)); double oldsec = Double.parseDouble(firstold.substring(5, 10)); double oldval = oldhour*60*60 + oldmin*60 + oldsec; builder .e("track") .e("location") .t(locations[0]).up() .element("extension") .a("application","http://www.videolan.org/vlc/playlist/0") .e("vlc:option") .t("start-time=" + oldval).up() .e("vlc:option") .t("stop-time=" + firstval).up() .up(); builder .e("track") .e("location") .t(locations[1]).up() .element("extension") .a("application","http://www.videolan.org/vlc/playlist/0") .e("vlc:option") .t("start-time=" + firstval).up() .e("vlc:option") .t("stop-time=" + secondval).up() .up(); builder .e("track") .e("location") .t(locations[0]).up() .element("extension") .a("application","http://www.videolan.org/vlc/playlist/0") .e("vlc:option") .t("start-time=" + secondval).up() .e("vlc:option") .t("stop-time=" + secondval+1).up() .e("vlc:option") .t("no-video").up() .e("vlc:option") .t("no-audio").up() ; builder.up(); } outputProperties.put(javax.xml.transform.OutputKeys.METHOD, "xml"); builder.toWriter(writer, outputProperties); System.out.println(builder.asString(outputProperties)); } }
1) For the timing I used a subtitle converted to "ass"
2) I cleaned up the subtitles and for that I used Excel. You can snip certain strings. I could've used java, but I'm a noob so far and java doesn't like certain characters. As long as you have the time stamp and enclosed in "", you should be fine. This is an example of cleaned up subtitle dialogue time stamp:

Code: Select all

Dialogue: 0,0:03:36.75,0:03:39.29,Default,,0000,0000,000DD

3) I used two videos here (they should have the same duration time, otherwise adjust time by adding another variable yourself), notice that you have to change location to what suits you, i.e. file:///C:/Users/***/Downloads/***/Example.mp4.
4) You will get an xspf file in the folder that the java class is in. Which you can open in vlc.


There's room for a lot of improvement, but I just wanted to share if someone is interested.


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 10 guests