Results 1 to 4 of 4

Thread: playing music

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Post

    how do you play music in VB? eg. How do you get a file to play, and how do you get it to stop.

    Regards,
    Alexander McAndrew

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    You can use MS Multimedia Control.

    Private Sub Form_Load ()

    MMControl1.Notify = False
    MMControl1.Wait = True
    MMControl1.DeviceType = "CDAudio"
    MMControl1.Command = "Open"

    End Sub

    Private Sub Form_Unload (Cancel as Integer)

    Form1.MMControl1.Command = "Close"

    End Sub

    ------------------
    smalig
    [email protected]
    smalig.tripod.com

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Post

    thanks for replying! Unfortunatley though, I don't really understand what that does, and how I can choose what file to play. Also, what is MMControl1? I once saw some simple code that looked SOMETHING liked the following:

    open "C:\whatever.wav" for something

    something like that. Does that give you any ideas? Thanks for all of your help,
    ALexander McAndrew

  4. #4
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    The code from above for audio CD.

    The Multimedia control allows you to manage Media Control Interface (MCI) devices. These devices include: sound boards, MIDI sequencers, CD-ROM drives, audio players, videodisc players, and videotape recorders and players.

    Select References under the Project menu, and add a reference to the "Microsoft Multimedia Control" by checking the appropriate box.

    If you want to play a wav file with MS Multimedia control you can use follow code. Add Microsoft CommonDialog Control, Microsoft Multimedia Control and Command Button to your form. Put this code to your form.

    ---------------
    Private Sub Command1_Click()

    On Error Resume Next

    With CommonDialog1
    .Filter = "Wav Files|*.wav"
    .ShowOpen
    If Err.Number = cdlCancel Then Exit Sub
    MMControl1.FileName = .FileName
    End With

    MMControl1.Command = "Open"

    End Sub

    Private Sub Form_Load()

    Command1.Caption = "Play"

    With MMControl1
    .Notify = False
    .Wait = True
    .Shareable = False
    .DeviceType = "WaveAudio"
    End With

    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    MMControl1.Command = "Close"
    End Sub
    ---------------

    Also you can play with API (look sample here).

    ------------------
    smalig
    [email protected]
    smalig.tripod.com

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