It is currently Sat Dec 07, 2019 7:09 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Create a system alert beep on a Mac
PostPosted: Mon Dec 02, 2019 9:49 pm 
Offline
New User
New User

Joined: Mon Dec 02, 2019 9:43 pm
Posts: 2
Is there an easier way to create the default system alert sound on a Mac without having to read the setting file to see what sound file it is set to, load the sound and then play the sound?

Thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: Create a system alert beep on a Mac
PostPosted: Tue Dec 03, 2019 6:50 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3542
Location: Netherlands
You mean a beep like this ?
Code:
OpenWindow(0, 0, 0, 222, 200, "Beep example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 10, 10, 200, 40, "Beep")
Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_Gadget And EventGadget() = 0
    NSBeep_()
  EndIf
Until Event = #PB_Event_CloseWindow


or
Code:
#kUserPreferredAlert = $00001000

ImportC "-framework AudioToolbox"
  AudioServicesPlaySystemSound(SystemSoundID.l)
EndImport

OpenWindow(0, 0, 0, 222, 200, "User alert example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 10, 10, 200, 40, "Alert")
Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_Gadget And EventGadget() = 0
    AudioServicesPlaySystemSound(#kUserPreferredAlert)
  EndIf
Until Event = #PB_Event_CloseWindow

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: Create a system alert beep on a Mac
PostPosted: Tue Dec 03, 2019 12:16 pm 
Offline
New User
New User

Joined: Mon Dec 02, 2019 9:43 pm
Posts: 2
Perfect. Thank you


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye