Windows VCL中未更改通知声音

问题描述 投票:0回答:1

我正在尝试在Delphi VCL应用程序中更改TNotification声音。

  try
    ANotification := ANotificationCenter.CreateNotification;
    ANotification.Name := NAME_NTC_NOVA_SOLICITACAO;
    ANotification.Title := Title;
    ANotification.AlertBody := Body;
    ANotification.EnableSound := True;
    ANotification.SoundName := ExtractFilePath(ParamStr(0)) + 'sound\eventually.mp3';
    ANotificationCenter.PresentNotification(ANotification);  
  finally
    ANotification.Free;
  end;

Using TNotification文档所述,声音文件需要放在“项目”窗口中,然后配置“项目”->“部署”。我已经做了这些事情。

我的通知声音sound\eventually.mp3已放置在正确的路径中。但是Windows的默认通知声音保持不变。

UPDATE: ANotificationCenter只是在设计时就以窗体的形式删除,在此组件中没有任何更改。

delphi
1个回答
0
投票

由于没有找到答案,我最终禁用了通知声音,并自行播放了模拟通知声音的媒体文件。

不是我一直在寻找的解决方案,但是效果很好。

uses
  Winapi.MMSystem;
...
  try
    ANotification := ANotificationCenter.CreateNotification;
    ANotification.Name := NAME_NTC_NOVA_SOLICITACAO;
    ANotification.Title := Title;
    ANotification.AlertBody := Body;    
    ANotification.EnableSound := False;
    sndPlaySound(PWideChar(ExtractFilePath(ParamStr(0)) + 'sound\eventually.wav'), SND_ASYNC);
    ANotificationCenter.PresentNotification(ANotification);  
  finally
    ANotification.Free;
  end;
© www.soinside.com 2019 - 2024. All rights reserved.