how do i use windows media player on my form?

andrew_perez5

Registered User.
Local time
Today, 03:14
Joined
Jan 3, 2005
Messages
12
I need some help from u guys? I have a form with many fields in coulmnar form. One of those fields contains a string path to a wav file on a certain directory.What i need is that once I select a record from the form,then click a certain button, a program(Maybe Windows media player or other player) will play the wav file on the selected path. I understand i might need to add some active x control to be able to do this. Can anybody help me with this pls?
 
you can simply use a hyperlink to play the wav you want.
 
Copy this into a public module...

Code:
Option Compare Database 
Option Explicit 

'PlayWaveFile 
Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal filename As String, ByVal snd_async As Long) As Long 

Public Function PlayWaveFile(sWavFile As String) 
If apisndPlaySound(sWavFile, 1) = 0 Then 
'MsgBox "The Sound Did Not Play!" 
End If 
End Function 

Public Sub PlayWaveFile_Cord() 
Call PlayWaveFile("C:\Windows\Media\chord.wav") 
End Sub
My example will play the standard 'chord' wave file. To call it from another event in your db, just use this...

Code:
Call PlayWaveFile_Cord
Just modify the Call PlayWaveFile("C:\Windows\Media\chord.wav") to point where your files are located based on the value in a text box like Call PlayWaveFile([YourTextBoxNameHere])
 
Thanks

Thanks for the code. Your amazing, I'm gonna try something more and if i have problems, I'll post again. Thanks.....
 
I tried your code and its working. My problem is on my form, i have a lot of records displayed and each row of record represents a path and filename to play.What i need is when i select a record from the list by using the record selector on the left side, i will be able to get the path and filename then play it by using a button by calling "Call PlayWaveFile("path.wav")". If its ok with you to let me send you my mdb file or if its really possible?Can we build an event on the record selector so i can pass the path to a variable?

Bon
 
Since you are using a continuos form you can create a command button to the left or right end of the record and assign the code I listed above Call PlayWaveFile([YourTextBoxNameHere]) to the command button. When the user clicks the command button for the record of their choice it will play the wave at the location from that records text box value.
 
Ayt, i got it. What if i need a player to play the wav file like windows media player? Based on the code you gave me, it'll just play the wav file without knowing the status. I might need a player for it since the wav files that im dealing with here are lengthy files that will take 20 mins or more. This are wav files from call center conversations, i need this so the user or administrator can stop playing the file anytime and maybe review only some critical parts of the conversations. Do you have any idea?

Thank you and I'll appreciate any response!
 
I do not know how to use the Windows Media Player with Access. I looked and there are bunch of Windows Media Player "references" but I have never had the need to use the Windows Media Player with Access nor have I ever seen any postings related to the subject.

Please post back if you find a solution for I just might need it one day. ;)

Good luck!
 
how about, dya know a code that can stop the wavefile from playing? Or maybe pause it?
 
Hey ghudson,

I got it. I never thought, how simple it is. Just add a windows media player control on your form then this is the code for playing.


'windows media player : name : md
'microsoft common dialog6.0 : name : cd
'command button : name : open
'command button : name : play

Private Sub Command1_Click()
cd.Filter = "Mp3|*.mp3|midi|*.mid|wav|*.wav"
cd.ShowOpen
End Sub

Private Sub Command2_Click()
md.FileName = cd.FileName
md.Play
End Sub


The Filename property will not appear as a property of the Media Player control(when u press (.) dot) but it will work.

I found this on www.vbcode.com which uses the same code for MS Access.

Thanks anyways for all your help!

Bo :) n
 
I can not find the code you mention at that link. Can you post all the code you are using to make it work? Thanks!
 
Here is my code.
txt_path - a string variable that i declare on a module
path - a textbox control with a value the comes from a table
Form_frm_Call_Information - my parent form name
wmp - the name of my windows media player control
path - a textbox control that holds a value that came from a table

Option Compare Database


Private Sub Form_Click()
path.SetFocus
txt_path = path.Text
Form_frm_Call_Information.wmp.filename = txt_path
End Sub

Private Sub Form_DblClick(Cancel As Integer)
path.SetFocus
txt_path = path.Text
Form_frm_Call_Information.wmp.filename = txt_path
Form_frm_Call_Information.wmp.Play
End Sub

Private Sub Form_Load()
path.SetFocus
txt_path = path.Text

End Sub



try to visit http://www.vbcode.com then search for windows media player on the search box under Search Database.

Thanks

Bon
 

Users who are viewing this thread

Back
Top Bottom