Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 14th, 2006, 1:57 PM   #11
Darcksky
Newbie
 
Join Date: May 2006
Posts: 18
Rep Power: 0 Darcksky is on a distinguished road
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 Sub

That'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 Sub

My 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
what should i change there?
Darcksky is offline   Reply With Quote
Old Jul 14th, 2006, 11:26 PM   #12
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
Quote:
'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
Read that again, and again, and again until you see what is wrong. But not too long, you wouldn't want to waste your time. If you need a hint, its in the first line.
Booooze is offline   Reply With Quote
Old Jul 18th, 2006, 7:01 PM   #13
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
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.
Booooze is offline   Reply With Quote
Old Jul 28th, 2006, 10:05 PM   #14
Darcksky
Newbie
 
Join Date: May 2006
Posts: 18
Rep Power: 0 Darcksky is on a distinguished road
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 ??
Darcksky is offline   Reply With Quote
Old Jul 28th, 2006, 11:47 PM   #15
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
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.
Booooze is offline   Reply With Quote
Old Jul 29th, 2006, 6:13 PM   #16
Darcksky
Newbie
 
Join Date: May 2006
Posts: 18
Rep Power: 0 Darcksky is on a distinguished road
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?
Darcksky is offline   Reply With Quote
Old Jul 29th, 2006, 6:16 PM   #17
Darcksky
Newbie
 
Join Date: May 2006
Posts: 18
Rep Power: 0 Darcksky is on a distinguished road
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?
Darcksky is offline   Reply With Quote
Old Jul 29th, 2006, 8:23 PM   #18
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
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)
  1. 'Declare a buffer to store the
  2. 'contents of the resource file
  3. Dim strBuff As String
  4. Dim strFile As String
  5.  
  6. 'Create a temp file name
  7. strFile = App.Path & "\MyTempSong.mp3"
  8.  
  9. 'Extract the file from the resource file
  10. strBuff = StrConv(LoadResData("SONG", "MP3"), vbUnicode)
  11.  
  12. 'Save the string as a file
  13. Open strFile For Output As #1
  14. Print #1, strBuff
  15. Close #1
  16.  
  17.  
  18.  
  19. Wmp.URL = App.Path & "\MyTempSong.mp3" ' load song
  20. Wmp.Controls.play 'play the song
  21.  
  22.  
  23. 'Delete your temp file
  24. 'Kill strFile
Booooze is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:58 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC