def switch(self, num, *any): # bookmarks, favourite channel, cat = conf.switch_channel.split(":") # get list streams = self.parent.channels[channel].streams[cat] # pickrandom if conf.switch_random: self.last = random.randint(0, len(streams) - 1) # or iterate over list else: self.last = self.last + num if self.last >= len(streams): self.last = 0 elif self.last < 0: self.last = len(streams) - 1 # play i = self.last action.play(streams[i]["url"], streams[i]["format"]) # set pointer in gtk.TreeView if self.parent.channels[channel].current == cat: self.parent.channels[channel].gtk_list.get_selection().select_path( i)
def play(self): row = self.row() if row and "url" in row: # playlist and audio type audioformat = row.get("format", self.audioformat) listformat = row.get("listformat", self.listformat) # invoke audio player action.play(row, audioformat, listformat) elif row.get("homepage") and row.get("format") == "text/html": action.browser(row["homepage"]) else: self.status("No station selected for playing.") return row
def play(self): row = self.row() rx_sound = re.compile("""(http://[^"<>]+[.](mp3|ogg|m3u|pls|ram))""") html = ahttp.get(row["homepage"]) # look up ANY audio url for uu in rx_sound.findall(html): log.DATA(uu) (url, fmt) = uu row["url"] = url action.play(row, mime_fmt(fmt), "srv") return # or just open webpage action.browser(row["homepage"])
def test(): say = aiy.audio.say('hello') action.play(say, 'play')
def play(self, player): for action in self.actions: ans = input("Play action %s?(y/n)\n" % (action)) if ans[0] == "y": action.play(player)
def play(self, row, *args, **kwargs): action.play(row=row, audioformat=row.get("format", "audio/mpeg"), source=row.get("listformat", "href"))