Re: Playing Sounds in AppleScript
Re: Playing Sounds in AppleScript
- Subject: Re: Playing Sounds in AppleScript
- From: email@hidden
- Date: Fri, 30 Oct 2015 09:26:05 -0400
A quick question.
Wen I put in something like the below, users on other machines get an
error which says about a missing play value
set theFile to POSIX path of "HD:Applications:netutils:sounds:logo.mp3"
set theSound to current application's NSSound's alloc()'s
initWithContentsOfFile:theFile byReference:false
tell theSound to play()
What I am trying to ask is, how can I resolve the problem of, a user's
hard drive is called macintosh HD, yet the above code produces an
error. So how do I tell the file to play on Macintosh HD?
On 10/30/15, Christopher Stone <email@hidden> wrote:
> On Oct 30, 2015, at 07:24, Shane Stanley <email@hidden>
> wrote:
>> The code looks correct (as long as there is no return after "alloc()'s"),
>> but the error message suggests the path is incorrect.
> ______________________________________________________________________
>
> Works for me.
>
> --
> Take Care,
> Chris
>
> -------------------------------------------------------------------------------------------
> # dNam: Playing Sounds with ASObjC
> # dMod: 2015/10/30 08:01
> -------------------------------------------------------------------------------------------
>
> use scripting additions
> use framework "Foundation"
> use framework "AppKit"
>
> tell application "Finder" to set finderSelectionList to selection as alias
> list
>
> if finderSelectionList is not {} then
> set theSound to POSIX path of first item of finderSelectionList
> tell (current application's NSSound's alloc()'s
> initWithContentsOfFile:theSound byReference:false) to play()
> end if
>
> -------------------------------------------------------------------------------------------
>
>
_______________________________________________
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