def switchToChannelId(cls, playerProperties, channelId, channel):

        if playerProperties['player'] == 'audio' or (playerProperties['player'] == 'video' and playerProperties['media'] != 'channel'):

            # stop all other players except pvr

            handler.notifyLog('player:%s media:%s @id:%s is running' %
                              (playerProperties['player'], playerProperties['media'], playerProperties['playerid']))
            query = {
                "method": "Player.Stop",
                "params": {"playerid": playerProperties['playerid']},
            }
            res = jsonrpc(query)
            if 'result' in res and res['result'] == "OK":
                handler.notifyLog('Player stopped')

        handler.notifyLog('Currently playing channelid %s, switch to id %s' % (playerProperties['id'], channelId))
        query = {
            "method": "Player.Open",
            "params": {"item": {"channelid": channelId}}
        }
        res = jsonrpc(query)
        if 'result' in res and res['result'] == 'OK':
            handler.notifyLog('Switched to channel \'%s\'' % (channel))
        else:
            handler.notifyLog('Couldn\'t switch to channel \'%s\'' % (channel))
            handler.notifyOSD(loc(30000), loc(30025) % (channel), icon=IconAlert)
Example #2
0
            broadcast.update({'broadcasts': pvr.broadcasts})

    # check online availability of images and move to server cache

    bc = handler.cRequestConnector()
    response = bc.transmitFile(
        [broadcast['icon'], pvr.channel_logo, handler.FALLBACK])
    if response is not None:
        broadcast.update({
            'icon': response['items'],
            'icontype': response['icontype']
        })

    # determine ratings

    if broadcast['rating'] != '':
        broadcast.update({
            'rating':
            float(broadcast['rating']) if int(broadcast['rating']) < 10 else
            float(int(broadcast['rating']) / 10.0)
        })

    args.update({'command': 'add', 'broadcast': handler.sanitize(broadcast)})
    if args['broadcast'].get(
            'icon', None) is None or bc.transmitAnnouncement(args) is None:
        handler.notifyLog('Broadcast could\'nt delivered')
        handler.notifyOSD(30000, bc.status, icon=handler.IconAlert)
    else:
        handler.notifyLog('Broadcast delivered')
        handler.notifyOSD(30000, bc.status, icon=handler.IconOk)
Example #3
0
    def poll(self):

        while not XBMCMonitor.abortRequested(self):

            if XBMCMonitor.waitForAbort(self, INTERVAL):
                break
            if self.SettingsChanged:
                self.getSettings()

            _now = time.time()
            _switchInstantly = False

            for _timer in self.timers:

                if not _timer['utime']:
                    handler.notifyLog(
                        'Couldn\'t calculate timestamp, delete timer',
                        xbmc.LOGERROR)
                    self.resetTmr(_timer['date'])
                    break

                # delete old/discarded timers
                if _timer['utime'] + self.__discardTmr < _now:
                    self.resetTmr(_timer['date'])
                    continue

                if _timer['utime'] < _now: _switchInstantly = True
                if (_timer['utime'] - _now < INTERVAL +
                        self.__dispMsgTime / 1000) or _switchInstantly:
                    chanIdTmr = self.channelName2channelId(
                        _timer['channel'].decode('utf-8'))
                    if chanIdTmr:

                        # get player properties, switch if necessary

                        plrProps = self.getPlayer()
                        if chanIdTmr == plrProps['id']:
                            handler.notifyLog('Channel switching unnecessary')
                            handler.notifyOSD(
                                __LS__(30000),
                                __LS__(30027) %
                                (_timer['channel'].decode('utf-8')),
                                time=self.__dispMsgTime)
                        else:
                            switchAborted = False
                            secs = 0
                            handler.notifyLog(
                                'Channel switch to %s required' %
                                (_timer['channel'].decode('utf-8')))

                            if _switchInstantly:
                                handler.notifyLog(
                                    'immediate channel switching required')
                                handler.notifyOSD(
                                    __LS__(30000),
                                    __LS__(30027) %
                                    (_timer['channel'].decode('utf-8')),
                                    time=5000)

                            elif not self.__showNoticeBeforeSw:
                                xbmc.sleep(self.__dispMsgTime)

                            elif self.__useCountdownTimer:
                                handler.OSDProgress.create(
                                    __LS__(30028),
                                    __LS__(30026) %
                                    (_timer['title'], _timer['channel']),
                                    __LS__(30029) %
                                    (int(self.__dispMsgTime / 1000 - secs)))
                                while secs < self.__dispMsgTime / 1000:
                                    secs += 1
                                    percent = int(
                                        (secs * 100000) / self.__dispMsgTime)
                                    handler.OSDProgress.update(
                                        percent,
                                        __LS__(30026) %
                                        (_timer['title'], _timer['channel']),
                                        __LS__(30029) %
                                        (int(self.__dispMsgTime / 1000 -
                                             secs)))
                                    xbmc.sleep(1000)
                                    if (handler.OSDProgress.iscanceled()):
                                        switchAborted = True
                                        break
                                handler.OSDProgress.close()
                            else:
                                idleTime = xbmc.getGlobalIdleTime()
                                handler.notifyOSD(
                                    __LS__(30000),
                                    __LS__(30026) %
                                    (_timer['title'].decode('utf-8'),
                                     _timer['channel'].decode('utf-8')),
                                    time=self.__dispMsgTime)
                                while secs < self.__dispMsgTime / 1000:
                                    if idleTime > xbmc.getGlobalIdleTime():
                                        switchAborted = True
                                        break
                                    xbmc.sleep(1000)
                                    idleTime += 1
                                    secs += 1
                                if switchAborted:
                                    handler.notifyOSD(__LS__(30000),
                                                      __LS__(30032))

                            if switchAborted:
                                handler.notifyLog(
                                    'Channelswitch cancelled by user')
                            else:
                                if plrProps['player'] == 'audio' or (
                                        plrProps['player'] == 'video'
                                        and plrProps['media'] != 'channel'):

                                    # stop all other players except pvr

                                    handler.notifyLog(
                                        'player:%s media:%s @id:%s is running'
                                        %
                                        (plrProps['player'], plrProps['media'],
                                         plrProps['playerid']))
                                    query = {
                                        "method": "Player.Stop",
                                        "params": {
                                            "playerid": plrProps['playerid']
                                        },
                                    }
                                    res = jsonrpc(query)
                                    if 'result' in res and res[
                                            'result'] == "OK":
                                        handler.notifyLog('Player stopped')

                                handler.notifyLog(
                                    'Currently playing channelid %s, switch to id %s'
                                    % (plrProps['id'], chanIdTmr))
                                query = {
                                    "method": "Player.Open",
                                    "params": {
                                        "item": {
                                            "channelid": chanIdTmr
                                        }
                                    }
                                }
                                res = jsonrpc(query)
                                if 'result' in res and res['result'] == 'OK':
                                    handler.notifyLog(
                                        'Switched to channel \'%s\'' %
                                        (_timer['channel'].decode('utf-8')))
                                else:
                                    handler.notifyLog(
                                        'Couldn\'t switch to channel \'%s\'' %
                                        (_timer['channel'].decode('utf-8')))
                                    handler.notifyOSD(
                                        __LS__(30000),
                                        __LS__(30025) %
                                        (_timer['channel'].decode('utf-8')),
                                        icon=__IconAlert__)

                    self.resetTmr(_timer['date'])
            self.timers = handler.getTimer()

        handler.notifyLog('Service kicks off')
Example #4
0
    def poll(self):

        while not XBMCMonitor.abortRequested(self):

            if XBMCMonitor.waitForAbort(self, INTERVAL): 
                break
            if self.SettingsChanged:
                self.getSettings()

            _now = time.time()
            timers = handler.readTimerStrings()
            for _timer in timers:

                if not _timer['utime']:
                    handler.notifyLog('Couldn\'t calculate timestamp, delete timer', xbmc.LOGERROR)
                    self.resetSwitchTimer(_timer['channel'], _timer['date'])
                    break

                # delete old/discarded timers
                if _timer['utime'] + self.__discardTmr < _now:
                    self.resetSwitchTimer(_timer['channel'], _timer['date'])
                    continue

                _timediff = INTERVAL + self.__dispMsgTime/1000
                if _timer['utime'] - _now < _timediff:
                    chanIdTmr = self.channelName2channelId(_timer['channel'].decode('utf-8'))
                    if chanIdTmr:

                        # get player properties, switch if necessary

                        plrProps = self.getPlayer()
                        if chanIdTmr == plrProps['id']:
                            handler.notifyLog('Channel switching unnecessary')
                            handler.notifyOSD(__LS__(30000), __LS__(30027) % (_timer['channel'].decode('utf-8')), time=self.__dispMsgTime)
                        else:
                            switchAborted = False
                            secs = 0
                            handler.notifyLog('Channel switch to %s required' %  (_timer['channel'].decode('utf-8')))

                            if self.__showNoticeBeforeSw:
                                if self.__useCountdownTimer:
                                    percent = 0
                                    handler.OSDProgress.create(__LS__(30028), _timer['channel'].decode('utf-8'), _timer['title'].decode('utf-8'), __LS__(30029) % (int(self.__dispMsgTime/1000 - secs)))
                                    while secs < self.__dispMsgTime/1000:
                                        secs += 1
                                        percent = int((secs * 100)/self.__dispMsgTime)
                                        handler.OSDProgress.update(percent, _timer['channel'].decode('utf-8'), _timer['title'].decode('utf-8'), __LS__(30029) % (int(self.__dispMsgTime/1000 - secs)))
                                        xbmc.sleep(1000)
                                        if (handler.OSDProgress.iscanceled()):
                                            switchAborted = True
                                            break
                                    handler.OSDProgress.close()
                                else:
                                    idleTime = xbmc.getGlobalIdleTime()
                                    handler.notifyOSD(__LS__(30000), __LS__(30026) % (_timer['channel'].decode('utf-8')), time=self.__dispMsgTime)

                                    # wait for for cancelling by user (Ennieki ;)

                                    while secs < self.__dispMsgTime/1000:
                                        if idleTime > xbmc.getGlobalIdleTime():
                                            switchAborted = True
                                            break
                                        xbmc.sleep(1000)
                                        idleTime += 1
                                        secs += 1
                            else:
                                xbmc.sleep(self.__dispMsgTime)
 
                            if switchAborted:
                                handler.notifyLog('Channelswitch cancelled by user')
                            else:
                                if plrProps['player'] == 'audio' or (plrProps['player'] == 'video' and plrProps['media'] != 'channel'):

                                    # stop all other players except pvr

                                    handler.notifyLog('player:%s media:%s @id:%s is running' % (plrProps['player'], plrProps['media'], plrProps['playerid']))
                                    query = {
                                            "jsonrpc": "2.0",
                                            "method": "Player.Stop",
                                            "params": {"playerid": plrProps['playerid']},
                                            "id": 1
                                            }
                                    res = jsonrpc(query)
                                    if 'result' in res and res['result'] == "OK":
                                        handler.notifyLog('Player stopped')

                                handler.notifyLog('Currently playing channelid %s, switch to id %s' % (plrProps['id'], chanIdTmr))
                                query = {
                                        "jsonrpc": "2.0",
                                        "id": 1,
                                        "method": "Player.Open",
                                        "params": {"item": {"channelid": chanIdTmr}}
                                        }
                                res = jsonrpc(query)
                                if 'result' in res and res['result'] == 'OK':
                                    handler.notifyLog('Switched to channel \'%s\'' % (_timer['channel'].decode('utf-8')))
                                else:
                                    handler.notifyLog('Couldn\'t switch to channel \'%s\'' % (_timer['channel'].decode('utf-8')))
                                    handler.notifyOSD(__LS__(30000), __LS__(30025) % (_timer['channel'].decode('utf-8')), icon=__IconAlert__)

                        self.resetSwitchTimer(_timer['channel'], _timer['date'])
                        handler.notifyLog('Timer @%s deactivated' % (_timer['date']))

        handler.notifyLog('Service kicks off')
Example #5
0
    def poll(self):

        while not XBMCMonitor.abortRequested(self):

            if XBMCMonitor.waitForAbort(self, INTERVAL):
                break
            if self.SettingsChanged:
                self.getSettings()

            _now = time.time()
            _switchInstantly = False
            plrProps = self.getPlayer()

            for _timer in self.timers:

                if not _timer['utime']:
                    handler.notifyLog(
                        'Couldn\'t calculate timestamp, delete timer',
                        xbmc.LOGERROR)
                    self.resetTmr(_timer['date'])
                    break

                # delete old/discarded timers
                if _timer['utime'] + self.__discardTmr < _now:
                    self.resetTmr(_timer['date'])
                    continue

                if _timer['utime'] < _now: _switchInstantly = True
                if (_timer['utime'] - _now < INTERVAL +
                        self.__dispMsgTime / 1000) or _switchInstantly:
                    chanIdTmr = self.channelName2channelId(_timer['channel'])
                    if chanIdTmr:

                        # compare with player properties, switch if necessary

                        if chanIdTmr == plrProps['id']:
                            handler.notifyLog('Channel switching unnecessary')
                            handler.notifyOSD(
                                __LS__(30000),
                                __LS__(30027) %
                                (_timer['title'], _timer['channel']),
                                time=self.__dispMsgTime)
                        else:
                            switchAborted = False
                            secs = 0
                            handler.notifyLog('Channel switch to %s required' %
                                              (_timer['channel']))

                            if _switchInstantly:
                                handler.notifyLog(
                                    'immediate channel switching required')
                                handler.notifyOSD(
                                    __LS__(30000),
                                    __LS__(30027) %
                                    (_timer['title'], _timer['channel']),
                                    time=5000)

                            elif not self.__showNoticeBeforeSw:
                                xbmc.sleep(self.__dispMsgTime)

                            elif self.__useCountdownTimer:
                                handler.OSDProgress.create(
                                    __LS__(30028),
                                    __LS__(30026) %
                                    (_timer['channel'], _timer['title']),
                                    __LS__(30029) %
                                    (int(self.__dispMsgTime / 1000 - secs)))
                                while secs < self.__dispMsgTime / 1000:
                                    secs += 1
                                    percent = int(
                                        (secs * 100000) / self.__dispMsgTime)
                                    handler.OSDProgress.update(
                                        percent,
                                        __LS__(30026) %
                                        (_timer['channel'], _timer['title']),
                                        __LS__(30029) %
                                        (int(self.__dispMsgTime / 1000 -
                                             secs)))
                                    xbmc.sleep(1000)
                                    if (handler.OSDProgress.iscanceled()):
                                        switchAborted = True
                                        break
                                handler.OSDProgress.close()
                            else:
                                idleTime = xbmc.getGlobalIdleTime()
                                handler.notifyOSD(
                                    __LS__(30000),
                                    __LS__(30026) %
                                    (_timer['channel'], _timer['title']),
                                    time=self.__dispMsgTime)
                                while secs < self.__dispMsgTime / 1000:
                                    if idleTime > xbmc.getGlobalIdleTime():
                                        switchAborted = True
                                        break

                                    xbmc.sleep(1000)
                                    idleTime += 1
                                    secs += 1
                                if switchAborted:
                                    handler.notifyOSD(__LS__(30000),
                                                      __LS__(30032))

                            if switchAborted:
                                handler.notifyLog(
                                    'Channelswitch cancelled by user')
                            else:
                                self.has_started = False
                                self.switchToChannelId(plrProps, chanIdTmr,
                                                       _timer['channel'])

                    self.resetTmr(_timer['date'])

            if self.has_started and self.switchOnInit and self.channel > 0:
                handler.notifyLog('Channelswitch on startup enabled')
                query = {
                    "method": "PVR.GetChannels",
                    "params": {
                        "channelgroupid": "alltv",
                        "properties": ["channelnumber"]
                    }
                }
                res = jsonrpc(query)
                if 'result' in res:
                    for _channel in res['result']['channels']:
                        if _channel['channelnumber'] == self.channel:
                            handler.notifyLog(
                                'Channelswitch on startup is enabled, switch to \'%s\''
                                % (_channel['label']))
                            handler.notifyOSD(
                                __LS__(30000),
                                __LS__(30013) % (_channel['label']))
                            self.switchToChannelId(plrProps,
                                                   _channel['channelid'],
                                                   _channel['label'])
                            self.has_started = False
                            break

            self.timers = handler.getTimer()

        handler.notifyLog('Service kicks off')
    def poll(self):

        while not knClasses.XBMCMonitor.abortRequested(self):

            if knClasses.XBMCMonitor.waitForAbort(self, INTERVAL): break
            if self.SettingsChanged:
                self.getSettings()

            _now = time.time()
            _switchInstantly = False
            plrProps = self.getPlayer()

            for _timer in self.timers:

                if not _timer['utime']:
                    handler.notifyLog('Couldn\'t calculate timestamp, delete timer', xbmc.LOGERROR)
                    self.resetTmr(_timer['date'])
                    break

                # delete old/discarded timers
                if _timer['utime'] + self.__discardTmr < _now:
                    self.resetTmr(_timer['date'])
                    continue

                if _timer['utime'] - self.__leadOffset < _now: _switchInstantly = True
                if (_timer['utime'] - _now < INTERVAL + self.__dispMsgTime / 1000 + self.__leadOffset) or _switchInstantly:
                    chanIdTmr = self.channelName2channelId(_timer['channel'])
                    if chanIdTmr:

                        # compare with player properties, switch if necessary

                        if chanIdTmr == plrProps['id']:
                            handler.notifyLog('Channel switching unnecessary')
                            handler.notifyOSD(loc(30000), loc(30027) % (_timer['title'], _timer['channel']), time=self.__dispMsgTime)
                        else:
                            switchAborted = False
                            secs = 0
                            handler.notifyLog('Channel switch to %s required' % (_timer['channel']))

                            if _switchInstantly:
                                handler.notifyLog('immediate channel switching required')
                                handler.notifyOSD(loc(30000), loc(30027) % (_timer['title'], _timer['channel']), time=5000)
                            elif not self.__showNoticeBeforeSw: xbmc.sleep(self.__dispMsgTime)
                            elif self.__useCountdownTimer:
                                if os.path.exists(os.path.join(path, 'resources', 'skins', 'Default', '1080i', SKIN)):

                                    try:
                                        pvr = knClasses.cPvrProperties()
                                        pvrprops = dict()
                                        recEnabled = True
                                        pvrprops.update(pvr.getRecordingCapabilities(
                                            self.channelName2channelId(_timer['channel']), _timer['utime']))
                                        if pvrprops['hastimer']: recEnabled = False
                                    except (pvr.PvrAddTimerException, pvr.JsonExecException), e:
                                        handler.notifyLog(str(e), xbmc.LOGERROR)
                                        recEnabled = False

                                    Popup = knClasses.cNotification(SKIN, path, message=loc(30035) % (_timer['title'], _timer['channel']),
                                                          timer=self.__dispMsgTime/1000, icon=_timer['icon'], recEnabled=recEnabled)
                                    Popup.doModal()
                                    if Popup.isCanceled: switchAborted = True
                                    elif Popup.initRecording:
                                        try:
                                            pvr.setTimer(pvrprops['broadcastid'])
                                            handler.notifyLog('Recording schedule set for %s: %s' % (_timer['channel'], _timer['title']), xbmc.LOGNOTICE)
                                            switchAborted = True
                                        except (pvr.PvrAddTimerException, pvr.JsonExecException), e:
                                            handler.notifyOSD(loc(30000), loc(30036) % (_timer['title'], _timer['channel']), icon=IconAlert)
                                            handler.notifyLog(str(e), xbmc.LOGERROR)
                                    elif Popup.requestSwitch:
                                        handler.notifyLog('immediate channel switch initate by user')
                                    else:
                                        handler.notifyLog('Window countdown completed without user action')
                                else:
                                    handler.OSDProgress.create(loc(30028), loc(30026) %
                                                               (_timer['channel'], _timer['title']),
                                                               loc(30029) % (int(self.__dispMsgTime / 1000 - secs)))
                                    while secs < self.__dispMsgTime /1000:
                                        secs += 1
                                        percent = int((secs * 100000) / self.__dispMsgTime)
                                        handler.OSDProgress.update(percent, loc(30026) %
                                                                   (_timer['channel'], _timer['title']),
                                                                   loc(30029) % (int(self.__dispMsgTime / 1000 - secs)))
                                        xbmc.sleep(1000)
                                        if (handler.OSDProgress.iscanceled()):
                                            switchAborted = True
                                            break
                                    handler.OSDProgress.close()
                            else:
                                idleTime = xbmc.getGlobalIdleTime()
                                handler.notifyOSD(loc(30000), loc(30026) %
                                                  (_timer['channel'], _timer['title']), time=self.__dispMsgTime)
                                while secs < self.__dispMsgTime /1000:
                                    if idleTime > xbmc.getGlobalIdleTime():
                                        switchAborted = True
                                        break

                                    xbmc.sleep(1000)
                                    idleTime += 1
                                    secs += 1
                                if switchAborted: handler.notifyOSD(loc(30000), loc(30032))

                            if switchAborted: handler.notifyLog('Channelswitch cancelled by user')
                            else:
                                self.bootstrap = False
                                self.switchToChannelId(plrProps, chanIdTmr, _timer['channel'])

                    self.resetTmr(_timer['date'])
                            if switchAborted: handler.notifyLog('Channelswitch cancelled by user')
                            else:
                                self.bootstrap = False
                                self.switchToChannelId(plrProps, chanIdTmr, _timer['channel'])

                    self.resetTmr(_timer['date'])

            if self.bootstrap and self.__switchOnInit and self.__channel > 0:
                handler.notifyLog('Channelswitch on startup enabled')
                query = {
                        "method": "PVR.GetChannels",
                        "params": {"channelgroupid": "alltv", "properties": ["channelnumber"]}
                        }
                res = jsonrpc(query)
                if 'result' in res:
                    for _channel in res['result']['channels']:
                        if _channel['channelnumber'] == self.__channel:
                            handler.notifyLog('Channelswitch on startup is enabled, switch to \'%s\'' % (_channel['label']))
                            handler.notifyOSD(loc(30000), loc(30013) % (_channel['label']))
                            self.switchToChannelId(plrProps, _channel['channelid'], _channel['label'])
                            self.bootstrap = False
                            break

            self.timers = handler.getTimer()

        handler.notifyLog('Service kicks off')

service = Service()
service.poll()
del service
    def poll(self):

        while not XBMCMonitor.abortRequested(self):

            if XBMCMonitor.waitForAbort(self, INTERVAL):
                break
            if self.SettingsChanged:
                self.getSettings()

            _now = time.time()
            timers = handler.readTimerStrings()
            for _timer in timers:

                if not _timer["utime"]:
                    handler.notifyLog("Couldn't calculate timestamp, delete timer", xbmc.LOGERROR)
                    self.resetSwitchTimer(_timer["channel"], _timer["date"])
                    break

                # delete old/discarded timers
                if _timer["utime"] + self.__discardTmr < _now:
                    self.resetSwitchTimer(_timer["channel"], _timer["date"])
                    continue

                _timediff = INTERVAL + self.__dispMsgTime / 1000
                if _timer["utime"] - _now < _timediff:
                    chanIdTmr = self.channelName2channelId(_timer["channel"].decode("utf-8"))
                    if chanIdTmr:

                        # get player properties, switch if necessary

                        plrProps = self.getPlayer()
                        if chanIdTmr == plrProps["id"]:
                            handler.notifyLog("Channel switching not required")
                            handler.notifyOSD(
                                __LS__(30000),
                                __LS__(30027) % (_timer["channel"].decode("utf-8")),
                                time=self.__dispMsgTime,
                            )
                        else:
                            idleTime = xbmc.getGlobalIdleTime()
                            countdown = 0
                            switchAborted = False

                            handler.notifyLog("Channel switch to " + _timer["channel"].decode("utf-8") + "required")

                            if self.__useCountdownTimer:

                                # TODO:
                                # - only check every 30s, this should be enough, see line 24
                                # - the switch dialog should appear @ starttime minus 30s minus dialog-displaytime
                                #   then the user has enough time to react
                                # - translate "Switch to channel" and "seconds left". I'm too lazy right now ;)

                                ret = msgdialogprogress.create(
                                    "Channel switch requested",
                                    "Switch to Channel:" + (_timer["channel"].decode("utf-8")),
                                )
                                secs = 0
                                percent = 0
                                time_to_wait = self.__dispMsgTime
                                # use the multiplier 100 to get better %/calculation
                                increment = 100 * 100 / time_to_wait
                                cancelled = False
                                while secs < time_to_wait:
                                    secs = secs + 1
                                    # divide with 100, to get the right value
                                    percent = increment * secs / 100
                                    secs_left = str((time_to_wait - secs))
                                    remaining_display = str(secs_left) + " seconds left."
                                    msgdialogprogress.update(
                                        percent,
                                        str(_timer["channel"].decode("utf-8")),
                                        str(_timer["title"].decode("utf-8")),
                                        remaining_display,
                                    )
                                    xbmc.sleep(1000)
                                    if msgdialogprogress.iscanceled():
                                        switchAborted = True
                                        break
                                msgdialogprogress.close()

                            else:
                                handler.notifyOSD(
                                    __LS__(30000),
                                    __LS__(30026) % (_timer["channel"].decode("utf-8")),
                                    time=self.__dispMsgTime,
                                )

                                # wait for for cancelling by user (Ennieki ;)

                                while countdown < self.__dispMsgTime / 1000:
                                    if idleTime > xbmc.getGlobalIdleTime():
                                        switchAborted = True
                                        break
                                    xbmc.sleep(1000)
                                    idleTime += 1
                                    countdown += 1

                            if switchAborted:
                                handler.notifyLog("Channelswitch cancelled by user")
                            else:
                                if plrProps["player"] == "audio" or (
                                    plrProps["player"] == "video" and plrProps["media"] != "channel"
                                ):
                                    # stop the media player
                                    handler.notifyLog(
                                        "player:%s media:%s @id:%s is running"
                                        % (plrProps["player"], plrProps["media"], plrProps["playerid"])
                                    )
                                    query = {
                                        "jsonrpc": "2.0",
                                        "method": "Player.Stop",
                                        "params": {"playerid": plrProps["playerid"]},
                                        "id": 1,
                                    }
                                    res = jsonrpc(query)
                                    # is this faster?
                                    # xbmc.executebuiltin('PlayerControl(Stop)')
                                    if "result" in res and res["result"] == "OK":
                                        handler.notifyLog("Player stopped")

                                handler.notifyLog(
                                    "Currently playing channelid %s, switch to id %s" % (plrProps["id"], chanIdTmr)
                                )
                                query = {
                                    "jsonrpc": "2.0",
                                    "id": 1,
                                    "method": "Player.Open",
                                    "params": {"item": {"channelid": chanIdTmr}},
                                }
                                res = jsonrpc(query)
                                if "result" in res and res["result"] == "OK":
                                    handler.notifyLog("Switched to channel '%s'" % (_timer["channel"].decode("utf-8")))
                                else:
                                    handler.notifyLog(
                                        "Couldn't switch to channel '%s'" % (_timer["channel"].decode("utf-8"))
                                    )
                                    handler.notifyOSD(
                                        __LS__(30000),
                                        __LS__(30025) % (_timer["channel"].decode("utf-8")),
                                        icon=__IconAlert__,
                                    )

                        self.resetSwitchTimer(_timer["channel"], _timer["date"])
                        handler.notifyLog("Timer @%s deactivated" % (_timer["date"]))

        handler.notifyLog("Service kicks off")