Play audio files in access

Source: Internet
Author: User
Technorati label: Access, sound

There are three methods. One is to use the playsound function in winmm. It seems that only wav files can be played, the other is to use ShellExecute, and the other is to use a media player in the Microsoft Office 11.0 Object Library. I only use the first one, and the last two are temporarily recorded here for memo.

First, use the playsound function in winmm.

  1. Declare function apisndplaysound lib "winmm" alias "sndplaysounda" (byval filename as string, byval snd_async as long) as long
  2. Function playsound (swavfile as string)
  3. If apisndplaysound (swavfile, 1) = 0 then
  4. Msgbox "the sound did not play! "
  5. End if
  6. End Function

You can call the above function during actual playback:

  1. Playsound ("C:/Windows/Media/chimes. wav ")

Second: Use ShellExecute. From

Here

  1. Private declare function ShellExecute lib "shell32.dll" alias "shellexecutea" (byval hwnd as long, byval lpoperation as string, byval lpfile as string, byval lpparameters as string, byval lpdirectory as string, byval nshowcmd as long) as long
  2. Private declare function findwindow lib "USER32" alias "find0000wa" (byval lpclassname as string, byval lpwindowname as string) as long
  3. Private declare function postmessage lib "USER32" alias "postmessagea" (byval hwnd as long, byval wmsg as long, byval wparam as long, lparam as any) as long
  4. Private const wm_close = & h10' close
  5. Available 'lpoperation parameters: open, print, find, release E, and edit
  6. 'Nshowcmd parameter window mode type declaration
  7. Private const sw_hide = 0
  8. Private const sw_shownormal = 1
  9. Private const sw_showminimized = 2
  10. Private const sw_showmaximized = 3
  11. Private const sw_shownoactivate = 4
  12. Private const sw_show = 5
  13. Private const sw_minimize = 6
  14. Private const sw_showminnoactive = 7
  15. Private const sw_showna = 8
  16. Private const sw_restore = 9
  17. Private sub command0_click ()
  18. 'Open and play
  19. ShellExecute me. hwnd, "open", "dj-i said I love you dj", "", "d:/kugoo", sw_hide
  20. End sub
  21. Private sub commandementclick ()
  22. 'Close
  23. Dim hwnd as long
  24. Hwnd = findwindow (vbnullstring, "Windows Media Player ")
  25. Postmessage hwnd, wm_close, 0 &, 0 &
  26. End sub

Third: Use a media player. View

Here

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.