libvlc and setting time/position

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
simontam
New Cone
New Cone
Posts: 1
Joined: 18 Mar 2007 02:44

libvlc and setting time/position

Postby simontam » 18 Mar 2007 05:20

I'm using nativeVlc.cs (C#) to access libvlc. I have a video that I want to start playback at X amount of time into the video.

For some reason the code I have here works but only after you have begun playing the video once. The first time you play the video it starts at the very beginning. Subsequent calls adhere to the time setting and video playback begins at the time specified. Any ideas what's wrong? Also note that if I use Play(item) it completely ignores the time altogether.


if (textBox1.Text != "")
{
this.nativeVlc.Time = Convert.ToInt32(textBox1.Text);
}
this.nativeVlc.AddTarget("c:\\temp\\foo.mpg", null, ref item);
//this.nativeVlc.Play(item);
this.nativeVlc.Play();

Tappen
Cone that earned his stripes
Cone that earned his stripes
Posts: 150
Joined: 30 Oct 2006 07:55

Postby Tappen » 22 Mar 2007 00:59

VLC doesn't know how long an item is, or how to seek within it, till it's started. You have to wait till you see the status is playing before you can set the time. Vlc is multi-threaded, so it's an asynchronous thing you have to poll for.

You can try using a parameter in the AddTarget call:

"--start-time=" + Convert.ToInt32(textBox1.Text)

or maybe

":start-time=" + Convert.ToInt32(textBox1.Text)

I'm never sure whether -- or : is more likely to work in parameters when scripting. This should work for playing an .mpg file on the hard-disk but I know this parameter won't work for DVD tracks.

Spellcoder
Blank Cone
Blank Cone
Posts: 57
Joined: 19 Apr 2006 12:21
Location: Hengelo // The Netherlands
Contact:

Postby Spellcoder » 22 Mar 2007 13:24

With the Mozilla plugin/Javascript I have no problem in using :start-time with DVD's in the options with 0.8.6 and 0.9.0. (I use dvdread:// as protocol to play DVD).

I can't imagine it should make a difference whether you use it in the Mozilla plugin or ActiveX with C#, because the options are parsed by VLC.

One thing you have to look out for though is that :start-time works with seconds, while the seeking methods use the time in milliseconds.
my hideout: http://www.spellcoder.nl
my VLC bugreports: https://trac.videolan.org/vlc/query?rep ... spellcoder
likes coding, designing, WoW, VLC&plugin, Amiga's and Mac's & fluffy cats


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 8 guests