Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > API de Windows
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 03-12-2008
nandynna nandynna is offline
Registrado
 
Registrado: abr 2007
Posts: 4
Poder: 0
nandynna Va por buen camino
Desactivar y activar sonido del sistema

HOla! Les escribo porque necesito saber como hacer en delphi para desactivar o activar el sonido del sistema operativo(general), es decir manejar activando y desactivando el mute del control del volumen. busco en google, en el foro y no encuentro nada. Bueno.. si me pudieran ayudar estaria muy agradecida..salu2!
Responder Con Cita
  #2  
Antiguo 03-12-2008
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Poder: 24
seoane Va por buen camino
Cita:
Empezado por nandynna Ver Mensaje
busco en google, en el foro y no encuentro nada.
¿Probaste a buscar MUTE?

http://www.clubdelphi.com/foros/show...highlight=mute
Responder Con Cita
  #3  
Antiguo 03-12-2008
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.932
Poder: 26
delphi.com.ar Va por buen camino
Ante todo, te aclaro que lo que te estoy subiendo es un rejunte de código, que sería bueno que lo pruebes a fondo, se trata de una unit con una función genérica y dos implementaciones de esta, y un proyecto de ejemplo:

Código Delphi [-]
unit MMUtils;

interface

uses
  Windows;

procedure mmMixSetVolume(AComponentType, AValue: DWORD);
procedure mmMixSetMute(AComponentType: DWORD; AValue: boolean);

implementation

uses
  SysUtils, MMSystem;

procedure RaiseLastMMError;
begin
  { TODO : .. }
  RaiseLastOsError;
end;

procedure mmMixSetDetail(AComponentType, AControlType: DWORD; Data: Pointer; DataSize: DWORD);
var
  hMix: HMIXER;
  mxlc: MIXERLINECONTROLS;
  mxcd: TMIXERCONTROLDETAILS;
  mxc: MIXERCONTROL;
  mxl: TMixerLine;
begin
  if (mixerGetNumDevs() > 0) then
  begin
    if mixerOpen(@hMix, 0, 0, 0, 0) = MMSYSERR_NOERROR then
      try
        mxl.dwComponentType := AComponentType;
        mxl.cbStruct := SizeOf(mxl);

        if mixerGetLineInfo(hMix, @mxl, MIXER_GETLINEINFOF_COMPONENTTYPE) = MMSYSERR_NOERROR then
        begin
          ZeroMemory(@mxlc, SizeOf(mxlc));

          mxlc.cbStruct := SizeOf(mxlc);
          mxlc.dwLineID := mxl.dwLineID;
          mxlc.dwControlType := AControlType;
          mxlc.cControls := 1;
          mxlc.cbmxctrl := SizeOf(mxc);
          mxlc.pamxctrl := @mxc;

          if mixerGetLineControls(hMix, @mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE) = MMSYSERR_NOERROR then
            ZeroMemory(@mxcd, SizeOf(mxcd));
            mxcd.dwControlID := mxc.dwControlID;
            mxcd.cbStruct := SizeOf(mxcd);
            mxcd.cMultipleItems := 0;
            mxcd.cbDetails := DataSize;
            mxcd.paDetails := Data;
            mxcd.cChannels := 1;

            if mixerSetControlDetails(hMix, @mxcd, MIXER_SETCONTROLDETAILSF_VALUE) <> MMSYSERR_NOERROR then
              RaiseLastMMError;
          end else
            RaiseLastMMError;
      finally
        if mixerClose(hMix) <> MMSYSERR_NOERROR then
         RaiseLastMMError;
      end;
  end;
end;

procedure mmMixSetVolume(AComponentType, AValue: DWORD);
var
  uValue: TMIXERCONTROLDETAILS_UNSIGNED;
begin
  uValue.dwValue := AValue;
  mmMixSetDetail(AComponentType, MIXERCONTROL_CONTROLTYPE_VOLUME, @uValue, SizeOf(uValue));
end;


procedure mmMixSetMute(AComponentType: DWORD; AValue: boolean);
var
  bValue: MIXERCONTROLDETAILS_BOOLEAN;
begin
  bValue.fValue := Ord(AValue);
  mmMixSetDetail(AComponentType, MIXERCONTROL_CONTROLTYPE_MUTE, @bValue, SizeOf(bValue));
end;


end.

El proyecto de ejemplo:
Código Delphi [-]
program MMMixer;

uses
  Windows, SysUtils, MMSystem,
  MMUtils in '..\Comunes\MMUtils.pas';

begin
  { Pone el volúmen a la mitad de la escala}
  mmMixSetVolume(MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, MaxWord div 2);

  { Silencia la mezcladora }
  mmMixSetMute(MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, True);
end.

Saludos!
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.

Última edición por delphi.com.ar fecha: 03-12-2008 a las 21:06:55. Razón: Corrección del código
Responder Con Cita
  #4  
Antiguo 04-12-2008
nandynna nandynna is offline
Registrado
 
Registrado: abr 2007
Posts: 4
Poder: 0
nandynna Va por buen camino
Cita:
Empezado por seoane Ver Mensaje
Hola! muchas gracias por la pronta respuesta, lo voy a probar adaptandolo a mi programa, necesito que cuando se cliquee la imagen se habilite el mute o deshabilite. En realidad, creo que hay una sentencia (yo la use hace unos años en un programa y me funcionaba), pero lo grabé en cds que ya no se pueden leer por el paso de los años , y bueno. hoy estoy aqui.. (no hay que guardar nada en cds!!!) aviso cualquier cosa y muchas gracias de nuevo!salu2.
Responder Con Cita
  #5  
Antiguo 04-12-2008
nandynna nandynna is offline
Registrado
 
Registrado: abr 2007
Posts: 4
Poder: 0
nandynna Va por buen camino
Cita:
Empezado por delphi.com.ar Ver Mensaje
Ante todo, te aclaro que lo que te estoy subiendo es un rejunte de código, que sería bueno que lo pruebes a fondo, se trata de una unit con una función genérica y dos implementaciones de esta, y un proyecto de ejemplo:

Código Delphi [-]
unit MMUtils;

interface

uses
  Windows;

procedure mmMixSetVolume(AComponentType, AValue: DWORD);
procedure mmMixSetMute(AComponentType: DWORD; AValue: boolean);

implementation

uses
  SysUtils, MMSystem;

procedure RaiseLastMMError;
begin
  { TODO : .. }
  RaiseLastOsError;
end;

procedure mmMixSetDetail(AComponentType, AControlType: DWORD; Data: Pointer; DataSize: DWORD);
var
  hMix: HMIXER;
  mxlc: MIXERLINECONTROLS;
  mxcd: TMIXERCONTROLDETAILS;
  mxc: MIXERCONTROL;
  mxl: TMixerLine;
begin
  if (mixerGetNumDevs() > 0) then
  begin
    if mixerOpen(@hMix, 0, 0, 0, 0) = MMSYSERR_NOERROR then
      try
        mxl.dwComponentType := AComponentType;
        mxl.cbStruct := SizeOf(mxl);

        if mixerGetLineInfo(hMix, @mxl, MIXER_GETLINEINFOF_COMPONENTTYPE) = MMSYSERR_NOERROR then
        begin
          ZeroMemory(@mxlc, SizeOf(mxlc));

          mxlc.cbStruct := SizeOf(mxlc);
          mxlc.dwLineID := mxl.dwLineID;
          mxlc.dwControlType := AControlType;
          mxlc.cControls := 1;
          mxlc.cbmxctrl := SizeOf(mxc);
          mxlc.pamxctrl := @mxc;

          if mixerGetLineControls(hMix, @mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE) = MMSYSERR_NOERROR then
            ZeroMemory(@mxcd, SizeOf(mxcd));
            mxcd.dwControlID := mxc.dwControlID;
            mxcd.cbStruct := SizeOf(mxcd);
            mxcd.cMultipleItems := 0;
            mxcd.cbDetails := DataSize;
            mxcd.paDetails := Data;
            mxcd.cChannels := 1;

            if mixerSetControlDetails(hMix, @mxcd, MIXER_SETCONTROLDETAILSF_VALUE) <> MMSYSERR_NOERROR then
              RaiseLastMMError;
          end else
            RaiseLastMMError;
      finally
        if mixerClose(hMix) <> MMSYSERR_NOERROR then
         RaiseLastMMError;
      end;
  end;
end;

procedure mmMixSetVolume(AComponentType, AValue: DWORD);
var
  uValue: TMIXERCONTROLDETAILS_UNSIGNED;
begin
  uValue.dwValue := AValue;
  mmMixSetDetail(AComponentType, MIXERCONTROL_CONTROLTYPE_VOLUME, @uValue, SizeOf(uValue));
end;


procedure mmMixSetMute(AComponentType: DWORD; AValue: boolean);
var
  bValue: MIXERCONTROLDETAILS_BOOLEAN;
begin
  bValue.fValue := Ord(AValue);
  mmMixSetDetail(AComponentType, MIXERCONTROL_CONTROLTYPE_MUTE, @bValue, SizeOf(bValue));
end;


end.

El proyecto de ejemplo:
Código Delphi [-]
program MMMixer;

uses
  Windows, SysUtils, MMSystem,
  MMUtils in '..\Comunes\MMUtils.pas';

begin
  { Pone el volúmen a la mitad de la escala}
  mmMixSetVolume(MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, MaxWord div 2);

  { Silencia la mezcladora }
  mmMixSetMute(MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, True);
end.

Saludos!
muchas gracias! voy a probar tambien estas opciones y cuento los resultados. thanks again and salu2!
Responder Con Cita
  #6  
Antiguo 08-01-2009
osmuar_exp osmuar_exp is offline
Miembro
 
Registrado: ene 2008
Posts: 18
Poder: 0
osmuar_exp Va por buen camino
Thumbs up Thanks

Fue de gran utilidad.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Activar y desactivar un Datetimepicker Delphitest Varios 12 03-09-2008 19:53:39
Activar/Desactivar Triggers Delphius Firebird e Interbase 8 16-04-2007 05:51:16
activar sonido emiliu Varios 2 27-11-2005 22:55:25
activar y desactivar negrita. rebollo75 Impresión 3 28-01-2005 10:25:04
Activar y Desactivar un conexion de red Ney API de Windows 1 30-01-2004 19:28:12


La franja horaria es GMT +2. Ahora son las 07:14:14.


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