|
 |
access thread: Close Application
Message #1 by "Maha Arupputhan Pappan" <mahap@p...> on Tue, 29 Jan 2002 05:55:31
|
|
Hi all,
I am using Access XP. I have coded this in the "On Load" event of a form.
Dim myMusic As String
Dim myMusicPath As String
Dim myPath As String
Dim myMusicStart As String
Dim RetVal
myMusic = "track2.mp3"
myMusicPath = "c:\temp\download\home\mp3s\"
myPath = "C:\Program Files\Winamp\Winamp.exe "
myMusicStart = myPath & myMusicPath & myMusic
RetVal = Shell(myMusicStart, vbHide)
Each time the form is loaded the music starts. That's OK. Now I need to
close or exit the music each time the form is closed. How can I do that?
Thanks,
Maha
Message #2 by John Fejsa <John.Fejsa@h...> on Wed, 30 Jan 2002 08:44:36 +1100
|
|
I prefer using API calls to control muiltimedia. Find encluded code I use
to play sound on startup in hidden mode.
Form code
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Private Sub Form_Load()
On Error GoTo Err_Form_Load
Dim a As Long
Dim strFile As String
strDBPath =3D libCurrentDBPath
strFile =3D strDBPath & "start.wav"
a =3D libfPlayMultimediaFile(strFile, 1) ' don't wait for finish
Exit_Form_Load:
Exit Sub
Err_Form_Load:
MsgBox Error$, vbCritical, "Error Loading Splash Screen!"
Resume Exit_Form_Load
End Sub
Various functions to help you manipulate multimedia output
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Option Compare Database
Option Explicit
Public Const pcsSYNC =3D 0 ' wait until sound is finished playing
Public Const pcsASYNC =3D 1 ' don't wait for finish
Public Const pcsNODEFAULT =3D 2 ' play no default sound if sound doesn't
exist
Public Const pcsLOOP =3D 8 ' play sound in an infinite loop (until
next libPlaySound)
Public Const pcsNOSTOP =3D 16 ' don't interrupt a playing sound
'Sound APIs
Private Declare Function libPlaySound Lib "Winmm.dll" Alias "sndPlaySoundA"
_
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
'AVI APIs
Private Declare Function libmciSendString Lib "Winmm.dll" Alias "mciSendStr
ingA" _
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Declare Function libmciGetErrorString Lib "Winmm.dll" _
Alias "mciGetErrorStringA" (ByVal dwError As Long, _
ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
Function libfPlayMultimediaFile(ByVal strFileName As String, _
Optional intPlayMode As Integer) As Long
On Err GoTo Err_libfPlayMultimediaFile
'Purpose: Play multimedia file
'Accepts: the complete file name including the extension
'Returns: error code
'Note: MUST pass a filename _with_ extension
' Supports Wav, AVI, MID type files
'Author: John Fejsa
'Date Created: 25/10/2001
'Last Modified: 25/10/2001
'Modified by: John Fejsa
Dim lngRet As Long
Dim strTemp As String
Select Case LCase(libfGetFileExt(strFileName))
Case "wav":
If Not IsMissing(intPlayMode) Then
lngRet =3D libPlaySound(strFileName, intPlayMode)
Else
MsgBox "Must specify play mode."
Exit Function
End If
Case "avi", "mid":
strTemp =3D String$(256, 0)
lngRet =3D libmciSendString("play " & strFileName, strTemp,
255, 0)
End Select
libfPlayMultimediaFile =3D lngRet
Exit_libfPlayMultimediaFile:
Exit Function
Err_libfPlayMultimediaFile:
MsgBox "Error playing requested file.", vbCritical, "libHCHC -
libfPlayMultimediaFile Function!"
Resume Exit_libfPlayMultimediaFile
End Function
Function libfStopMultimediaFile(ByVal strFileName As String)
On Err GoTo Err_libfStopMultimediaFile
'Purpose: Stop multimedia playback
'Author: John Fejsa
'Date Created: 25/10/2001
'Last Modified: 25/10/2001
'Modified by: John Fejsa
'Accepts: the complete file name including the extension
'Returns: error code
'Note: MUST pass a filename _with_ extension
' Supports Wav, AVI, MID type files
Dim lngRet As Long
Dim strTemp As String
Select Case LCase(libfGetFileExt(strFileName))
Case "wav":
lngRet =3D libPlaySound(0, pcsASYNC)
Case "avi", "mid":
strTemp =3D String$(256, 0)
lngRet =3D libmciSendString("stop " & strFileName, strTemp,
255, 0)
End Select
libfStopMultimediaFile =3D lngRet
Exit_libfStopMultimediaFile:
Exit Function
Err_libfStopMultimediaFile:
MsgBox "Error stoping multimedia playback.", vbCritical, "libHCHC -
libfStopMultimediaFile Function!"
Resume Exit_libfStopMultimediaFile
End Function
Private Function libfGetFileExt(ByVal strFullPath As String) As String
On Err GoTo Err_libfGetFileExt
'Purpose: Retrieve file extension
'Author: John Fejsa
'Date Created: 25/10/2001
'Last Modified: 25/10/2001
'Modified by: John Fejsa
'Accepts: the complete file name including the extension
'Returns: text file extension
Dim intPos As Integer, intLen As Integer
intLen =3D Len(strFullPath)
If intLen Then
For intPos =3D intLen To 1 Step -1
'Find the last \
If Mid$(strFullPath, intPos, 1) =3D "." Then
libfGetFileExt =3D Mid$(strFullPath, intPos + 1)
Exit Function
End If
Next intPos
End If
Exit_libfGetFileExt:
Exit Function
Err_libfGetFileExt:
MsgBox "Error getting file extension.", vbCritical, "libHCHC -
libfGetFileExt Function!"
Resume Exit_libfGetFileExt
End Function
Function libfGetError(ByVal lngErrNum As Long) As String
On Err GoTo Err_libfGetError
'Purpose: Translate the error code to a string
'Author: John Fejsa
'Date Created: 25/10/2001
'Last Modified: 25/10/2001
'Modified by: John Fejsa
'Accepts: long error code
'Returns: string error code
Dim lngx As Long
Dim strErr As String
strErr =3D String$(256, 0)
lngx =3D libmciGetErrorString(lngErrNum, strErr, 255)
strErr =3D Left$(strErr, Len(strErr) - 1)
libfGetError =3D strErr
Exit_libfGetError:
Exit Function
Err_libfGetError:
MsgBox "Error converting error code number to string.", vbCritical,
"libHCHC - libfGetError Function!"
Resume Exit_libfGetError
End Function
I hope that will help you...
____________________________________________________
John Fejsa
Systems Analyst/Computer Programmer
Hunter Centre for Health Advancement
Locked Bag 10
WALLSEND NSW 2287
Phone: (02) 49246 336 Fax: (02) 49246 209
____________________________________________________
The doors we open and close each day decide the lives we live
____________________________________________________
CONFIDENTIALITY & PRIVILEGE NOTICE
The information contained in this email message is intended for the named
addressee only. If you are not the intended recipient you must not copy,
distribute, take any action reliant on, or disclose any details of the
information in this email to any other person or organisation. If you
have received this email in error please notify us immediately.
>>> mahap@p... 29/01/2002 16:55:31 >>>
Hi all,
I am using Access XP. I have coded this in the "On Load" event of a form.
Dim myMusic As String
Dim myMusicPath As String
Dim myPath As String
Dim myMusicStart As String
Dim RetVal
myMusic =3D "track2.mp3"
myMusicPath =3D "c:\temp\download\home\mp3s\"
myPath =3D "C:\Program Files\Winamp type files
Dim lngRet \Winamp.exe "
myMusicStart =3D myPath & myMusicPath & myMusic
RetVal =3D Shell(myMusicStart, vbHide)
Each time the form is loaded the music starts. That's OK. Now I need to
close or exit the music each time the form is closed. How can I do that?
Thanks,
Maha
This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient,
please delete it and notify the sender. Views expressed in this message are those of the individual sender, and are not necessarily
the views of Hunter Health.
|
|
 |