• 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: AppleScript-Users Digest, Vol 12, Issue 525
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript-Users Digest, Vol 12, Issue 525


  • Subject: Re: AppleScript-Users Digest, Vol 12, Issue 525
  • From: Christopher Clancy <email@hidden>
  • Date: Fri, 30 Oct 2015 07:47:30 -0700
  • X_v_e_cd: 19f120d3ce734c931e105fcd37073c7d
  • X_v_r_cd: 4e39da860beaa08c05ad42fe0255ad08

Help

> On Oct 30, 2015, at 06:21, email@hidden wrote:
>
> Send AppleScript-Users mailing list submissions to
>    email@hidden
>
> To subscribe or unsubscribe via the World Wide Web, visit
>    https://lists.apple.com/mailman/listinfo/applescript-users
> or, via email, send a message with subject or body 'help' to
>    email@hidden
>
> You can reach the person managing the list at
>    email@hidden
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of AppleScript-Users digest..."
>
>
> Today's Topics:
>
>   1. Re: Playing Sounds in AppleScript (S. J. Cunningham)
>   2. Re: Playing Sounds in AppleScript (Shane Stanley)
>   3. Re: Playing Sounds in AppleScript (email@hidden)
>   4. Re: Playing Sounds in AppleScript (Shane Stanley)
>   5. Re: Playing Sounds in AppleScript (Christopher Stone)
>   6. Re: Playing Sounds in AppleScript (Luther Fuller)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 30 Oct 2015 07:37:17 -0400
> From: "S. J. Cunningham" <email@hidden>
> To: AppleScript Listserv <email@hidden>
> Subject: Re: Playing Sounds in AppleScript
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset="iso-8859-1"
>
>
>> On Oct 30, 2015, at 7:29 AM, email@hidden wrote:
>>
>> Hi there,
>> I wanted to see if there was a possibility of playing sounds in my scripts?
>> The sounds are .mp3 files.
>> The only way I know how, was using Play Sound. However my concern
>> would be, if the user's hard drive name wasn't MacintoshHD, then how
>> will the sounds be played?
>> Also, is there no alternative to the Play Sound application?
>> Thanks.
>
> Here's a script I use to wake me up in the morning:
>
> property Reveillie : alias "MacBook Pro:Users:sjc:Documents:Development:cron:Reveille.mp3"
> property sysVolMax : 100
> property qtVolMax : 256
> property reveilleVol : 30 -- reduce to 10 for external speakers
> property logfile : "MacBook Pro:Users:sjc:Documents:Development:cron:Debug Log.txt"
> try
>    set logFileID to open for access file logfile with write permission
> on error
>    close access file logfile
>    return
> end try
> write ¬
>    return & "Start at: " & (current date) & return & return to logFileID ¬
>    starting at get eof of logFileID
>
> -- Set System Volume
> set pctVol to reveilleVol / sysVolMax
> set saveSysVol to output volume of (get volume settings)
> display dialog "Current System Volume is " & saveSysVol
> write ¬
>    "System Volume = : " & saveSysVol & return to logFileID ¬
>    starting at get eof of logFileID
> set volume output volume pctVol * sysVolMax
> set newSysVol to output volume of (get volume settings)
> display dialog "New System Volume is " & newSysVol
>
> tell application "QuickTime Player"
>    activate
>    set theFile to open Reveillie
>    set audio volume of document 1 to pctVol * qtVolMax
>    play document 1
>    repeat while playing of document 1
>        delay 1
>    end repeat
>    -- display dialog "quitting"
>    quit
>
> end tell
>
> -- Restore System Volume Settings
> set volume output volume saveSysVol
> write ¬
>    "Stop at: " & (current date) & return & return to logFileID
> close access logFileID
>
> Steve
> ------------------
> OS X 10.6.8, AppleScript 2.1.2
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <https://lists.apple.com/mailman/private/applescript-users/attachments/20151030/face8d52/attachment.html>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 30 Oct 2015 22:52:12 +1100
> From: Shane Stanley <email@hidden>
> To: AS users <email@hidden>
> Subject: Re: Playing Sounds in AppleScript
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset="utf-8"
>
>> 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/>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <https://lists.apple.com/mailman/private/applescript-users/attachments/20151030/660c1b97/attachment.html>
>
> ------------------------------
>
> Message: 3
> Date: Fri, 30 Oct 2015 08:19:31 -0400
> From: email@hidden
> To: Shane Stanley <email@hidden>
> Cc: AS users <email@hidden>
> Subject: Re: Playing Sounds in AppleScript
> Message-ID:
>    <CAGoy0=email@hidden>
> Content-Type: text/plain; charset=UTF-8
>
> I'm using OS X 10.11.
> What was given produces an error, unless I typed it wrong
> 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?
>
>
>
> ------------------------------
>
> Message: 4
> Date: Fri, 30 Oct 2015 23:24:27 +1100
> From: Shane Stanley <email@hidden>
> To: AS users <email@hidden>
> Subject: Re: Playing Sounds in AppleScript
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=utf-8
>
>> 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/>
>
>
>
>
> ------------------------------
>
> Message: 5
> Date: Fri, 30 Oct 2015 08:14:00 -0500
> From: Christopher Stone <email@hidden>
> To: Applescript Users List <email@hidden>
> Subject: Re: Playing Sounds in AppleScript
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset="utf-8"
>
>> 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
>
> -------------------------------------------------------------------------------------------
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <https://lists.apple.com/mailman/private/applescript-users/attachments/20151030/a877bfb9/attachment.html>
>
> ------------------------------
>
> Message: 6
> Date: Fri, 30 Oct 2015 08:21:43 -0500
> From: Luther Fuller <email@hidden>
> To: Applescript Users <email@hidden>
> Subject: Re: Playing Sounds in AppleScript
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset="utf-8"
>
>> On Oct 30, 2015, at 6:29 AM, email@hidden wrote:
>>
>> I wanted to see if there was a possibility of playing sounds in my scripts?
>> The sounds are .mp3 files.
>
> I use this to play sound files ...
>
>    set soundPath to (quoted form of (POSIX path of soundAlias))
>    set soundpid to do shell script "afplay " & soundPath & " &> /dev/null & echo $!" -- start the music
>
> I use this to loop the music until another process is finished.
> This has been working for many years without any problems.
> My current system is 10.7.5.
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <https://lists.apple.com/mailman/private/applescript-users/attachments/20151030/e22457ea/attachment.html>
>
> ------------------------------
>
> _______________________________________________
> AppleScript-Users mailing list
> email@hidden
> https://lists.apple.com/mailman/listinfo/applescript-users
>
> End of AppleScript-Users Digest, Vol 12, Issue 525
> **************************************************

 _______________________________________________
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


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