def _onMirrorPush(self, message):

        if 'icon' in message:
            # BUILD KODI NOTIFICATION
            applicationNameMirrored = message.get('application_name', '')
            titleMirrored = message.get('title', '')

            # Add Title...
            title = applicationNameMirrored if not titleMirrored else applicationNameMirrored + ': '
            title += titleMirrored

            # ...Body...
            body = message.get('body', '').rstrip('\n').replace('\n', ' / ')

            # ...and Icon
            iconPath = common.base64ToFile(message['icon'], self.imgFilePath, imgFormat='JPEG', imgSize=(96, 96))

            common.showNotification(title, body, self.notificationTime, iconPath)

            # Action on phone call
            # Works only with com.android.dialer (Android stock dialer)
            if self.cmdOnPhoneCallPush != 'none' and message.get('package_name', '') in ['com.android.dialer']:

                common.log('Execute action on phone call start (mirror): %s' % self.cmdOnPhoneCallPush)

                if self.cmdOnPhoneCallPush == 'pause':
                    common.executeJSONRPCMethod('Player.PlayPause', {'play': False})
                elif self.cmdOnPhoneCallPush == 'stop':
                    common.executeJSONRPCMethod('Player.Stop')
示例#2
0
    def _onDismissPush(self, message, cmd):

        # TODO: add package_name, source_device_iden for be sure is the right dismission
        """
        {"notification_id": 1812, "package_name": "com.podkicker", "notification_tag": null,
        "source_user_iden": "ujy9SIuzSFw", "source_device_iden": "ujy9SIuzSFwsjzWIEVDzOK", "type": "dismissal"}
        """
        if message['notification_id'] == self.pbPlaybackNotificationId:
            common.log('Execute action on dismiss push: %s' % cmd)

            if cmd == 'pause':
                common.executeJSONRPCMethod('Player.PlayPause')
            elif cmd == 'stop':
                common.executeJSONRPCMethod('Player.Stop')
            elif cmd == 'next':
                common.executeJSONRPCMethod('Player.GoTo', {'to': 'next'})

        # Action on phone call
        # Works only with com.android.dialer (Android stock dialer)
        if self.cmdOnPhoneCallPush != 'none' and message.get(
                'package_name', '') in ['com.android.dialer']:

            common.log('Execute action on phone call end (dismiss): %s' %
                       self.cmdOnPhoneCallPush)

            if self.cmdOnPhoneCallPush == 'pause':
                common.executeJSONRPCMethod('Player.PlayPause', {'play': True})
    def _onDismissPush(self, message, cmd):

        # TODO: add package_name, source_device_iden for be sure is the right dismission
        """
        {"notification_id": 1812, "package_name": "com.podkicker", "notification_tag": null,
        "source_user_iden": "ujy9SIuzSFw", "source_device_iden": "ujy9SIuzSFwsjzWIEVDzOK", "type": "dismissal"}
        """
        if message['notification_id'] == self.pbPlaybackNotificationId:
            common.log('Execute action on dismiss push: %s' % cmd)

            if cmd == 'pause':
                common.executeJSONRPCMethod('Player.PlayPause')
            elif cmd == 'stop':
                common.executeJSONRPCMethod('Player.Stop')
            elif cmd == 'next':
                common.executeJSONRPCMethod('Player.GoTo', {'to': 'next'})

        # Action on phone call
        # Works only with com.android.dialer (Android stock dialer)
        if self.cmdOnPhoneCallPush != 'none' and message.get('package_name', '') in ['com.android.dialer']:

            common.log('Execute action on phone call end (dismiss): %s' % self.cmdOnPhoneCallPush)

            if self.cmdOnPhoneCallPush == 'pause':
                common.executeJSONRPCMethod('Player.PlayPause', {'play': True})
示例#4
0
    def _onMirrorPush(self, message):

        if 'icon' in message:
            # BUILD KODI NOTIFICATION
            applicationNameMirrored = message.get('application_name', '')
            titleMirrored = message.get('title', '')

            # Add Title...
            title = applicationNameMirrored if not titleMirrored else applicationNameMirrored + ': '
            title += titleMirrored

            # ...Body...
            body = message.get('body', '').rstrip('\n').replace('\n', ' / ')

            # ...and Icon
            iconPath = common.base64ToFile(message['icon'],
                                           self.imgFilePath,
                                           imgFormat='JPEG',
                                           imgSize=(96, 96))

            common.showNotification(title, body, self.notificationTime,
                                    iconPath)

            # Action on phone call
            # Works only with com.android.dialer (Android stock dialer)
            if self.cmdOnPhoneCallPush != 'none' and message.get(
                    'package_name', '') in ['com.android.dialer']:

                common.log('Execute action on phone call start (mirror): %s' %
                           self.cmdOnPhoneCallPush)

                if self.cmdOnPhoneCallPush == 'pause':
                    common.executeJSONRPCMethod('Player.PlayPause',
                                                {'play': False})
                elif self.cmdOnPhoneCallPush == 'stop':
                    common.executeJSONRPCMethod('Player.Stop')