[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Obtaining Media File Length (in time)

Posted on 2006-06-01
Medium Priority
Last Modified: 2008-02-01
I have an asp application, part of which runs digital dictation. I currently have the audio files, (in WAV format), listed on an asp page for secretaries to download, the file names of which are obtained directly from the directory the audio file sits in.

I want to be able to for each of the audio files show the length of the dictation, (audio file), but after hours of scouring the web, this does not seem an easy task.

Can anyone here provide the solution to doing the same. I am running Windows Server 2003, with IIS6. I have Windows Media Player 9 installed.

Question by:justinkent
  • 5
  • 4
LVL 22

Expert Comment

ID: 16808720
you will not be able to do this only with asp.  you will need to find, purchase, or create your own dll for the asp page to access.  here are a couple questions in the vb topic area which you could use to package up into a dll.


Author Comment

ID: 16843763
Thanks, but it doesn't help.

I would not even know how to begin to write my own dll, nor know what to make it do.

It seems there is a lot of script out there to do what I need, however, it is nearly all based in pure VB6 and/or using MCI, none of which can be run in an asp page.

Any further assistance would helpful.

LVL 22

Accepted Solution

WMIF earned 600 total points
ID: 16843932
>>It seems there is a lot of script out there to do what I need, however, it is nearly all based in pure VB6...

that is correct.  in full VB, you have access to objects like this.  asp is just a watered down scripting version of vb.  vb can create the dll's, and asp can access the dll's to use vb's capabilities.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 16849541
OK, I've found some code on this site and used it to create a dll which I've registered and ASP can use:

Private Declare Function mciSendString Lib "winmm.dll" _
      Alias "mciSendStringA" (ByVal lpstrCommand As String, _
      ByVal lpstrReturnString As String, ByVal uReturnLength As _
      Long, ByVal hwndCallback As Long) As Long
Function WavLength(FileName)

    Dim i As Long, RS As String, cb As Long
    RS = Space$(128)
    i = mciSendString("stop sound", RS, 128, cb)
    i = mciSendString("close sound", RS, 128, cb)
    i = mciSendString("open waveaudio!" & FileName & " Alias sound", RS, 128, cb)
    i = mciSendString("status sound length", RS, 128, cb)
    WavLength = RS
    i = mciSendString("stop sound", RS, 128, cb)
    i = mciSendString("close sound", RS, 128, cb)
End Function

This works well with one problem:
if the following file name is passed by the asp page:   "\\server-iis\wavlocation\wavfile.wav"  the dll works fine. However, using,
"\\server-2\wavlocation\wavfile.wav" the dll does not return anything at all.

server-iis is the local machine that iis and the dll resides on.  server-2 is a remote machine on the LAN.  

Using Windows Explorer or Windows Media player on the local machine, (server-iis), I can gain access and play the wav file on the remote machine so it doesn't seem to be a general file permissions problem?


Author Comment

ID: 16849689
On Local Error Resume Next
Dim FF As Integer
FF = FreeFile()
Open Fname For Input As #FF
If Err Then
    'no access to file
    'access to file
End If
Close #FF

Further investigation showed that adapting the above code into the dll produced no errors, meaning that the dll file has got access to the wav file on the remote server.  However, no sound length value is being returned.

Author Comment

ID: 16850723
Ok it seems that the winmm.dll file could be the problem now.

Will ask that as a new question.
LVL 22

Expert Comment

ID: 16853542
i have a feeling that its ... nevermind.  not for a grade C.

Author Comment

ID: 16853749
Grade C AND 300 points!  ;o)  

Bearing in mind also that you only basically advised that I needed to create a dll and provided no assistance when I said that I had no idea how to create one!  I spent 8 hours last night finding out how to create one myself and posted the code here!  

Never mind, I can't please everyone!  Have posted a new question and if you solve that, I'll grade it higher!

LVL 22

Expert Comment

ID: 16853884
actually 600 points, but its not about the points for me.  a grade c is an insult on this site.

creating dll's and accessing them through asp is not my expertise, and im not going to lie about it.  i would have continued to help you troubleshoot though had you given me the chance.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question