Changeset 199 for trunk/StreamVision/StreamVision.py
- Timestamp:
- 11/10/05 05:21:07 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/StreamVision/StreamVision.py
r195 r199 58 58 return name 59 59 60 def iTunesApp(): 61 return app(id='com.apple.iTunes') 60 def iTunesApp(): return app(id='com.apple.iTunes') 61 def XTensionApp(): return app(creator='SHEx') 62 63 HAVE_XTENSION = False 64 try: 65 XTensionApp() 66 HAVE_XTENSION = True 67 except: 68 pass 62 69 63 70 class StreamVision(NSApplication): … … 77 84 if artwork: 78 85 kw['pictImage'] = artwork[0].data.get() 79 growlNotify(iTunes.current_track.name.get(), 86 growlNotify(iTunes.current_track.name.get() + ' ' + 87 '★' * (iTunes.current_track.rating.get() / 20), 80 88 iTunes.current_track.album.get() + "\n" + 81 89 iTunes.current_track.artist.get(), … … 104 112 self.hotKeyActions[_StreamVision.HotKeyAddress(hotKeyRef)] = func 105 113 114 def incrementRatingBy(self, increment): 115 iTunes = iTunesApp() 116 rating = iTunes.current_track.rating.get() 117 rating += increment 118 if rating < 0: 119 rating = 0 120 NSBeep() 121 elif rating > 100: 122 rating = 100 123 NSBeep() 124 iTunes.current_track.rating.set(rating) 125 126 def playPause(self): 127 iTunes = iTunesApp() 128 iTunes.playpause() 129 if HAVE_XTENSION: 130 if iTunes.player_state() == k.playing: 131 XTensionApp().turnon('Stereo') 132 else: 133 XTensionApp().turnoff('Stereo') 134 106 135 def finishLaunching(self): 107 136 super(StreamVision, self).finishLaunching() 108 137 self.registerHotKey(self.displayTrackInfo, 100) # F8 109 138 self.registerHotKey(self.goToSite, 100, cmdKey) # cmd-F8 110 self.registerHotKey( lambda: iTunesApp().playpause(), 101) # F9139 self.registerHotKey(self.playPause, 101) # F9 111 140 self.registerHotKey(lambda: iTunesApp().previous_track(), 109) # F10 112 141 self.registerHotKey(lambda: iTunesApp().next_track(), 103) # F11 142 self.registerHotKey(lambda: self.incrementRatingBy(-20), 109, cmdKey) # cmd-F10 143 self.registerHotKey(lambda: self.incrementRatingBy(20), 103, cmdKey) # cmd-F11 113 144 NSDistributedNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, self.displayTrackInfo, 'com.apple.iTunes.playerInfo', None) 114 145
Note:
See TracChangeset
for help on using the changeset viewer.