Re: Playing Sounds in AppleScript
Re: Playing Sounds in AppleScript
- Subject: Re: Playing Sounds in AppleScript
- From: Shane Stanley <email@hidden>
- Date: Fri, 30 Oct 2015 23:24:27 +1100
- X_v_e_cd: c4afbd7dc1c8b521eb59d370b346bdaa
- X_v_r_cd: c3efcbbb0b9631f220f5306862301870
On 30 Oct 2015, at 11:19 PM, email@hidden wrote:
>
> The message says
> Can’t get play of missing value.
> What I have is this
>
> use scripting additions
> use framework "Foundation"
> use framework "AppKit"
> set theFile to POSIX path of "Phoenix:Applications:netutils:sounds:logo.mp3"
> set theSound to current application's NSSound's alloc()'s
> initWithContentsOfFile:theFile byReference:false
> tell theSound to play()
> Hopefully I didn't type that all incorrectly?
The code looks correct (as long as there is no return after "alloc()'s"), but the error message suggests the path is incorrect.
Test it like this to see:
use scripting additions
use framework "Foundation"
use framework "AppKit"
set theFile to POSIX path of (choose file of type {"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