How can I get a movie's time length in a double value without using a plugin? What would the approach look like?
Without a plugin, well load it in a MoviePlayer and ask it for the length.
Be careful as loading may be asynchronously!
dim f as FolderItem = SpecialFolder.Desktop.Child("test.m4v") dim a as AVAssetMBS = AVAssetmbs.assetWithFile(f) if a = nil then MsgBox "failed to read file at all" Return end if // request duration property a.loadValuesAsynchronouslyForKeys array("duration") dim e as NSErrorMBS dim Status as Integer = a.statusOfValueForKey("duration", e) while status < a.AVKeyValueStatusLoaded // wait for loading in background status = a.statusOfValueForKey("duration", e) wend // got it? if status <> a.AVKeyValueStatusLoaded then MsgBox "Failed to load duration." if e <> nil then MsgBox e.LocalizedDescription end if else MsgBox str(a.duration.Seconds)+" seconds long." end if
As you see we also wait for the duration to be loaded asynchronously before we report it.