iTunes Local Control Airplay Devices to Variable

Monstergerm
Posts: 302
Joined: Tue Sep 01, 2009 1:47 pm

iTunes Local Control Airplay Devices to Variable

Post by Monstergerm »

Your plugin has the option of saving airplay devices to variable with the option of converting to string for display on control pages.
I think it would be very easy to achieve both, the conversion to string for display and keeping the info in list format for restoring devices.

Code: Select all

    
#-------------------------------------------------------------------------------
    def airplayDevicesToVariable(self, action):
        self.logger.debug(u'action "{}": {}'.format(action.description,action.props['variable']))
        devices = self.airplay.active_devices
        if action.props['convert']:
            devices = ', '.join(devices) # convert list to string
        variable_set(action.props['variable'],devices)

#-------------------------------------------------------------------------------
    def airplayDevicesFromVariable(self, action):
        self.logger.debug(u'action "{}": {}'.format(action.description,action.props['variable']))
        devices = variable_get(action.props['variable'])
        if "[u'" in devices: # we have a list
            self.airplay.active_devices = variable_get(action.props['variable'], list)
        else:
            devices = variable_get(action.props['variable'], str)
            devices = devices.split(', ')  #convert string to list
            devices = map(unicode, devices) #make unicode
            self.airplay.active_devices = devices

I also patched my plugin version with three actions that I think would be useful and are easy to add since they are already in the Apple Script portion:
save duration of the current track to variable
save player position to variable
set player position from variable
User avatar
c64
Posts: 53
Joined: Sun Oct 28, 2012 2:09 am
Location: Germany

Re: iTunes Local Control Airplay Devices to Variable

Post by c64 »

Saving player position & resuming player position from a variable is exactly what I am looking for. Would you be kind enough to share how you did it?
Monstergerm
Posts: 302
Joined: Tue Sep 01, 2009 1:47 pm

Re: iTunes Local Control Airplay Devices to Variable

Post by Monstergerm »

The latest version 2022.06 incorporates these upgrades.
Post Reply

Return to “kmarkley's plugins”