WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sound and Media

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Music Length


Question:

I searched for posts and tech articles about mp3s and couldn't find what I really want (or just didn't understand it). What I want to do is read whatever property info I need from an mp3 file and calculate the actual play time for that file. Any help on this subject would be appreciated.

Answer:

file = "c:\temp\my.mp3"
device = "sequencer"
ext = strupper(fileextension(file))
if ext == "MP3" then device = "mpegvideo"
if ext == "WAV" then device = "waveaudio"

pm = PlayMedia(strcat("open ",device,"!",filenameshort(file)," alias music"))
errormode(@cancel)
	if pm == ""
	Playmedia("close music")
	Message("Error","This file is an invalid format")
	list = ""
	filecount = itemcount(list," ")
	return("error")
endif

Playmedia("set music time format ms")
l = Playmedia("status music length")/1000
l = TimeAdd("1:1:1:0:0:0",strcat("0:0:0:0:0:",l))
m = itemextract(5,l,":")+0
s = itemextract(6,l,":")
Message(file,StrCat("Length = ",m,":",s))

See Also:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP+Get~Audio~File~Information.txt


Article ID:   W16718
File Created: 2014:07:18:09:51:40
Last Updated: 2014:07:18:09:51:40