fork of iTunes Remote Control with bugfixes and enhancements
at master 95 lines 4.8 kB view raw
1(* 2Copyright (c) 2006 James Huston 3All rights reserved. 4 5Redistribution and use in source and binary forms, with or without 6modification, are permitted provided that the following conditions 7are met: 81. Redistributions of source code must retain the above copyright 9 notice, this list of conditions and the following disclaimer. 102. Redistributions in binary form must reproduce the above copyright 11 notice, this list of conditions and the following disclaimer in the 12 documentation and/or other materials provided with the distribution. 133. The name of the author may not be used to endorse or promote products 14 derived from this software without specific prior written permission. 15 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26*) 27 28on choose menu item theObject 29 set fullMachineURI to "eppc://" & contents of default entry "MachineURI" of user defaults 30 if name of theObject is "menu-updatepodcast" then 31 using terms from application "iTunes" 32 tell application "iTunes" of machine fullMachineURI to updateAllPodcasts 33 end using terms from 34 else if name of theObject is "menu-subscribe" then 35 set thePanel to window "win-subscribe" 36 display panel thePanel attached to window "win-main" 37 else if name of theObject is "menu-prefs" then 38 display panel window "win-prefs" attached to window "win-main" 39 else if name of theObject is "menu-open" then 40 tell application "Finder" of machine fullMachineURI to open "/Applications/iTunes.app" as POSIX file 41 else if name of theObject is "menu-refreshrate" then 42 set contents of default entry "refreshRate" of user defaults to (title of current menu item of theObject) 43 else if name of theObject is "menu-mutecomp" then 44 set state of theObject to not (state of theObject as boolean) 45 tell application "iTunes" of machine fullMachineURI to set volume output muted not (output muted of (get volume settings)) 46 else if name of theObject is "menu-rate" then 47 set starRating to title of current menu item of theObject 48 set songRating to (starRating * 20) 49 using terms from application "iTunes" 50 tell application "iTunes" of machine fullMachineURI to set rating of current track to songRating 51 end using terms from 52 end if 53end choose menu item 54 55on will close theObject 56 set visible of theObject to false 57end will close 58 59on clicked theObject 60 set fullMachineURI to "eppc://" & contents of default entry "MachineURI" of user defaults 61 if name of theObject is "but-checkupdates" then 62 set contents of default entry "SUCheckAtStartup" of user defaults to state of theObject 63 else if name of theObject is "but-showprogress" then 64 set contents of default entry "ShowProgress" of user defaults to state of theObject 65 set visible of progress indicator "pi-dur" of window "win-main" to state of theObject 66 else if name of theObject is "but-quit" then 67 set contents of default entry "QuitiTunes" of user defaults to state of theObject 68 else if name of theObject is "but-update" then 69 set contents of default entry "UpdateMoreOften" of user defaults to state of theObject 70 else if name of theObject is "but-addplay" then 71 set contents of default entry "IncreasePlayCount" of user defaults to state of theObject 72 else if name of theObject is "but-up" then 73 using terms from application "iTunes" 74 tell application "iTunes" of machine fullMachineURI to set sound volume to 100 75 end using terms from 76 set contents of slider "sl-volume" of window "win-main" to 100 77 else if name of theObject is "but-down" then 78 using terms from application "iTunes" 79 tell application "iTunes" of machine fullMachineURI to set sound volume to 0 80 end using terms from 81 set contents of slider "sl-volume" of window "win-main" to 0 82 else if name of theObject is "but-subscribe" then 83 set podcastURL to contents of text field "tf-podcasturl" of window "win-subscribe" 84 if podcastURL is not "" then 85 using terms from application "iTunes" 86 tell application "iTunes" of machine fullMachineURI to subscribe podcastURL 87 end using terms from 88 close panel (window of theObject) 89 else 90 close panel (window of theObject) 91 end if 92 else if name of theObject is "but-close" then 93 close panel (window of theObject) 94 end if 95end clicked