Results 1 to 6 of 6

Thread: mciSendString - Play Sound from ARRAY not PATH ?

Threaded View

  1. #5
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: mciSendString - Play Sound from ARRAY not PATH ?

    To play from an array you need to load the wave file from HD into an array

    I don't know if this is loaded into an array or not but once you load it you can play it many times by referring to it's alias name meaning you can load more than one wave file and give each one a different alias

    Code:
    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
     (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As _
     Integer, ByVal hwndCallback As Integer) As Integer
    
    Dim myFile(0 To 10) As String
    
    Private Sub Form_Load()
     myFile(0) = Chr(34) & App.Path & "\your_wave_file.wav" & Chr(34)
    End Sub
    
    Private Sub Command1_Click() 'Play
     Call mciSendString("open " & myFile(0) & " type waveaudio alias Alias1", 0&, 0, 0)
    
     mciSendString "play Alias1", 0&, 0, 0
    End Sub
    
    Private Sub Command2_Click() 'Pause
     mciSendString "pause Alias1", vbNullString, 0, 0
    End Sub
    
    Private Sub Command3_Click() 'Resume
     mciSendString "resume Alias1", vbNullString, 0, 0
    End Sub
    
    Private Sub Command4_Click() 'Stop
     mciSendString "stop Alias1", vbNullString, 0, 0
    End Sub
    
    Private Sub Command5_Click() 'Close
     mciSendString "close Alias1", vbNullString, 0, 0
    End Sub
    I think if you want total control over the wave files like you suggested above you will probably need to use the waveIn/waveOut APIs
    Last edited by jmsrickland; Feb 24th, 2016 at 08:56 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

Tags for this Thread

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