4 from brisa.core import log
5 from brisa.upnp.device import Service, ServiceController
9 class PlayListOutBoundExcept(Exception):
11 return "Play List Out of Bounds!"
15 class PlayList(Service):
19 Implements a playlist for ZukeBox server.
22 service_type = "urn:schemas-upnp-org:service:PlayList:1"
23 service_name = "PlayList"
25 def __init__(self, positions=10, xml_path):
26 scpd_path = pjoin(xml_path, "zukebox-playlist-scpd.xml")
27 Service.__init__(self, service_name, service_type, '', scpd_path,
28 PlayListControl(positions, service_type))
30 def get_playlist(self):
31 return self.control_controller.get_playlist()
33 class PlayListControl(ServiceController):
35 def __init__(self, positions, serv_type):
36 ServiceController.__init__(self, serv_type)
37 self.positions = positions
40 self.prev = self.current
44 self.current_uri = None
45 self.current_uri_metadata = None
47 def soap_IsLocked(self, *args, **kwargs):
49 if not len(self.list) == self.positions:
51 rt = {"Locked": locked}
52 return {"IsLockedResponse": rt}
54 def soap_IsAvailble(self, *args, **kwargs):
56 if not len(self.list) == 0:
58 rt = {"Availble": availble}
59 return {"IsAvailbleResponse": rt}
61 def soap_Append(self, *args, **kwargs):
62 """Put a object in the playlist
64 if not self.is_locked():
65 self.current_uri = kwargs["CurrentURI"]
66 self.current_uri_metadata = kwargs["CurrentURIMetaData"]
67 self.from_name = kwargs["FromName"]
68 self.to_name = kwargs["ToName"]
69 self.list.append(self.current_uri)
73 raise PlayListOutBoundExcept()
75 def soap_Drop(self, *args, **kwargs):
76 """Pop the object at position passed by index
78 if self.is_availble():
79 index = kwargs["Index"]
83 raise PlayListOutBoundExcept()
85 def soap_GetSizeOfPlayList(self, *args, **kwargs):
86 """Return the size of playlist"""
87 lenght = len(self.list)
88 rt = {"PlayListSize": lenght}
89 return {"GetSizeOfPlayListResponse": rt}
91 def soap_GetCurrent(self, *args, **kwargs):
92 if self.is_availble():
93 rt = {"CurrentPosition": self.list[self.current]}
94 return {"GetCurrentResponse": rt}
96 def clean_playlist(self):
97 if self.is_availble():
100 def get_playlist(self):