Jump to content
Sign in to follow this  

_SoundLength Failing.

Recommended Posts

I've been having problems with the function _SoundLength(). _SoundLength() is failing, its not an error, but it just keeps failing. And I'm not sure why. Any help is appreciated. :) Thanks.

Here is a reproducer:

$Sound = @WindowsDir&"\Media\Notify.wav"
$Open = _SoundOpen($Sound)
MsgBox(0, "", _SoundLength($Open, 2))

Share this post

Link to post
Share on other sites

try using this

Func _SoundLength($sSnd_id, $iMode = 1)
    ;Declare variables
    Local $iSnd_len_ms, $iSnd_len_min, $iSnd_len_hour, $iSnd_len_sec, $sSnd_len_format
    ;validate $iMode
    If $iMode <> 1 And $iMode <> 2 Then Return SetError(1, 0, 0)
    ;tell mci to use time in milliseconds
    mciSendString("set " & FileGetShortName($sSnd_id) & " time format miliseconds")
    ;recieve length of sound
    $iSnd_len_ms = mciSendString("status " & FileGetShortName($sSnd_id) & " length")
    ;assign modified data to variables
    $iSnd_len_min = Int($iSnd_len_ms / 60000)
    $iSnd_len_hour = Int($iSnd_len_min / 60)
    $iSnd_len_sec = Int(Int($iSnd_len_ms / 1000) - ($iSnd_len_min * 60))
    ;assign formatted data to $sSnd_len_format
    $sSnd_len_format = StringFormat("%02i:%02i:%02i", $iSnd_len_hour, $iSnd_len_min, $iSnd_len_sec)
    ;return correct variable
    If $iMode = 1 Then Return $sSnd_len_format
    If $iMode = 2 Then Return $iSnd_len_ms
EndFunc   ;==>_SoundLength

its from 3.2.6.x

Should work fine!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...