How can I find the length of an audio file with QTP?.
Question ID: 104753
1
0

I have a test requirementto see how long an audio file is. I have never worked with media files and no clue on how to figure this out

Marked as spam
Posted by (Questions: 17, Answers: 5)
Asked on December 13, 2012 10:21 pm
118 views
Answers (1)
2
Private answer

You can use VBScipting to invoking the Windows Media Player.

Here is sample code:


Dim oWMP,  AudioPath, lDuration

AudioPath = ''C:temptest.mp3''
Set oWMP = CreateObject(''WMPlayer.OCX.7'')

oWMP.settings.autoStart = false
oWMP.settings.volume = 20  ' 0 - 100
oWMP.settings.balance = 0  ' -100 to 100
oWMP.settings.enableErrorDialogs = True
oWMP.enableContextMenu = true
oWMP.mediaCollection.add(AudioPath)
oWMP.URL=AudioPath
' Following to display player and have it on independ thread
'oWMP.openPlayer(AudioPath)
owmp.enabled=true
'Following is used to play audio  comment it out if you do not want audio played
oWMP.controls.play

lDuration =oWmp.currentMedia.duration

msgbox lDuration
If lDuration <> 0 Then
	msgbox ''Duration  > 0''
Else
	msgbox ''Duration Equals 0''
End If

oWMP.controls.stop
'following will close player if not using OpenPlayer method.
oWMP.close
SET oWMP=nothing

Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on December 13, 2012 10:24 pm
0
I see you are using mp3 files. will this work with other file types?
( at December 13, 2012 10:26 pm)
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top