|
-
Apr 7th, 2007, 02:25 PM
#1
Thread Starter
Lively Member
Playing Music
How Can I Play Music Just Normal MP3 Music Without Using
Windows Media Player.
Thnx In Advance
-
Apr 7th, 2007, 10:29 PM
#2
Addicted Member
Re: Playing Music
you could use the Windows Media Player control, and set visible to false
-
Apr 8th, 2007, 06:59 AM
#3
Re: Playing Music
See our Classic VB FAQs (in the FAQ forum, or via the link in my signature) for examples of a few methods.
-
Apr 8th, 2007, 07:48 AM
#4
Thread Starter
Lively Member
Re: Playing Music
Aah Ok Thnx
-
Apr 8th, 2007, 02:28 PM
#5
Re: Playing Music
Two ways that you might find helpful are the sndPlaySound API and the MMControl that can be added in VB.
sndPlaySound
This function plays the sound specified by 'lpszPlaySound' parameter. This function is limited to .wav files. An example of use is shown below.
VB Code:
Option Explicit
' Plays the sound specified by
' lpszPlaySound. This function is
' limited to .wav files.
Private Declare Function sndPlaySound _
Lib "winmm.dll" _
Alias "sndPlaySoundA" ( _
ByVal lpszSoundName As String, _
ByVal uFlags As Long) _
As Long
Private Const SND_NOWAIT As Long = &H2000 ' Don't wait if the driver is busy
Private Const SND_SYNC As Long = &H0 ' Play synchronously (default)
Private Const SND_FLAGS As Long = SND_SYNC Or SND_NOWAIT ' Combination of two constants above
Private Sub Command1_Click()
' Call sndPlaySound to play our file
Call sndPlaySound(App.Path & "\Chimes.wav", SND_FLAGS)
End Sub
MMControl
This is a control that can be added through Visual Basic 6.0 by going to Project > Components and selecting 'Microsoft Multimedia Control 6.0'. This control can play a mixture of sound types and is of more use than sndPlaySound if you are playing music through VB. An example on using this is below:
VB Code:
Private Sub Form_Load()
With MMControl1
.FileName = App.Path & "\Sound.wma" ' Set the file to be played
.Command = "Open" ' Open the file
.Command = "Play" ' Play the file
End With
End Sub
Hope this is of some help
-
Apr 8th, 2007, 02:41 PM
#6
Re: Playing Music
I hope you don't mind Jenova, but I copied your post to the FAQ thread (as your methods weren't in it already).
-
Apr 8th, 2007, 02:44 PM
#7
Re: Playing Music
No that's fine . Thanks a lot
-
Apr 9th, 2007, 03:15 PM
#8
Thread Starter
Lively Member
Re: Playing Music
Aah This Is What I Searched For 
Yhnnxx Man Reaaly Thnx
-
Apr 10th, 2007, 09:33 AM
#9
Thread Starter
Lively Member
Re: Playing Music
No Errors, But It Doesnt Play The Music
Does It Only Works For .Wav Sounds
Cuz I Wanted To Play .MP3 Files
VB Code Code:
Call sndPlaySound("C:\Documents and Settings\Administrator\My Documents\My Music\Other\Wai A Pasi.mp3", SND_FLAGS)
-
Apr 10th, 2007, 09:39 AM
#10
Re: Playing Music
 Originally Posted by XCustoms
Does It Only Works For .Wav Sounds
Yes:
 Originally Posted by Jenova
sndPlaySound
.. This function is limited to .wav files.
Try a different method.
-
Apr 10th, 2007, 09:46 AM
#11
Thread Starter
Lively Member
Re: Playing Music
MP3 File Worked But Only With MMControl But Not Normal 
I Want To Create My Own Button
-
Apr 10th, 2007, 02:57 PM
#12
Re: Playing Music
When you say Create your own button can you be more specific? Do you mean you want to press a button and play the file? If that is the case you just need to use the code that i showed you before in a button click event.
VB Code:
Private Sub Command1_Click()
With MMControl1
.FileName = App.Path & "\Sound.wma" ' Set the file to be played
.Command = "Open" ' Open the file
.Command = "Play" ' Play the file
End With
End Sub
Hope this helps
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|