Changeset 656


Ignore:
Timestamp:
04/07/13 20:14:47 (6 years ago)
Author:
Nicholas Riley
Message:

StreamVision?.py: Display "(AirPlay?)" in Growl notification if
outputting over AirPlay?. Display notification when default output
device changes.

Useful to provide feedback from soundsource
(https://github.com/nriley/SoundSource), particularly given the issues
with my X10 interface not liking the winter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/StreamVision/StreamVision.py

    r655 r656  
    4040def growlNotify(title, description, **kw):
    4141    try:
     42        if usingStereo:
     43            description += '\n(AirPlay)'
     44
    4245        growl.notify(
    4346            with_name=NOTIFICATION_TRACK_INFO,
     
    98101
    99102needsStereoPowerOn = HAVE_XTENSION
     103usingStereo = False
    100104
    101105def mayUseStereo():
     
    111115    return remote_speakers and remote_speakers[0] not in (None, k.missing_value)
    112116
    113 def turnStereoOn():
    114     global needsStereoPowerOn
     117def turnStereoOnOrOff():
     118    global needsStereoPowerOn, usingStereo
     119    usingStereo = False
    115120    if not default_output_device_is_airplay() and not mayUseStereo():
    116121        if HAVE_XTENSION and XTensionApp().status('Stereo'):
     
    119124    if not XTensionApp().status('Stereo'):
    120125        XTensionApp().turnon('Stereo')
     126    usingStereo = True
    121127    needsStereoPowerOn = False
    122128
    123129def turnStereoOff():
    124     global needsStereoPowerOn
     130    global needsStereoPowerOn, usingStereo
     131    usingStereo = False
    125132    if default_output_device_is_airplay() or not mayUseStereo():
    126133        return
     
    182189            turnStereoOff()
    183190            return
    184         turnStereoOn()
     191        turnStereoOnOrOff()
    185192        if trackClass == k.URL_track:
    186193            if amuaPlaying():
     
    221228                    **kw)
    222229
     230    def defaultOutputDeviceChanged(self):
     231        turnStereoOnOrOff()
     232        self.displayTrackInfo()
     233
    223234    def goToSite(self):
    224235        iTunes = iTunesApp()
     
    285296            return
    286297        if iTunes.player_state() == k.playing:
    287             turnStereoOn()
     298            turnStereoOnOrOff()
    288299        else:
    289300            turnStereoOff()
     
    366377            print "failed to connect to remote: ", e
    367378
    368         set_default_output_device_changed_callback(turnStereoOn)
    369         turnStereoOn()
     379        set_default_output_device_changed_callback(
     380            self.defaultOutputDeviceChanged)
     381        turnStereoOnOrOff()
    370382
    371383    def sendEvent_(self, theEvent):
Note: See TracChangeset for help on using the changeset viewer.