![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Newbie
Join Date: May 2006
Posts: 18
Rep Power: 0
![]() |
This is my code
'the API declaration that play Wav file
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
'the LoadDataIntoFile function
Public Sub LoadDataIntoFile(DataName As Integer, FileName As String)
Dim myArray() As Byte
Dim myFile As Long
If Dir(FileName) = "" Then
myArray = LoadResData(DataName, "CUSTOM")
myFile = FreeFile
Open FileName For Binary Access Write As #myFile
Put #myFile, , myArray
Close #myFile
End If
End Sub
Private Sub Form_Load()
'copy the Wav file to c:\tmpfile.$$$
LoadDataIntoFile 101, App.Path & "\bless.wav"
'Play the Wav file using the sndPlaySound API function
sndPlaySound App.Path & "\bless.wav", 1
End Sub
Private Sub Timer1_Timer()
Unload Me
Form2.Show
End SubThat's the code for the First Form and this is for the second one.. 'the API declaration that play Wav file
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
'the LoadDataIntoFile function
Public Sub LoadDataIntoFile(DataName As Integer, FileName As String)
Dim myArray() As Byte
Dim myFile As Long
If Dir(FileName) = "" Then
myArray = LoadResData(DataName, "CUSTOM")
myFile = FreeFile
Open FileName For Binary Access Write As #myFile
Put #myFile, , myArray
Close #myFile
End If
End Sub
Private Sub Form_Load()
'copy the Wav file to c:\tmpfile.$$$
LoadDataIntoFile 102, App.Path & "\Rock.mp3"
'Play the Wav file using the sndPlaySound API function
sndPlaySound App.Path & "\Rock.mp3", 1
End SubMy Problem is the Second Form it copys the wav file to my appplication but i doesnt run or i dont hear the sound i think there is a problem in the , 1 |
|
|
|
|
|
#12 | |
|
Expert Programmer
|
Quote:
|
|
|
|
|
|
|
#13 |
|
Expert Programmer
|
lol, well in case you didn't figure it out, you're using the library and function to play wav files, not mp3s. Doesn't work.
|
|
|
|
|
|
#14 |
|
Newbie
Join Date: May 2006
Posts: 18
Rep Power: 0
![]() |
Yea i have figured out some friend told me but is there a way to Play mp3 too because i convert it to wav and i was 6mb now the music is 32MB and my project is 40mb it was like 2mb is there a way ??
|
|
|
|
|
|
#15 |
|
Expert Programmer
|
Like I said, if it's an MP3, and it's a windows program, just use windows media player control. Give it another shot. Your making more work for yourself.
|
|
|
|
|
|
#16 |
|
Newbie
Join Date: May 2006
Posts: 18
Rep Power: 0
![]() |
Can you give me the Code for Windows media Control Mixed with Resource ??
Cause Private Sub Form_Load() MMControl1.FileName = App.Path & "\intro_sound.mp3" MMControl1.Command = "Open" MMControl1.Wait = True MMControl1.Shareable = False MMControl1.Command = "Play" MMControl1.Command = "Close" End Sub interrupts my program How should i do it? |
|
|
|
|
|
#17 |
|
Newbie
Join Date: May 2006
Posts: 18
Rep Power: 0
![]() |
Can you give me the Code for Windows media Control Mixed with Resource ??
Cause Private Sub Form_Load() MMControl1.FileName = App.Path & "\intro_sound.mp3" MMControl1.Command = "Open" MMControl1.Wait = True MMControl1.Shareable = False MMControl1.Command = "Play" MMControl1.Command = "Close" End Sub interrupts my program How should i do it? |
|
|
|
|
|
#18 |
|
Expert Programmer
|
Judging by your code, It looks like you are using a different version of windows media player than I am. You have to be running 2000 or higher I think in order to use WMP v9. Regardless, here is the code I used. All it does is extracts the resource file (the song) to the location of the executable. It then plays the song. I don't see what is so hard about it that you can't grasp. Like I said, I think you are using a different version of WMP.
vb Syntax (Toggle Plain Text)
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|