By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,855 Members | 1,988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,855 IT Pros & Developers. It's quick & easy.

Playing Sound Clip

P: n/a
I use the following code to play WAV files from Access. Is there a method to
play MP3 files from an Access event or control.:
'************************************************* ****
Option Compare Database
Option Explicit

Declare Function sndplaysound Lib "WINMM.DLL" Alias "sndPlaySoundA" (ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long
Dim soundName As String
Dim WFlags As Integer
Dim x As Integer

Const SND_SYNC = &H0
Const snd_async = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10
Function PlayIt(soundName$)
Dim myPath As String
myPath = GetPath()

soundName$ = myPath & soundName$
WFlags% = snd_async
x% = sndplaysound(soundName$, WFlags%)
End Function
'************************************************* *****
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Mon, 19 Sep 2005 09:31:04 -0400, "Johnny M" <ne**@solutionsbymiller.com> wrote:
I use the following code to play WAV files from Access. Is there a method to
play MP3 files from an Access event or control.:
'************************************************ *****
Option Compare Database
Option Explicit

Declare Function sndplaysound Lib "WINMM.DLL" Alias "sndPlaySoundA" (ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long
Dim soundName As String
Dim WFlags As Integer
Dim x As Integer

Const SND_SYNC = &H0
Const snd_async = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10
Function PlayIt(soundName$)
Dim myPath As String
myPath = GetPath()

soundName$ = myPath & soundName$
WFlags% = snd_async
x% = sndplaysound(soundName$, WFlags%)
End Function
'************************************************ ******


Hi
I use

Dim i As Long
i = mciSendString("close voice1", 0&, 0, 0) 'precautionary
i = mciSendString("Open " & AudioPath & " Alias voice1", 0&, 0, 0)
i = mciSendString("play voice1", 0&, 0, 0)

where mciSendString is

Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As
String, ByVal lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As
Long
Nov 13 '05 #2

P: n/a
Thanks I got this function to work but it appears to require no spaces in
the name of the file or directory. Is there a work around for this?

Johnny

"polite person" <ge*******@ease.com> wrote in message
news:4g********************************@4ax.com...
On Mon, 19 Sep 2005 09:31:04 -0400, "Johnny M"
<ne**@solutionsbymiller.com> wrote:
I use the following code to play WAV files from Access. Is there a method
to
play MP3 files from an Access event or control.:
'*********************************************** ******
Option Compare Database
Option Explicit

Declare Function sndplaysound Lib "WINMM.DLL" Alias "sndPlaySoundA" (ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long
Dim soundName As String
Dim WFlags As Integer
Dim x As Integer

Const SND_SYNC = &H0
Const snd_async = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10
Function PlayIt(soundName$)
Dim myPath As String
myPath = GetPath()

soundName$ = myPath & soundName$
WFlags% = snd_async
x% = sndplaysound(soundName$, WFlags%)
End Function
'*********************************************** *******


Hi
I use

Dim i As Long
i = mciSendString("close voice1", 0&, 0, 0) 'precautionary
i = mciSendString("Open " & AudioPath & " Alias voice1", 0&, 0, 0)
i = mciSendString("play voice1", 0&, 0, 0)

where mciSendString is

Public Declare Function mciSendString Lib "winmm.dll" Alias
"mciSendStringA" (ByVal lpstrCommand As
String, ByVal lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal
hwndCallback As Long) As
Long

Nov 13 '05 #3

P: n/a
On Wed, 21 Sep 2005 16:52:55 -0400, "Johnny M" <ne**@solutionsbymiller.com> wrote:
Thanks I got this function to work but it appears to require no spaces in
the name of the file or directory. Is there a work around for this?

Johnny

Hi
call with extra quotes eg

AudioPath = """C:/funny name.mp3"""
"polite person" <ge*******@ease.com> wrote in message
news:4g********************************@4ax.com.. .
On Mon, 19 Sep 2005 09:31:04 -0400, "Johnny M"
<ne**@solutionsbymiller.com> wrote:
I use the following code to play WAV files from Access. Is there a method
to
play MP3 files from an Access event or control.:
'********************************************** *******
Option Compare Database
Option Explicit

Declare Function sndplaysound Lib "WINMM.DLL" Alias "sndPlaySoundA" (ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long
Dim soundName As String
Dim WFlags As Integer
Dim x As Integer

Const SND_SYNC = &H0
Const snd_async = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10
Function PlayIt(soundName$)
Dim myPath As String
myPath = GetPath()

soundName$ = myPath & soundName$
WFlags% = snd_async
x% = sndplaysound(soundName$, WFlags%)
End Function
'********************************************** ********


Hi
I use

Dim i As Long
i = mciSendString("close voice1", 0&, 0, 0) 'precautionary
i = mciSendString("Open " & AudioPath & " Alias voice1", 0&, 0, 0)
i = mciSendString("play voice1", 0&, 0, 0)

where mciSendString is

Public Declare Function mciSendString Lib "winmm.dll" Alias
"mciSendStringA" (ByVal lpstrCommand As
String, ByVal lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal
hwndCallback As Long) As
Long


Nov 13 '05 #4

P: n/a
Actually, I seem to recall it requires a short file name: it's not just the
spaces it's complaining about!

Check out http://www.mvps.org/access/api/api0020.htm at "The Access Web" for
how to determine the short file name for a given long file name.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Johnny M" <ne**@solutionsbymiller.com> wrote in message
news:IKjYe.88310$Zp.47317@lakeread04...
Thanks I got this function to work but it appears to require no spaces in
the name of the file or directory. Is there a work around for this?

Johnny

"polite person" <ge*******@ease.com> wrote in message
news:4g********************************@4ax.com...
On Mon, 19 Sep 2005 09:31:04 -0400, "Johnny M"
<ne**@solutionsbymiller.com> wrote:
I use the following code to play WAV files from Access. Is there a method
to
play MP3 files from an Access event or control.:
'********************************************** *******
Option Compare Database
Option Explicit

Declare Function sndplaysound Lib "WINMM.DLL" Alias "sndPlaySoundA"
(ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long
Dim soundName As String
Dim WFlags As Integer
Dim x As Integer

Const SND_SYNC = &H0
Const snd_async = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10
Function PlayIt(soundName$)
Dim myPath As String
myPath = GetPath()

soundName$ = myPath & soundName$
WFlags% = snd_async
x% = sndplaysound(soundName$, WFlags%)
End Function
'********************************************** ********


Hi
I use

Dim i As Long
i = mciSendString("close voice1", 0&, 0, 0) 'precautionary
i = mciSendString("Open " & AudioPath & " Alias voice1", 0&, 0, 0)
i = mciSendString("play voice1", 0&, 0, 0)

where mciSendString is

Public Declare Function mciSendString Lib "winmm.dll" Alias
"mciSendStringA" (ByVal lpstrCommand As
String, ByVal lpstrReturnString As Any, ByVal uReturnLength As Long,
ByVal hwndCallback As Long) As
Long


Nov 13 '05 #5

P: n/a
Thanks I used the getshortname function and it worked fine.

Johnny
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:kK********************@rogers.com...
Actually, I seem to recall it requires a short file name: it's not just
the spaces it's complaining about!

Check out http://www.mvps.org/access/api/api0020.htm at "The Access Web"
for how to determine the short file name for a given long file name.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Johnny M" <ne**@solutionsbymiller.com> wrote in message
news:IKjYe.88310$Zp.47317@lakeread04...
Thanks I got this function to work but it appears to require no spaces in
the name of the file or directory. Is there a work around for this?

Johnny

"polite person" <ge*******@ease.com> wrote in message
news:4g********************************@4ax.com...
On Mon, 19 Sep 2005 09:31:04 -0400, "Johnny M"
<ne**@solutionsbymiller.com> wrote:

I use the following code to play WAV files from Access. Is there a
method to
play MP3 files from an Access event or control.:
'********************************************* ********
Option Compare Database
Option Explicit

Declare Function sndplaysound Lib "WINMM.DLL" Alias "sndPlaySoundA"
(ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long
Dim soundName As String
Dim WFlags As Integer
Dim x As Integer

Const SND_SYNC = &H0
Const snd_async = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10
Function PlayIt(soundName$)
Dim myPath As String
myPath = GetPath()

soundName$ = myPath & soundName$
WFlags% = snd_async
x% = sndplaysound(soundName$, WFlags%)
End Function
'********************************************* *********

Hi
I use

Dim i As Long
i = mciSendString("close voice1", 0&, 0, 0) 'precautionary
i = mciSendString("Open " & AudioPath & " Alias voice1", 0&, 0, 0)
i = mciSendString("play voice1", 0&, 0, 0)

where mciSendString is

Public Declare Function mciSendString Lib "winmm.dll" Alias
"mciSendStringA" (ByVal lpstrCommand As
String, ByVal lpstrReturnString As Any, ByVal uReturnLength As Long,
ByVal hwndCallback As Long) As
Long



Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.