CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Oct 2009
    Posts
    34

    Unhappy PlaySound will only play up to a 48.69s wav file

    Using API PlaySound I can't get it to play wav files longer than 48.690 seconds.

    My system is WinXP Service Pack 2 - VB6 SP5

    I need to use the SND_SYNC Flag.

    Normal PCM wav files at 44100Hz, 16 bit Mono and from the Hard Drive.

    *NOTE* wav files up to > 48.690s play perfect till the end.

    A 48.700s or longer wav file will NOT play till the end.

    BTW: In an old W98se system this problem does NOT happen.

    ===================================================================

    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.
    http://www.filedropper.com/4wavfiles
    or
    http://wikisend.com/download/284888/4wavfiles.zip

    Thanks for looking........ Any help would be fantastic.
    Last edited by BriansBrain; May 5th, 2014 at 01:20 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured