Changeset 414
- Timestamp:
- 02/25/08 11:16:56 PM (9 months ago)
- Files:
-
- trunk/StreamVision/StreamVision.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/StreamVision/StreamVision.py
r341 r414 75 75 def iTunesApp(): return app(id='com.apple.iTunes') 76 76 def XTensionApp(): return app(creator='SHEx') 77 def AmuaApp(): return app('Amua.app') 77 78 78 79 HAVE_XTENSION = False … … 83 84 pass 84 85 86 HAVE_AMUA = False 87 try: 88 AmuaApp() 89 HAVE_AMUA = True 90 except: 91 pass 92 85 93 needsStereoPowerOn = HAVE_XTENSION 94 95 def amuaPlaying(): 96 if not HAVE_AMUA: 97 return False 98 return AmuaApp().is_playing() 86 99 87 100 class StreamVision(NSApplication): … … 90 103 hotKeys = [] 91 104 92 def displayTrackInfo(self ):105 def displayTrackInfo(self, playerInfo=None): 93 106 global needsStereoPowerOn 94 107 … … 112 125 needsStereoPowerOn = False 113 126 if trackClass == k.URL_track: 127 if amuaPlaying(): 128 if playerInfo is None: # Amua displays it itself 129 AmuaApp().display_song_information() 130 return 114 131 growlNotify(cleanStreamTitle(iTunes.current_stream_title()), 115 132 cleanStreamTrackName(trackName)) … … 134 151 iTunes = iTunesApp() 135 152 if iTunes.player_state() == k.playing: 153 if amuaPlaying(): 154 AmuaApp().display_album_details() 155 return 136 156 url = iTunes.current_stream_URL() 137 157 if url != k.missing_value: … … 156 176 def incrementRatingBy(self, increment): 157 177 iTunes = iTunesApp() 178 if amuaPlaying(): 179 if rating < 0: 180 AmuaApp().ban_song() 181 growlNotify('Banned song.', '') 182 else: 183 AmuaApp().love_song() 184 growlNotify('Loved song.', '') 185 return 158 186 rating = iTunes.current_track.rating() 159 187 rating += increment … … 173 201 if not useStereo: 174 202 needsStereoPowerOn = False 175 iTunes.playpause() 203 if was_playing and amuaPlaying(): 204 AmuaApp().stop() 205 else: 206 iTunes.playpause() 176 207 if not was_playing and iTunes.player_state() == k.stopped: 177 208 # most likely, we're focused on the iPod, so playing does nothing … … 202 233 self.playPause(useStereo=False) 203 234 235 def nextTrack(self): 236 if amuaPlaying(): 237 AmuaApp().skip_song() 238 return 239 iTunesApp().next_track() 240 204 241 def registerZoomWindowHotKey(self): 205 242 self.zoomWindowHotKey = self.registerHotKey(self.zoomWindow, 42, cmdKey | controlKey) # cmd-ctrl-\ … … 237 274 self.registerHotKey(self.playPause, 101) # F9 238 275 self.registerHotKey(lambda: iTunesApp().previous_track(), 109) # F10 239 self.registerHotKey( lambda: iTunesApp().next_track(), 103) # F11276 self.registerHotKey(self.nextTrack, 103) # F11 240 277 self.registerHotKey(lambda: self.incrementRatingBy(-20), 109, shiftKey) # shift-F10 241 278 self.registerHotKey(lambda: self.incrementRatingBy(20), 103, shiftKey) # shift-F11