Changeset 300 for trunk/StreamVision
- Timestamp:
- 09/24/06 10:34:39 (18 years ago)
- Location:
- trunk/StreamVision
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/StreamVision/StreamVision.py
r252 r300 3 3 4 4 from appscript import app, k, its, CommandError 5 from AppKit import NSApplication, NS Beep, NSSystemDefined, NSURL, NSWorkspace5 from AppKit import NSApplication, NSApplicationDefined, NSBeep, NSSystemDefined, NSURL, NSWorkspace 6 6 from Foundation import NSDistributedNotificationCenter 7 7 from PyObjCTools import AppHelper … … 10 10 import struct 11 11 import scrape 12 import HIDRemote 12 13 import HotKey 13 14 … … 18 19 kEventHotKeyPressedSubtype = 6 19 20 kEventHotKeyReleasedSubtype = 9 21 22 kHIDUsage_Csmr_ScanNextTrack = 0xB5 23 kHIDUsage_Csmr_ScanPreviousTrack = 0xB6 24 kHIDUsage_Csmr_PlayOrPause = 0xCD 20 25 21 26 growl = app('GrowlHelperApp') … … 138 143 iTunes.current_track.rating.set(rating) 139 144 140 def playPause(self ):145 def playPause(self, useStereo=True): 141 146 iTunes = iTunesApp() 142 147 was_playing = (iTunes.player_state.get() == k.playing) … … 146 151 iTunes.browser_windows[1].view.set(iTunes.user_playlists.filter(its.name=='Stations')[1].get()) 147 152 iTunes.play() 148 if HAVE_XTENSION :153 if HAVE_XTENSION and useStereo: 149 154 if iTunes.player_state.get() == k.playing: 150 155 XTensionApp().turnon('Stereo') … … 190 195 self.registerZoomWindowHotKey() 191 196 NSDistributedNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, self.displayTrackInfo, 'com.apple.iTunes.playerInfo', None) 197 try: 198 HIDRemote.connect() 199 except OSError, e: 200 print "failed to connect to remote: ", e 192 201 193 202 def sendEvent_(self, theEvent): 194 if theEvent.type() == NSSystemDefined and \ 203 eventType = theEvent.type() 204 if eventType == NSSystemDefined and \ 195 205 theEvent.subtype() == kEventHotKeyPressedSubtype: 196 206 self.hotKeyActions[theEvent.data1()]() 207 elif eventType == NSApplicationDefined: 208 key = theEvent.data1() 209 if key == kHIDUsage_Csmr_ScanNextTrack: 210 iTunesApp().next_track() 211 elif key == kHIDUsage_Csmr_ScanPreviousTrack: 212 iTunesApp().previous_track() 213 elif key == kHIDUsage_Csmr_PlayOrPause: 214 self.playPause(useStereo=False) 197 215 super(StreamVision, self).sendEvent_(theEvent) 198 216 199 217 if __name__ == "__main__": 200 218 AppHelper.runEventLoop() 219 HIDRemote.disconnect() # XXX do we get here? -
trunk/StreamVision/setup.py
r211 r300 19 19 ext_modules=[Extension('HotKey', 20 20 sources=['HotKeymodule.c'], 21 extra_link_args=['-framework', 'Carbon'])], 21 extra_link_args=['-framework', 'Carbon']), 22 Extension('HIDRemote', 23 sources=['HIDRemotemodule.m'], 24 extra_link_args=['-framework', 'Cocoa', 25 '-framework', 'IOKit', 26 'libHIDUtilities.a'])], 22 27 data_files=["English.lproj"], 23 28 options=dict(py2app=dict(plist=plist)),
Note:
See TracChangeset
for help on using the changeset viewer.