Example #1
0
    def deferUpdateReachability(self, addTimer=True, logInfo=True):
        if addTimer and not self.deferReachabilityTimer:
            self.deferReachabilityTimer = plexapp.createTimer(
                1000,
                callback.Callable(self.onDeferUpdateReachabilityTimer),
                repeat=True)
            plexapp.APP.addTimer(self.deferReachabilityTimer)
        else:
            if self.deferReachabilityTimer:
                self.deferReachabilityTimer.reset()

        if self.deferReachabilityTimer and logInfo:
            util.LOG(
                'Defer update reachability for all devices a few seconds: GDMactive={0}'
                .format(gdm.DISCOVERY.isActive()))
Example #2
0
    def refresh(self, force=True, delay=False, wait=False):
        # Ignore refreshing local PQs
        if self.isLocal():
            return

        if wait:
            self.responded = False
            self.initialized = False
        # We refresh our play queue if the caller insists or if we only have a
        # portion of our play queue loaded. In particular, this means that we don't
        # refresh the play queue if we're asked to refresh because a new track is
        # being played but we have the entire album loaded already.

        if force or self.isWindowed():
            if delay:
                # We occasionally want to refresh the PQ in response to moving to a
                # new item and starting playback, but if we refresh immediately:
                # we probably end up refreshing before PMS realizes we've moved on.
                # There's no great solution, but delaying our refresh by just a few
                # seconds makes us much more likely to get an accurate window (and
                # accurate selected IDs) from PMS.

                if not self.refreshTimer:
                    self.refreshTimer = plexapp.createTimer(
                        5000, self.onRefreshTimer)
                    plexapp.APP.addTimer(self.refreshTimer)
            else:
                request = plexrequest.PlexRequest(
                    self.server, "/playQueues/" + str(self.id))
                self.addRequestOptions(request)
                context = request.createRequestContext(
                    "refresh", callback.Callable(self.onResponse))
                plexapp.APP.startRequest(request, context)

        if wait:
            return self.waitForInitialization()