PC Review


Reply
Thread Tools Rate Thread

Playing a sound when a form opens

 
 
Mike
Guest
Posts: n/a
 
      24th Jul 2003
When a form opens, I use a call to play a wav file using Media Player with
the following code:

Song = "c:\program files\windows media player\mplayer2.exe
c:\Bully\MyWavFile.wav"
Call Shell(Song, vbMinimizedNoFocus)

This works OK and it keeps Media Player minimized when the file plays. But
is there a way in Access to then close media player altogether so that it
does not stay open (although minimized) in the toolbar? Or, is there a
better way to play the wav file altogether?

Thanks!
Mike


 
Reply With Quote
 
 
 
 
Ron Weiner
Guest
Posts: n/a
 
      24th Jul 2003
For the life of me I can't even imagine why you'd want to do this but:

Add the following declare and const to a Module

Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_FILENAME = &H20000

From he place where you are doing a shell do:

Call PlaySound("c:\Bully\MyWavFile.wav", 0, SND_FILENAME)

This will play the sound without loading the media player

Ron W

"Mike" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> When a form opens, I use a call to play a wav file using Media Player with
> the following code:
>
> Song = "c:\program files\windows media player\mplayer2.exe
> c:\Bully\MyWavFile.wav"
> Call Shell(Song, vbMinimizedNoFocus)
>
> This works OK and it keeps Media Player minimized when the file plays. But
> is there a way in Access to then close media player altogether so that it
> does not stay open (although minimized) in the toolbar? Or, is there a
> better way to play the wav file altogether?
>
> Thanks!
> Mike
>
>



 
Reply With Quote
 
 
 
 
Wayne Gillespie
Guest
Posts: n/a
 
      24th Jul 2003
On Thu, 24 Jul 2003 09:43:06 -0400, "Mike" <(E-Mail Removed)> wrote:

>When a form opens, I use a call to play a wav file using Media Player with
>the following code:
>
>Song = "c:\program files\windows media player\mplayer2.exe
>c:\Bully\MyWavFile.wav"
>Call Shell(Song, vbMinimizedNoFocus)
>
>This works OK and it keeps Media Player minimized when the file plays. But
>is there a way in Access to then close media player altogether so that it
>does not stay open (although minimized) in the toolbar? Or, is there a
>better way to play the wav file altogether?
>
>Thanks!
>Mike
>


http://www.mvps.org/access/api/api0011.htm
has code from Dev Ashish to play wav files using API's that works well.


Wayne Gillespie
Gosford NSW Australia
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SOUND sound SOUND sound SOUND sound !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! =?Utf-8?B?amFjayBiYXVlcg==?= Microsoft Powerpoint 10 31st Jan 2007 08:10 PM
Sound distortion with WMP9/MovieMaker2 playing AVIs [CMI8738 onboard sound and DX sound hardware acceleration] George R. Windows XP MovieMaker 2 8th Jul 2003 11:35 PM
Sound distortion with WMP9/MovieMaker2 playing AVIs [CMI8738 onboard sound and DX sound hardware acceleration] George R. Windows XP General 2 8th Jul 2003 11:35 PM
Sound distortion with WMP9/MovieMaker2 playing AVIs [CMI8738 onboard sound and DX sound hardware acceleration] George R. Windows XP Video 2 8th Jul 2003 11:35 PM
Sound distortion with WMP9/MovieMaker2 playing AVIs [CMI8738 onboard sound and DX sound hardware acceleration] George R. Windows XP Hardware 2 8th Jul 2003 11:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:17 AM.