Is there any way to achieve seamless looping wav files between the "From"
and "To" properties using VB6's MM Control?
I've been using the Notify event as the cue to start playing again, but this
causes a hole in the audio.
Help!!!!
Many thanks,
Ed.
Don't use the MM control for this. Instead, call Windows' PlaySound API
function. Here's an example. Add two command buttons to a form. Command1
starts playing the sound. Command2 stops it.
-----BEGIN CODE
Option Explicit
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal
lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_ASYNC = &H1 'play asynchronously
Private Const SND_FILENAME = &H20000 'name is a file name
Private Const SND_LOOP = &H8 'loop the sound until next
sndPlaySound
Private Const SND_NODEFAULT = &H2 'silence not default, if sound not
found
Private Sub Command1_Click()
Dim sWavFileName As String
Dim lFlags As Long
'Hard-coded for example purposes only.
sWavFileName = "H:\WINNT\Media\ding.wav"
lFlags = SND_ASYNC Or SND_FILENAME Or SND_LOOP Or SND_NODEFAULT
PlaySound sWavFileName, 0&, lFlags
End Sub
Private Sub Command2_Click()
PlaySound vbNullString, 0&, SND_ASYNC
End Sub
----END CODE
This is much easier and more efficient than using the control.
Mike
Thanks,
Ed.
"MikeD" <nob...@nowhere.edu> wrote in message
news:ueWfoshT...@TK2MSFTNGP10.phx.gbl...
No. PlaySound (or sndPlaySound for that matter) can only play a .wav file
from start to finish (although playback can be stopped at anytime by calling
the function again IF the sound was played asynchronously [meaning the
function returns immediately after playback has started]). To specify
"from" and "to" points, you'd need to use MCI (not necessarily the MM
control as you can use MCI API functions) or DirectX.
PlaySound is the easiest way to play a .wav sound, but it doesn't give you
much control. It allows you to loop the sound, play it synchronously
(meaning the function doesn't return until playback has finished) or
asynchronously, but not much else.
Mike
Ed.
"MikeD" <nob...@nowhere.edu> wrote in message
news:u5zYHvoT...@TK2MSFTNGP10.phx.gbl...
"Ed" <e...@ANTISPAMtobysoft.com> wrote in message news:ca9i99$99m$1...@newsg4.svr.pol.co.uk...
"Norm Cook" <norm...@cableone.net> wrote in message
news:10cm2io...@corp.supernews.com...
MCI provides no "built-in" way to loop (like PlaySound does for a .wav
file). Even using the API, you'd have to do pretty much the same thing as
you've done with the MM control...only it's more involved because you need
to use a callback function to get notifications from MCI about playback
status (and thus determine when playback has stopped).
I have no idea if it'll help, but you might want to look into using DirectX.
I also don't know exactly what it is you're trying to do (apparently, loop
segments of .wav files, but that's just a guess). DirectX may help. I'm
not real familiar with DirectX so I can't say for sure. But you're
apparently not happy with what MCI or the PlaySound function can do, so you
may as well look into what DirectX offers.
Mike