.net - get duration of .mp4 file -
i making application in .net(vb) in display list of video files (.mp4). want show duration of each file well. couldn't find way how got duration of mp4 file. please provide , hint or guideline.
you can extract file attributes , duration of particular file.this function help:
function getduration(byval moviefullpath string) string if file.exists(moviefullpath) dim objshell object = createobject("shell.application") dim objfolder object = _ objshell.namespace(path.getdirectoryname(moviefullpath)) each strfilename in objfolder.items if strfilename.name = path.getfilename(moviefullpath) return objfolder.getdetailsof(strfilename, 21).tostring exit exit function end if next return "" else return "" end if end function
and call function like
dim myduration string = getduration("c:\somepath\somevideooraudiofile.avi")
hope helps!!
updates:
in case of using different operating system xp,you should make small changed aboce code..
if using windows 7, change
dim myduration string = getduration("c:\somepath\somevideooraudiofile.avi")
to
return objfolder.getdetailsof(strfilename, 36).tostring
.
for windows vista use return objfolder.getdetailsof(strfilename, 27).tostring
Comments
Post a Comment