Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I launch a .wav file with windows media player minimized to play for 10 sec when in Microsoft Access when a form loads?

Posted on 2007-04-10
10
Medium Priority
?
610 Views
Last Modified: 2010-06-07
How do I launch a .wav file with windows media player minimized to play for 10 sec when in Microsoft Access when a form loads?
0
Comment
Question by:tkschultz1207
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 15

Expert Comment

by:OMC2000
ID: 18881558
record 10 seconds wav file
in starter module/form open another small form first, open player, set property minimized, specify file to play and start playing.
with the next statement in starter module open your form which takes 10 seconds to get loaded, when it is loaded you might call function from the form, which started started media player to close it and then close that form too.

You could also use MCI32.OCX instead of windows media player.
0
 
LVL 13

Accepted Solution

by:
wiswalld earned 2000 total points
ID: 18881741
Create a module with this
Option Compare Database
Declare Function MessageBeep Lib "user32.dll" (ByVal wType As Long) As Long
Public MySound() As Long ' return value
'wType
Public Const MB_ICONASTERISK = &H40
'Play the SystemAsterisk sound.
Public Const MB_ICONEXCLAMATION = &H30
'Play the SystemExclamation sound.
Public Const MB_ICONHAND = &H10
'Play the SystemHand sound.
Public Const MB_ICONQUESTION = &H20
'Play the SystemQuestion sound.
Public Const MB_OK = &H0
'Play the SystemDefault sound.
Public Const MB_REGULAR = &HFFFFFFFF
'Play a regular beep
Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal LpszSoundName As String, ByVal hMod As Long, ByVal uFlags As Long) As Long
Option Explicit

Public Function PlayWavFile(strPath As String)
    Dim snd_async As Long
    Call PlaySound(strPath, 0, snd_async)
End Function

On open or whatever call this code:

Call PlayWavFile("C:\your wav file")
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 18881765
How long is your wave file now? If u cut it down to 10 seconds (u can still use the good old windows recorder for that), u can simply call this api


Private Declare Function sndPlaySoundA Lib "WINMM.DLL" (ByVal lpszSoundName As String, ByVal ValueFlags As Long) As Long

Global Const SND_ASYNC = &H1
Global Const SND_NODEFAULT = &H2


Public Sub PlayWaveFile(ByVal sFile As String)
  Dim lRet As Long
  lRet = sndPlaySoundA(sFile, SND_ASYNC Or SND_NODEFAULT)
End Sub


Add the above code to a module and call the function PlayWaveFile
eg

PlayWaveFile "c:\fred.wav"

note its asynchronous so function will return even though music still playing in the background
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 65

Expert Comment

by:rockiroads
ID: 18881780
Sorry wiswalld, your post wasnt there when I started typing
0
 

Author Comment

by:tkschultz1207
ID: 18882862
I don't have time to record just ten seconds, is there a way in code I can say stop executing that file after say the timer is up on the form?
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 18883113
Ok, on form_load u play the sound, obviously and set the form's timer to kick in after 10 seconds

then to stop playing the music, u add the code to in the form_timer event

private sub form_timer
    stopthatwavefile
end sub


and the code posted earlier to play a wave file? add this in

Public Sub StopWaveFile()
  Dim lRet As Long
  lRet = sndPlaySoundA(vbNullString, SND_ASYNC)
End Sub

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 18883119
>> I don't have time to record just ten seconds

sound recorder does it for you, u simply move the timer to 10secs then use the menu command to trim the rest then save as
its as simple as that
less than 2 mins work
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 18883130
ok, I see you accepted whilst I was answering your other question
I guess you must of figured it out then
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 18883222
tkschultz1207, just out of curiosity, would you mind telling us how u went about solving the problem of 10 seconds play only?
0
 

Author Comment

by:tkschultz1207
ID: 18888687
Sorry, I accepted the answer before you answered about the 10 seconds. I ended up not cutting the .wav file to 10 seconds and just played the entire .wav on close of the form which ended up being fine, since my presentation was due at 11am Texas time. Thanks for your help.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question