VLCKit "lengthWait" not returning a value

This forum is about all development around libVLC.
orbosphere
New Cone
New Cone
Posts: 4
Joined: 18 Jul 2020 16:10

VLCKit "lengthWait" not returning a value

Postby orbosphere » 18 Jul 2020 16:23

Hello,

I am trying to use VLCKit / TVVLCKit on an iOS/tvOS project.

I would like to be able to scan through a list of VLCMedia items and identify the length (duration) of the video file ahead of time, prior to playing the videos.

I am first ensuring each item is parsed with the following:

Code: Select all

media.parse(withOptions: VLCMediaParsingOptions(VLCMediaFetchNetwork))
but even after parsing has completed and the

Code: Select all

mediaDidFinishParsing
delegate method has been called, logging

Code: Select all

media.length
or

Code: Select all

media.length.verboseStringValue
does not seem to work- Im just seeing a length string of "--:--"

However, if I take a VLCMedia item, play it, and then check the length, I then see the correct duration. This works:

Code: Select all

let mediaList = VLCMediaList() mediaList.add(media) vpc.playMediaList(mediaList, firstIndex: 0, subtitlesFilePath: nil) navigationController?.show(VLCFullscreenMovieTVViewController.init(), sender: nil) DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { NSLog("this item length: \(media.length.verboseStringValue)") }
However, the time delay in the asyncAfter call does matter- I also tried 0.1 seconds, and that resulted in no value- just "--:--"


I've also attempted using lengthWait prior to playing the file like so:

Code: Select all

let length = media.lengthWait(until: Date().addingTimeInterval(10.0))
This is not working for me either.

Ultimately my question is:
I'd like to know if there are any other strategies to identifying a VLCMedia item's length/duration without actually playing the file. It seems the length info is only available after loading the file to play, calling

Code: Select all

media.parse(withOptions:
or

Code: Select all

media.lengthWait(until:
do not seem to work for me. The files I am using are on the local network and are made available via SMB1.

If I need to "queue" up the item to play it, without actually playing it, to get the length info, I could potentially work with that. I only need to do this once when adding a file to my app's "library" and I can store the value. It seems like "media.lengthWait(until:" should be what I need, but even adding a very long wait time doesn't seem to produce a result for me.

Please let me know if there are any other strategies to get a media item's length value without actually playing it. I'd really appreciate it!

Thank you.

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: VLCKit "lengthWait" not returning a value

Postby Jean-Baptiste Kempf » 19 Jul 2020 18:36

What is the format of the files?
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.

orbosphere
New Cone
New Cone
Posts: 4
Joined: 18 Jul 2020 16:10

Re: VLCKit "lengthWait" not returning a value

Postby orbosphere » 19 Jul 2020 19:44

What is the format of the files?
I have tried .avi, .mkv, and .mp4, and the results appear to be the same. lengthWait isn't getting me anything even with a long wait time. But if I play the file and check the media's length a second later, then it appears to have the correct value.


All the files tested have been shared via the same drive on the network via SMB. Navigating the shared directory on that drive or playing files from it all appears to be responsive/quick.

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: VLCKit "lengthWait" not returning a value

Postby Jean-Baptiste Kempf » 21 Jul 2020 18:02

And does it work fine for local files?
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.

orbosphere
New Cone
New Cone
Posts: 4
Joined: 18 Jul 2020 16:10

Re: VLCKit "lengthWait" not returning a value

Postby orbosphere » 22 Jul 2020 04:09

And does it work fine for local files?
Yes- I just tested with a local .mov file. The value provided by lengthWait was fast and accurate.


Any idea how I could retrieve a length of a file over the network without actually playing it? I short delay is acceptable to me.

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: VLCKit "lengthWait" not returning a value

Postby Jean-Baptiste Kempf » 28 Jul 2020 10:13

And does it work fine for local files?
Yes- I just tested with a local .mov file. The value provided by lengthWait was fast and accurate.


Any idea how I could retrieve a length of a file over the network without actually playing it? I short delay is acceptable to me.

There should be a parsing flag for that, on the preparsing function
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.

orbosphere
New Cone
New Cone
Posts: 4
Joined: 18 Jul 2020 16:10

Re: VLCKit "lengthWait" not returning a value

Postby orbosphere » 28 Jul 2020 14:38

And does it work fine for local files?
Yes- I just tested with a local .mov file. The value provided by lengthWait was fast and accurate.


Any idea how I could retrieve a length of a file over the network without actually playing it? I short delay is acceptable to me.

There should be a parsing flag for that, on the preparsing function


I thought I had already tried this, but I must have done something wrong before. I just tested:

Code: Select all

media.parse(withOptions: VLCMediaParsingOptions(VLCMediaParseNetwork))
and sure enough my subsequent calls of:

Code: Select all

let length = media.lengthWait(until: Date().addingTimeInterval(6.0))
are now providing the correct length of my network files. Success!

Thank you for the help.

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: VLCKit "lengthWait" not returning a value

Postby Jean-Baptiste Kempf » 29 Jul 2020 11:02

Yes !
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 “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 5 guests