Exemplo n.º 1
0
    def client(self,rid):
        rid = int(rid)
        if not self._clients.has_key(rid):
            return self.clients()   # no longer present.

        result = ClientProfiles.makeStandardResponse( cherrypy.request, "mediaclient" )

        result["rid"] = rid
        result["def_folder"] = ""   # blank
        result["sid"] = ""
        srvc = self._servers.default_server_for_renderer(device_name(self._clients[rid]))
        if srvc:
            result["sid"] = srvc._server_id
            result["def_folder"] = srvc.get_default_container_id()
        result["limit"] = 50

        # udn needed so client can pick up the correct event set.
        result["udn"] = self._clients[rid].device.get_id()
        result["name"] = device_name(self._clients[rid])
        result["hasTransport"] = True   # play,pause,position etc.
        result["hasRenderer"] = True    # volume
        result["showServers"] = True    # so can select tracks etc.
        self.add_clients( result )

        return result
Exemplo n.º 2
0
    def generate_list(self, result, rid, id, offset, limit):
        #
        # if id is none then list the server sources.
        # else it a server-id:container-id.
        # 
        # Output is an update to the result dictionary
        # and the id of the container it is from.
        #
        _log.debug( "list id %s", id )
        result["rid"] = str(rid)    # in case browsing after select renderer
        if rid:
            rid = int(rid)
            result["name"] = device_name(self._clients[rid])
        else:
            result["name"] = ""

        srvc = None
        if id:
            srvc = self._servers.get_server(id)
            if srvc:
                ctr = srvc.get_container( id )

        elif rid and self._clients.has_key(rid):
            srvc = self._servers.default_server_for_renderer(device_name(self._clients[rid]))
            if srvc:
                id = srvc.get_top_level_container_id()
                ctr = srvc.get_container( id )

        result["title"] = "Browse"
        if srvc:
            _log.debug( "ctr %s", ctr )
            if ctr: 
                result["title"] = ctr.title()
#            result["title"] = "%s %s %s" % (ctr.artist(), ctr.album(), ctr.title())
            result["items"] = list()
            for ntry in srvc.enum_container(ctr, offset):
                result["items"].append( ntry )
                if len(result["items"]) >= limit:
                    break

            result["id"] = id   # container id
            result["offset"] = offset
            result["total"] = ctr.size()
            result["count"] = len(result["items"])
            result["limit"] = limit

            result["breadcrumb"] = srvc.get_breadcrumb_trail(ctr)

        else:
            result["items"] = self._servers.get_servers()
Exemplo n.º 3
0
    def playqueue(self, rid):
        _log.debug( "playqueue on %s", rid )
        if rid:
            rid = int(rid)
            srv = self._servers.default_server_for_renderer(device_name(self._clients[rid]))
            cid = srv.get_default_container_id()
            ctr = srv.get_container(cid)

            # get hold of the server and add to queue.
            self._coherence.ctrl.play_item( srv._client, self._clients[rid], ctr, False )
        return self.client(rid)
Exemplo n.º 4
0
    def zonelink(self, rid ):
        rid = int(rid)
        if not self._clients.has_key(rid):
            return self.clients()   # no longer present.

        result = ClientProfiles.makeStandardResponse( cherrypy.request, "mediazonelink" )

        result["rid"] = rid

        # udn needed so client can pick up the correct event set.
        result["udn"] = self._clients[rid].device.get_id()
        result["name"] = device_name(self._clients[rid])

        result["clients"] = {}
        for k in self._clients:
            clnt = self._clients[k]
            if clnt and k <> rid:   # exclude self.
                result["clients"][k] = device_name(clnt)

        # create list of zones
        return result
Exemplo n.º 5
0
 def add_clients(self,result):
     result["clients"] = {}
     result["links"] = {}
     for k in self._clients:
         clnt = self._clients[k]
         if clnt:
             result["clients"][k] = device_name(clnt)
             result["links"][k] = {}
             for k2 in self._clients:
                 if k2 <> k and self._clients[k2]:
                     # This shows wheteher we should display Link/UnLink for this client pair.
                     result["links"][k][k2] = (True,True)
Exemplo n.º 6
0
    def showqueue(self, rid):
        rid = int(rid)
        id = None
        srvc = self._servers.default_server_for_renderer(device_name(self._clients[rid]))
        if srvc:
            id = srvc.get_default_container_id()

        result = ClientProfiles.makeStandardResponse( cherrypy.request, "showqueue" )
        self.generate_list(result, rid, id, 0, sys.maxint )

        self.log_result(result)

        return result