Results 1 to 6 of 6

Thread: Playing WAVs RES files

  1. #1
    Guest

    Post

    How do you play a wav sound that is embeded in a resource file? (And how do you stop it playing!!)

    I'd rather not have to save it to disk first, if at all possible.

    ------------------
    Matthew Ralston
    E-Mail: m.ralston@mediavault.co.uk
    ICQ:31422892
    Web Sites:The Blue Link My Home Page (Not up at the moment!)

  2. #2
    Guest

    Post

    Doesn't matter, I've figured it out myself...

    ------------------
    Matthew Ralston
    E-Mail: m.ralston@mediavault.co.uk
    ICQ:31422892
    Web Sites:The Blue Link My Home Page (Not up at the moment!)

  3. #3
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    let us in on the secret then!

  4. #4
    Guest

    Post

    Mark Sreeves Analyst Programer Softlab A BMW Group Company not know this?

    Is your job title as cool as it sounds? Or is it just a great name for a boring overated job?

    Nuf chat...

    Resource file compiled with vb app, wave sound to play has a resource id string of 101...
    Code:
    Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Private Const SND_ASYNC = &H1
    Private Const SND_NODEFAULT = &H2
    Private Const FLAGS = SND_ASYNC And SND_NODEFAULT
    
    
    Public Sub PlayWavResource(pintResourceID As Integer)
        Dim bytArr() As Byte
        Dim intFFN As Integer
        Dim strPath As String
        bytArr = LoadResData(pintResourceID, "CUSTOM")
        strPath = App.Path & IIf(Right(App.Path, 1) = "\", "~tempwav.wav", "\~tempwav.wav")
        intFFN = FreeFile
        Open strPath For Binary As intFFN
        Put #intFFN, , bytArr
        Close #intFFN
        Call sndPlaySound(strPath, FLAGS)
        Kill strPath
    End Sub
    Unfortuantely it does copy the wave to a temp file first, we'll just have to put up with it...

    ------------------
    Matthew Ralston
    E-Mail: m.ralston@mediavault.co.uk
    ICQ:31422892
    Web Sites:The Blue Link My Home Page (Not up at the moment!)


    [This message has been edited by matthewralston (edited 01-07-2000).]

  5. #5
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Not exactly:
    Code:
    Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Private Const SND_ASYNC = &H1
    Private Const SND_NODEFAULT = &H2
    Private Const FLAGS = SND_ASYNC And SND_NODEFAULT
    
    
    Public Sub PlayWavResource(pintResourceID As Integer)
        Dim bytArr() As Byte
        Dim intFFN As Integer
        Dim strPath As String
        bytArr = LoadResData(pintResourceID, "CUSTOM")
        Call sndPlaySound(StrConv(bytArr, vbUnicode), FLAGS)
    End Sub

    ------------------

    Serge

    Software Developer
    Access8484@aol.com
    ICQ#: 51055819



  6. #6
    Guest

    Post

    Cool!

    ------------------
    Matthew Ralston
    E-Mail: m.ralston@mediavault.co.uk
    ICQ:31422892
    Web Sites:The Blue Link My Home Page (Not up at the moment!)

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