Here is my simple wav file tester I have made in VB6 to show the problem I am getting.
General Declarations
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 Sub Form_Load()
Code:
Dim TimerNOW As Date
Const SND_NODEFAULT = &H2 ' Stops the SystemDefault sound playing if this file cannot be found
Const SND_SYNC = &H0 ' Do not return until the sound has finished playing.
Dim wFlags As Long
wFlags = SND_SYNC Or SND_NODEFAULT
TimerNOW = Timer
PlaySound App.Path & "\Tone 44100Hz, 16 bit Mono, 48.690s.wav", ByVal 0&, wFlags
Debug.Print "File Length: 48.690s <-> Play Time: " & Format(Timer - TimerNOW, "00.000") & "s"
DoEvents
TimerNOW = Timer
PlaySound App.Path & "\Tone 44100Hz, 16 bit Mono, 49.000s.wav", ByVal 0&, wFlags
Debug.Print "File Length: 49.000s <-> Play Time: " & Format(Timer - TimerNOW, "00.000") & "s"
DoEvents
TimerNOW = Timer
PlaySound App.Path & "\Tone 44100Hz, 16 bit Mono, 60.000s.wav", ByVal 0&, wFlags
Debug.Print "File Length: 60.000s <-> Play Time: " & Format(Timer - TimerNOW, "00.000") & "s"
DoEvents
TimerNOW = Timer
PlaySound App.Path & "\Tone 44100Hz, 16 bit Mono, 90.000s.wav", ByVal 0&, wFlags
Debug.Print "File Length: 90.000s <-> Play Time: " & Format(Timer - TimerNOW, "00.000") & "s"
These are my results from the Debug.Print on WinXP system... File Length: 48.690s <-> Play Time: 48.798s
File Length: 49.000s <-> Play Time: 00.703s
File Length: 60.000s <-> Play Time: 22.656s
File Length: 90.000s <-> Play Time: 82.641s
I can't see what the problem is in my code.
BTW: My 4 wav files were made with Cool Pro and ALL work perfect to the end in every other player
Here are the 4 wav files incase someone wan't to try them.
Please note I can't upload them to the Forum even one file at a time as I get this ...
Code:
<forums.codeguru.com>
The following errors occurred:
wav-1.zip: Your file of 1.45 MB bytes exceeds the forum's limit
of 500.0 KB for this filetype.
Re: PlaySound will only play up to a 48.69s wav file
Just tried it on a system with Windows 2000 SP4
+ Different sound board.
Same problem
44100, 16 bit Mono File Length: 49.000s only Plays for: 00.688s
After some tests...
It does not matter if the wav files are Mono or Stereo, 41000 or 22050.
If they are longer than 4193kb then the playing time problem happens.
So it is the file size limitation in XP and Win 2000 when using PlaySound with the SND_SYNC flag.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.