Click to See Complete Forum and Search --> : playing music
spandex44
Nov 14th, 1999, 10:13 PM
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
smalig
Nov 14th, 1999, 10:24 PM
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
smalig@hotmail.com
smalig.tripod.com (http://smalig.tripod.com)
spandex44
Nov 15th, 1999, 02:54 AM
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
smalig
Nov 15th, 1999, 03:33 PM
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 (http://smalig.tripod.com/vb/079911.html)).
------------------
smalig
smalig@hotmail.com
smalig.tripod.com (http://smalig.tripod.com)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.