¿Qué funciones están disponibles dentro de Delphi para reproducir un archivo de sonido?¿Cómo reproducir un archivo wav en Delphi?
Respuesta
Aquí es la manera más rápida:
uses MMSystem;
procedure TForm1.Button1Click(Sender: TObject);
begin
sndPlaySound('C:\Windows\Media\Tada.wav',
SND_NODEFAULT Or SND_ASYNC Or SND_LOOP);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
sndPlaySound(nil, 0); // Stops the sound
end;
sndPlaySound existe para compatibilidad con versiones anteriores solo – Ampere
¿Funciona este procedimiento en FireMonkey? En caso afirmativo, ¿funcionará en otras plataformas que no sean Windows? –
Un tutorial completo está disponible en: http://sheepdogguides.com/dt3f.htm
Es un poco viejo. Pero debería funcionar
Sí, todavía funciona en 2009. –
Con la sndPlaySound función de la API de Win32 (Unidad MMSystem):
sndPlaySound ('C: \ Windows \ Media \ Tada.wav', SND_ASYNC);
sndPlaySound existe para compatibilidad con versiones anteriores solo – Ampere
Esta página explica bastante bien cómo utilizar el sndPlaySound función y la forma de integrar el archivo WAV como recurso: http://www.latiumsoftware.com/en/delphi/00024.php
El enlace ya no está actualizado. –
Es una pena, pero aún es posible acceder a través de archive.org: http://web.archive.org/web/20080509074922/http://www.latiumsoftware.com/en/delphi/00024.php – Name
+1 ; Gracias por la actualización. –
simple:
procedure PlaySoundFile(FileName: string);
begin
if FileExists(FileName)
then PlaySound(pchar(FileName), 0, SND_ASYNC or SND_FILENAME);
{ Flags are:
SND_SYNC =0 = Start playing, and wait for the sound to finish
SND_ASYNC =1 = Start playing, and don't wait to return
SND_LOOP =8 = Keep looping the sound until another sound is played }
end;
Las personas también están citando sndPlaySound, pero esto es solo por compatibilidad con versiones anteriores. Entonces, ¡no lo use!
Usted puede también estar interesado en esto:
procedure PlayWinSound(SystemSoundName: string);
begin
Winapi.MMSystem.PlaySound(PChar(SystemSoundName), 0, SND_ASYNC);
end;
{ All available constants are defined in the registry under the path HKEY_CURRENT_USER -> AppEvents -> Schemes -> Apps -> .Default.
System sounds:
SystemEXCLAMATION - Note)
SystemHAND - Critical Stop)
SystemQUESTION - Question)
SystemSTART - Windows-Start)
SystemEXIT - Windows-Shutdown)
SystemASTERIX - Star)
RESTOREUP - Enlarge)
RESTOREDOWN - Shrink)
MENUCOMMAND - Menu)
MENUPOPUP - Pop-Up)
MAXIMIZE - Maximize)
MINIMIZE - Minimize)
MAILBEEP - New Mail)
OPEN - Open Application)
CLOSE - Close Application)
APPGPFAULT - Program Error)
Asterisk - played when a popup alert is displayed, like a warning message.
Calendar Reminder - played when a Calendar event is taking place.
Critical Battery Alarm - played when your battery reaches its critical level.
Critical Stop - played when a fatal error occurs.
Default Beep - played for multiple reasons, depending on what you do. For example, it will play if you try to select a parent window before closing the active one.
Desktop Mail Notif - played when you receive a message in your desktop email client.
Device Connect - played when you connect a device to your computer. For example, when you insert a memory stick.
Device Disconnect - played when you disconnect a device from your computer.
Device Connect Failed - played when something happened with the device that you were trying to connect.
Exclamation - played when you try to do something that is not supported by Windows.
Instant Message Notif - played when you receive an instant message.
Low Battery Alarm - played when the battery is running low.
Message Nudge - played when you receive a BUZZ in an instant message.
New Fax Notification - played when you receive a fax via your fax-modem.
New Mail Notification - played when you receive an email message.
New Text Message Notif - played when you receive a text message.
NFP Completion - played when the transfer of data via NFC between your Windows device and another device is completed.
NFP Connection - played when your Windows device is connecting to another device via NFC.
Notification - played when a default notification from a program or app is displayed.
System Notification - played when a system notification is displayed. }
sndPlaySound - ¿Por qué no usarlo? http://www.xtremevbtalk.com/general/35559-difference-sndplaysound-playsound.html – Ampere
Puede agregar el enlace de MSDN: https://msdn.microsoft.com/en-us/library/dd743680%28v=vs. 85% 29.aspx – EMBarbosa
Entonces, ¿por qué Embarcadero todavía usa sndPlaySound en sus proyectos más nuevos? –
- 1. Reproducir archivo WAV hacia atrás
- 2. ¿Cómo usar QtMultimedia para reproducir un archivo wav?
- 3. Uso de AudioTrack en Android para reproducir un archivo WAV
- 4. problemas para reproducir wav en Java
- 5. Reproducir wav/mp3 desde la memoria
- 6. Reproducción de un archivo .WAV en .NET
- 7. cómo obtener muestras wav de un archivo wav?
- 8. Cómo reproducir sonidos en JavaScript
- 9. ¿Puede el reproductor flash reproducir archivos .wav desde una url?
- 10. Duración de un archivo de audio MP3/wav
- 11. ¿Cómo obtener y reproducir el archivo WAV almacenado como MySQL BLOB?
- 12. Cómo reproducir un archivo de sonido
- 13. Cómo aplicar DRM en un archivo .mp3/.wav
- 14. Cómo reproducir un archivo MP3 usando NAudio
- 15. ¿Cómo reproduciría un archivo .wav con un programa de Mathematica?
- 16. Graficando/Trazando un archivo Wav java
- 17. Convertir archivo .wav a .mp3
- 18. Cómo depurar un archivo DLL en Delphi
- 19. cómo crear un archivo xml en delphi
- 20. Convertir matriz de bytes a archivo wav
- 21. ¿Cómo agregar metadatos al archivo WAV?
- 22. Cómo convertir el archivo WAV a M4A?
- 23. Cómo jugar archivos .wav con java
- 24. ¿Cómo puedo determinar qué tan fuerte sonará un archivo WAV?
- 25. ¿Cómo convierto un archivo wav a formato mp3 usando sox?
- 26. ¿Cómo unir dos archivos wav usando python?
- 27. ¿Cómo reproducir un archivo de video en Android?
- 28. ¿Cómo puedo reproducir un archivo PLS desde un sitio web?
- 29. ¿Cómo puedo escribir un archivo WAV desde una matriz de bytes en Java?
- 30. Cargue un archivo WAV con Paperclip y almacene las versiones .wav y .mp3
simple. Use MMsystem.PlaySound. Úselo así: PlaySound (pchar (FileName), 1, SND_ASYNC o SND_FILENAME); – Ampere