[AccessD] How to play mp3 audio files
Kostas Konstantinidis
kost36 at otenet.gr
Thu Nov 23 06:37:31 CST 2017
Hi Gustav,
It breaks on
Private Declare Function GetShortPathName Lib "kernel32" Alias
"GetShortPathNameA" ( _
ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal lBuffer As Long) _
As Long
So I guess it needs Private PtrSafe Declare Function... for version 64b
With "insert" I meant how to get the audio clip into the form?
Many thanks
/kostas
-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
Gustav Brock
Sent: Thursday, November 23, 2017 1:20 PM
To: Access Developers discussion and problem solving
<accessd at databaseadvisors.com>
Subject: Re: [AccessD] How to play mp3 audio files
Hi Kostas
Not sure what you mean with "insert", but for playback this has worked for
me:
<code>
Option Compare Text
Option Explicit
Private Declare PtrSafe 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
Private Declare Function GetShortPathName Lib "kernel32" Alias
"GetShortPathNameA" ( _
ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal lBuffer As Long) _
As Long
Private CurrentFile As String
Private PlayStatus As Long
Public Sub StartSound(ByVal AudioFile As String)
CurrentFile = GetShortPath(AudioFile)
PlayStatus = mciSendString("play " & CurrentFile, 0&, 0, 0)
End Sub
Public Sub StopSound(Optional ByVal AudioFile As String)
If AudioFile = "" Then
AudioFile = CurrentFile
End If
PlayStatus = mciSendString("close " & AudioFile, 0&, 0, 0)
End Sub
Public Function GetShortPath( _
ByVal LongPath As String) _
As String
Dim Length As Long
Dim Buffer As String
Dim Path As String
' Find buffer size.
Length = GetShortPathName(LongPath, "", 0)
If Length > 0 Then
' Create the buffer.
Buffer = String(Length, vbNullChar)
' Retrieve the short pathname.
Length = GetShortPathName(LongPath, Buffer, Length)
' Remove the trailing null character.
Path = Left(Buffer, Length)
End If
GetShortPath = Path
End Function
</code>
/gustav
-----Oprindelig meddelelse-----
Fra: AccessD [mailto:accessd-bounces at databaseadvisors.com] På vegne af
Kostas Konstantinidis
Sendt: 23. november 2017 10:24
Til: 'Access Developers discussion and problem solving'
<accessd at databaseadvisors.com>
Emne: [AccessD] How to play mp3 audio files
Hi all,
Does anybody know how to insert and play audio clips into ms access forms?
Thank's
/kostas
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
More information about the AccessD
mailing list