AudioServicesPlayAlertSound lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- Gilles · 2018-05-23 11:07 Hello who knows where is function AudioServicesPlayAlertSound () ? I found it in AudioService.h But there is no file AudioService.pas and may I declare it like : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure AudioServicesPlayAlertSound (inSystemSoundID: SystemSoundID);external name '_AudioServicesPlayAlertSound'; ? (And also : why do they hate so much Carbon at Apple ?  ) ---------------------------------------------------------------------- Hansaplast · 2018-05-23 13:10 I have been playing a bit with DiskArbitration.h, and I'm definitely not an expert, but this seems to work: 1) Add the AudioToolbox framework with Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$linkframework AudioToolbox} 2) Declare the procedure like you did: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure AudioServicesPlayAlertSound (inSystemSoundID: TSystemSoundID); external name '_AudioServicesPlayAlertSound'; (note that I added a "T" in front of the SystemSoundID) 3) Declare the sound ID: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TSystemSoundID = UInt32; 4) And finally call: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i AudioServicesPlayAlertSound(1); Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1;  {$mode objfpc}{$H+}  interface{$linkframework AudioToolbox}  uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, MacOSAll, CocoaInt;  type    { TForm1 }    TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private    public    end;    TSystemSoundID = UInt32;    procedure AudioServicesPlayAlertSound (inSystemSoundID: TSystemSoundID); external name '_AudioServicesPlayAlertSound';var  Form1: TForm1;  implementation  {$R *.lfm}  { TForm1 }  procedure TForm1.Button1Click(Sender: TObject);begin  AudioServicesPlayAlertSound(1);  AudioServicesPlayAlertSound(2);end;  end. ---------------------------------------------------------------------- Hansaplast · 2018-05-23 14:02 Now that you got me to try this, maybe this is helpful as well, it allows playback of a sound file: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  unit Unit1;  {$mode objfpc}{$H+}  interface{$linkframework AudioToolbox}  uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, MacOSAll, CocoaInt;  type    { TForm1 }    TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private    public    end;    TSystemSoundID = UInt32;  pSystemSoundID = ^TSystemSoundID;    procedure AudioServicesPlayAlertSound (inSystemSoundID: TSystemSoundID); external name '_AudioServicesPlayAlertSound';  function AudioServicesCreateSystemSoundID(inFileURL: CFURLRef; outSystemSoundID: pSystemSoundID):OSStatus; external name '_AudioServicesCreateSystemSoundID';  var  Form1: TForm1;  implementation  {$R *.lfm}  { TForm1 }  procedure TForm1.Button1Click(Sender: TObject);var newSoundID:TSystemSoundID;  filePathURL: CFURLRef;    filePathCFStringRef: CFStringRef;    filePathStr: Str255; // = stringbegin  // Standard sound:  // AudioServicesPlayAlertSound(newSoundID);    // Play sound from file  filePathStr := '/Users/hans/Dropbox/Projects/Lazarus Projects/MacOS Sound Test/project1.app/Contents/Resources/notify.wav';  filePathCFStringRef := CFStringCreateWithPascalString(kCFAllocatorDefault, filePathStr, CFStringGetSystemEncoding);  filePathURL := CFURLCreateWithFileSystemPath(kCFAllocatorDefault, filePathCFStringRef, kCFURLPOSIXPathStyle, false);    AudioServicesCreateSystemSoundID(filePathURL, @newSoundID);  AudioServicesPlayAlertSound(newSoundID);end;  end.  Again the side note that I'm no expert ... but it does seem to work. Obviously, you'll need to grab a soundfile somewhere. ---------------------------------------------------------------------- Gilles · 2018-05-23 15:40 great I love this forum