• 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: 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


  • Follow-Ups:
    • Re: Playing Sounds in AppleScript
      • From: Shane Stanley <email@hidden>
    • Re: Playing Sounds in AppleScript
      • From: Christopher Stone <email@hidden>
References: 
 >Playing Sounds in AppleScript (From: email@hidden)
 >Re: Playing Sounds in AppleScript (From: Shane Stanley <email@hidden>)
 >Re: Playing Sounds in AppleScript (From: email@hidden)
 >Re: Playing Sounds in AppleScript (From: Shane Stanley <email@hidden>)
 >Re: Playing Sounds in AppleScript (From: Christopher Stone <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