PlaySound will only play up to a 48.69s wav file
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: PlaySound will only play up to a 48.69s wav file

  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 02:20 PM.

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,998

    Re: PlaySound will only play up to a 48.69s wav file

    Nobody wants to download an app to debug. Post the code in question (using CODE TAGS) for a faster response.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Oct 2009
    Posts
    34

    Re: PlaySound will only play up to a 48.69s wav file

    Quote Originally Posted by dglienna View Post
    Nobody wants to download an app to debug. Post the code in question (using CODE TAGS) for a faster response.
    Sorry

    The reason I did was to include the 4 wav files.

    I have edited my first post and included ONLY the wav files for download.

    Thanks for looking.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,517

    Re: PlaySound will only play up to a 48.69s wav file

    Quote Originally Posted by BriansBrain View Post
    I have edited my first post and included ONLY the wav files for download.
    Please, attach the zip archive file with the .wav to your post! So no one will need to download something unknown from some unknown sites.
    Victor Nijegorodov

  5. #5
    Join Date
    Oct 2009
    Posts
    34

    Re: PlaySound will only play up to a 48.69s wav file

    Quote Originally Posted by VictorN View Post
    Please, attach the zip archive file with the .wav to your post! So no one will need to download something unknown from some unknown sites.
    I originaly tried to upload to the Forum but I always get this ERROR.

    This is why I used External sites.

    I have even tried the files one at once and 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.
    Attached Images Attached Images  
    Last edited by BriansBrain; May 5th, 2014 at 02:21 PM.

  6. #6
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,998

    Re: PlaySound will only play up to a 48.69s wav file

    Just shorten the sound by 4/5 or so. Then both should be under 500
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Oct 2009
    Posts
    34

    Re: PlaySound will only play up to a 48.69s wav file

    Quote Originally Posted by dglienna View Post
    Just shorten the sound by 4/5 or so. Then both should be under 500
    LOL........ I need to play longer files........ this is why I posted my problem.

  8. #8
    Join Date
    Oct 2009
    Posts
    34

    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.

    Any ideas.

  9. #9
    Join Date
    Oct 2009
    Posts
    34

    Re: PlaySound will only play up to a 48.69s wav file

    I installed Windows XP Professional SP3 32-bit Black Edition on a spare system.

    Same problem playing the wav files.

    Baffled.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center