Lembit Soobik
Lembit.Soobik at t-online.de
Mon Oct 13 10:58:38 CDT 2003
BerichtI found that I have changed it to mci, but I remember at the beginning I had used Playsound, jsut cnnot find whether I have the old code still somewhere. anyway, if youare interested, here is the module with MCI. -------------------------------------------- Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal _ lpszCommand As String, ByVal lpszReturnString As String, ByVal cchReturnLength _ As Long, ByVal hwndCallback As Long) As Long Public Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal _ fdwError As Long, ByVal lpszErrorText As String, ByVal cchErrorText As Long) As Long Public Function DisplayError(ByVal errcode As Long) ' This subroutine displays a dialog box with the text of the MCI error. There's ' no reason to use the MessageBox API function; VB's MsgBox function will suffice. Dim errstr As String ' MCI error message text Dim retval As Long ' return value ' Get a string explaining the MCI error. errstr = Space(128) retval = mciGetErrorString(errcode, errstr, Len(errstr)) ' Remove the terminating null and empty space at the end. errstr = Left(errstr, InStr(errstr, vbNullChar) - 1) ' Display a simple error message box. retval = MsgBox(errstr, vbOKOnly Or vbCritical) End Function Public Function lsPlayMusic(strFilePath As String) As Boolean ' Open the file "C:\Music\MusicPlaying.mid" for later use in the example. ' Give it an alias of "MusicPlaying" so we don't need to refer to the filename again. ' Begin playback of the MIDI file when this button is pressed. Dim errcode As Long ' MCI error code Dim strOpen As String Debug.Print strFilePath If strFilePath <> "" Then strOpen = "open """ & strFilePath & """ alias MusicPlaying" Else Exit Function End If errcode = mciSendString(strOpen, "", 0, 0) If errcode <> 0 Then DisplayError errcode errcode = mciSendString("play MusicPlaying", "", 0, 0) If errcode <> 0 Then lsPlayMusic = False 'DisplayError errcode Else lsPlayMusic = True End If End Function Public Function lsPlayMusicToEnd(strFilePath As String) As Boolean ' Open the file. ' Give it an alias of "MusicPlaying" so we don't need to refer to the filename again. Dim errcode As Long ' MCI error code Dim strOpen As String If strFilePath <> "" Then strOpen = "open """ & strFilePath & """ alias MusicPlaying" Else Exit Function End If errcode = mciSendString(strOpen, "", 0, 0) If errcode <> 0 Then DisplayError errcode ' Begin playback of the file. The 'wait' keyword causes MCIsendString to return after ' the playback is finished errcode = mciSendString("play MusicPlaying wait", "", 0, 0) ' Stop playback of the file. errcode = mciSendString("stop MusicPlaying", "", 0, 0) ' Close the file. This is important, because the ' driver can only work with one file at a time. There's no need to check ' for an error here, since we're just closing the file. errcode = mciSendString("close MusicPlaying", "", 0, 0) If errcode <> 0 Then DisplayError errcode End Function Public Function lsStopMusic() As Boolean ' Stop playback of the file. Dim errcode As Long ' MCI error code errcode = mciSendString("stop MusicPlaying", "", 0, 0) If errcode <> 0 Then lsStopMusic = False 'DisplayError errcode Else lsStopMusic = True End If ' Close the file. This is important, because the ' driver can only work with one file at a time. There's no need to check ' for an error here, since we're just closing the file. errcode = mciSendString("close MusicPlaying", "", 0, 0) End Function Public Function lsOpenFileForMusic() lsOpenFileForMusic = GetFilePath(, "|mp3 Files|*.mp3|WAV Files|*.wav") End Function -------------------------------------------- Lembit Soobik ----- Original Message ----- The Windows Media player control plays MP3/WMA , but I stoppped using that because I had some delay on it (using .WAV). This when loading the file. Erwin hmmmm... I did not realize there is a problem. I will dig into the code tomorrow and let you all know. it is a pretty old db and I have since modified that part, but I rmember Playsound to work with mp3 as well as wav. too late today. Lembit Lembit Soobik ----- Original Message ----- ...how did you manage that Lembit ...I get an error if I spec anything other than a wav file? William Hindman -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20031013/265b5037/attachment-0001.html>