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_IsAvailble(self, *args, **kwargs):
63 if not len(self.list) == 0:
65 rt = {"Availble": availble}
66 return {"IsAvailbleResponse": rt}
68 def soap_Append(self, *args, **kwargs):
69 """Put a object in the playlist
71 if not self.is_locked():
72 self.current_uri = kwargs["CurrentURI"]
73 self.current_uri_metadata = kwargs["CurrentURIMetaData"]
74 self.from_name = kwargs["FromName"]
75 self.to_name = kwargs["ToName"]
76 self.list.append(self.current_uri)
80 raise PlayListOutBoundExcept()
82 def soap_Drop(self, *args, **kwargs):
83 """Pop the object at position passed by index
85 if self.is_availble():
86 index = kwargs["Index"]
90 raise PlayListOutBoundExcept()
92 def soap_GetSizeOfPlayList(self, *args, **kwargs):
93 """Return the size of playlist"""
94 lenght = len(self.list)
95 rt = {"PlayListSize": lenght}
96 return {"GetSizeOfPlayListResponse": rt}
98 def soap_GetCurrent(self, *args, **kwargs):
99 if self.is_availble():
100 rt = {"CurrentPosition": self.list[self.current]}
101 return {"GetCurrentResponse": rt}
103 def clean_playlist(self):
104 if self.is_availble():
107 def get_playlist(self):