• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Playing Sounds in AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Playing Sounds in AppleScript


  • Subject: Re: Playing Sounds in AppleScript
  • From: Shane Stanley <email@hidden>
  • Date: Fri, 30 Oct 2015 22:52:12 +1100

On 30 Oct 2015, at 10:29 PM, email@hidden wrote:

I wanted to see if there was a possibility of playing sounds in my scripts?

I think you mentioned in another message that you're running 10.11 or 10.10, so you can use this:

--  at top of script
use scripting additions
use framework "Foundation"
use framework "AppKit"

-- where you want to play the sound
set theFile to POSIX path of "Path:to:sound:file.mp3"
set theSound to current application's NSSound's alloc()'s initWithContentsOfFile:theFile byReference:false
tell theSound to play()


-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Playing Sounds in AppleScript
      • From: email@hidden
References: 
 >Playing Sounds in AppleScript (From: email@hidden)

  • Prev by Date: Re: Playing Sounds in AppleScript
  • Next by Date: Re: Playing Sounds in AppleScript
  • Previous by thread: Re: Playing Sounds in AppleScript
  • Next by thread: Re: Playing Sounds in AppleScript
  • Index(es):
    • Date
    • Thread