3 #from brisa.core.reactors import install_default_reactor
4 #reactor = install_default_reactor()
6 from brisa.core import log
7 from brisa.upnp.device import Service, ServiceController
11 class PlayListOutBoundExcept(Exception):
13 return "Play List Out of Bounds!"
17 class PlayList(Service):
21 Implements a playlist for ZukeBox server.
24 service_type = "urn:schemas-upnp-org:service:PlayList:1"
25 service_name = "PlayList"
27 def __init__(self, positions=10, xml_path=''):
28 scpd_path = pjoin(xml_path, "zukebox-playlist-scpd.xml")
29 Service.__init__(self, self.service_name, self.service_type, '', scpd_path,
30 PlayListControl(positions, self.service_type))
32 def get_playlist(self):
33 return self.control_controller.get_playlist()
35 class PlayListControl(ServiceController):
37 def __init__(self, positions, serv_type):
38 ServiceController.__init__(self, serv_type)
39 self.positions = positions
42 self.prev = self.current
46 self.current_uri = None
47 self.current_uri_metadata = None
49 def soap_IsLocked(self, *args, **kwargs):
51 if not len(self.list) == self.positions:
53 rt = {"Locked": locked}
54 return {"IsLockedResponse": rt}
56 def soap_IsAvailble(self, *args, **kwargs):
58 if not len(self.list) == 0:
60 rt = {"Availble": availble}
61 return {"IsAvailbleResponse": rt}
63 def soap_IsAvailble(self, *args, **kwargs):
65 if not len(self.list) == 0:
67 rt = {"Availble": availble}
68 return {"IsAvailbleResponse": rt}
70 def soap_Append(self, *args, **kwargs):
71 """Put a object in the playlist
73 if not self.is_locked():
74 self.current_uri = kwargs["CurrentURI"]
75 self.current_uri_metadata = kwargs["CurrentURIMetaData"]
76 self.from_name = kwargs["FromName"]
77 self.to_name = kwargs["ToName"]
78 self.list.append(self.current_uri)
82 raise PlayListOutBoundExcept()
84 def soap_Drop(self, *args, **kwargs):
85 """Pop the object at position passed by index
87 if self.is_availble():
88 index = kwargs["Index"]
92 raise PlayListOutBoundExcept()
94 def soap_GetSizeOfPlayList(self, *args, **kwargs):
95 """Return the size of playlist"""
96 lenght = len(self.list)
97 rt = {"PlayListSize": lenght}
98 return {"GetSizeOfPlayListResponse": rt}
100 def soap_GetCurrent(self, *args, **kwargs):
101 if self.is_availble():
102 rt = {"CurrentPosition": self.list[self.current]}
103 return {"GetCurrentResponse": rt}
105 def clean_playlist(self):
106 if self.is_availble():
109 def get_playlist(self):