Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   WaveOutOpen (https://www.clubdelphi.com/foros/showthread.php?t=70107)

JerS 30-09-2010 04:54:25

WaveOutOpen
 
Amigos necesito ayuda con el componente WaveOutOpen, me gustaria saber como utilizarlo para reproducir unos sonidos .wav que tengo guardados en algunas carpetas en mi pc desde mi aplicacion

Neftali [Germán.Estévez] 30-09-2010 09:53:07

¿Puedes dar algunos detalles más sobre este componente?
¿Página Web? ¿Es Free? ¿Lo puedes subir al FTP?

Sólo con el nombre es difícil adivinar más...

JerS 30-09-2010 20:47:45

Amigo Neftali fijate en este Hilo hacen referencia a esta Api

http://www.clubdelphi.com/foros/show...oducir+sonidos

Neftali [Germán.Estévez] 01-10-2010 10:41:30

He encontrado este código por Internet.
Ya te adelanto que no es mío y no lo he probado ya que en este equipo no dispongo del dispositivo adecuado.

Pruébalo y ya dirás...


Código Delphi [-]
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    TMS: TMemoryStream;
    wavOutDevice:Boolean;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses
  MMSystem;


procedure TForm1.Button1Click(Sender: TObject);
begin
  {in some procedure}
  if wavOutDevice then begin
    PlaySound(TMS.Memory, 0, SND_ASYNC or SND_MEMORY);
  end;
  //add 'or SND_LOOP' to loop it
  //if others, use tmsBells.Memory, etc. instead
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  if WaveOutGetNumDevs = 0 then begin
    showmessage('No .wav output device available in your PC');
    wavOutDevice := False; //global boolean variable
  end
  else begin
    TMS := TMemoryStream.Create;
    //use next line else where to load other .wav files when you need them
    TMS.LoadFromFile('.\ding.wav'); //may need a path like 'audio\music.wav'
    wavOutDevice := True; //global boolean var
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  //turn off any sound, use this else where to do same
  PlaySound(NIL, 0, SND_ASYNC or SND_NODEFAULT);
  TMS.Free; //free memory for other app's
end;

end.

JerS 04-10-2010 21:06:10

Cita:

Empezado por Neftali (Mensaje 378101)
He encontrado este código por Internet.
Ya te adelanto que no es mío y no lo he probado ya que en este equipo no dispongo del dispositivo adecuado.

Pruébalo y ya dirás...


Código Delphi [-]type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private TMS: TMemoryStream; wavOutDevice:Boolean; public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses MMSystem; procedure TForm1.Button1Click(Sender: TObject); begin {in some procedure} if wavOutDevice then begin PlaySound(TMS.Memory, 0, SND_ASYNC or SND_MEMORY); end; //add 'or SND_LOOP' to loop it //if others, use tmsBells.Memory, etc. instead end; procedure TForm1.FormCreate(Sender: TObject); begin if WaveOutGetNumDevs = 0 then begin showmessage('No .wav output device available in your PC'); wavOutDevice := False; //global boolean variable end else begin TMS := TMemoryStream.Create; //use next line else where to load other .wav files when you need them TMS.LoadFromFile('.\ding.wav'); //may need a path like 'audio\music.wav' wavOutDevice := True; //global boolean var end; end; procedure TForm1.FormDestroy(Sender: TObject); begin //turn off any sound, use this else where to do same PlaySound(NIL, 0, SND_ASYNC or SND_NODEFAULT); TMS.Free; //free memory for other app's end; end.


Me imagino que aqui es donde selecciono que tarjeta de sonido deseo utilizar
Código Delphi [-]
   if WaveOutGetNumDevs = 0 then begin

esta bien el la selecciona pero siempre suena por la que esta por defecto, asi le cambie los valores al WaveOutGetDev en este hilo http://www.clubdelphi.com/foros/show...oducir+sonidos hablan sobre el WaveOutOpen pero de verdad que no tengo ni idea de como se utiliza

JerS 04-10-2010 23:40:11

Efectivamente cuando aplico la funcion de WaveOutGetNumDevs me devuelve el numero de Tarjetas de Sonidos que tengo instaladas, en este caso son 2.

Ahora mi duda es con que funcion puedo hacer que mi aplicacion suene por la tarjeta de sonido que yo desee!


La franja horaria es GMT +2. Ahora son las 22:51:56.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi