Link to home
Start Free TrialLog in
Avatar of justinkent
justinkentFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Obtaining Media File Length (in time)

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.

Thanks.
Avatar of WMIF
WMIF

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.

http:Q_20826708.html
http:Q_20827810.html
Avatar of justinkent

ASKER

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.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of WMIF
WMIF

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?

Thanks.
-----------------------------------------------
On Local Error Resume Next
 
Dim FF As Integer
 
FF = FreeFile()
Open Fname For Input As #FF
If Err Then
    'no access to file
Else
    '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.
Ok it seems that the winmm.dll file could be the problem now.

Will ask that as a new question.
i have a feeling that its ... nevermind.  not for a grade C.
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!

https://www.experts-exchange.com/questions/21877555/VB-MCI-winmm-dll-WAV-file-question.html
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.