def songs_that_match(self,string): '''List of Songs with string in their song name''' songs = [] for i in range(xmms.get_playlist_length()): if string.lower() in xmms.get_playlist_title(i).lower(): songs.append(i) return songs
def songs_that_match(self,string): '''This Returns a List of Songs that Match a Pattern''' songs = [] for i in range(xmms.get_playlist_length()): if string.lower() in xmms.get_playlist_title(i).lower(): songs.append(i) return songs
def get_artist(self): if not self.isFrozen: playlistPosition = xmms.get_playlist_pos() title = xmms.get_playlist_title(playlistPosition) metaData = title.split(" - ") self.artist = metaData[0] return self.artist
def draw_jump(self,string): '''This Draws Jump.... But also returns selected song''' self.jump.clear() self.jump.insstr(1,2,"Search: %s" % string) songs = self.songs_that_match(string) # saves the length of the matching song list self.length = len(songs) try: slice = songs[self.base:self.base+3] except: slice = songs[:3] i = 2 for song in slice: if self.highlight + 2 == i: style = curses.A_STANDOUT else: style = curses.A_NORMAL self.jump.insstr(i,2,xmms.get_playlist_title(song)[:42],style) i = i + 1 self.jump.border() print >> log, "slice =", str(slice) # return the song number, or -1 try: return slice[self.highlight] except: return -1
def draw_jump(self,string): '''This Draws Jump.... But also returns highlighted Song''' self.jump.clear() self.jump.insstr(1,2,"Search: %s" % string) self.song_list = self.songs_that_match(string) # This tries to get a particular slice try: print_slice = self.song_list[self.base:self.base+3] except: print_slice = self.song_list[:3] i = 2 for j in print_slice: # This next Line Selects if it should be formatted if self.highlight + 2 == i: style = curses.A_STANDOUT else: style = curses.A_NORMAL self.jump.insstr(i,2,xmms.get_playlist_title(j)[:42],style) i = i + 1 self.jump.border() # this next block returns the highlighted song. If there is none, then # it returns -1 try: return print_slice[self.highlight] except: return -1
def play_title(self): title = "XMMS not playing!" if xmms.is_playing(): idx = xmms.get_playlist_pos() title = xmms.get_playlist_title(idx) print "Sending title '%s'." % title self.client_socket.sendall(title)
def update(self): # Calculate the time step now = time.time() dt = now - self.lastTime self.lastTime = now # Get the current song title title = str(xmms.get_playlist_title(xmms.get_playlist_pos())) if len(title) > self.vfd.width: # Scroll it around so we can see the whole thing. At the beginning # of the scroll cycle it delays by scrollerDelay scroll cycles, # and there is a scrollerGap character gap between copies of the scrolled title. if title != self.lastTitle: self.scrollerIndex = -self.scrollerDelay self.lastTitle = title if self.scrollerIndex >= 1: self.scrollerIndex %= self.scrollerGap + len(title) if self.scrollerIndex < 1: self.scrollerIndex = -self.scrollerDelay else: title = ("%s%s%s" % (title, " " * self.scrollerGap, title))[int(self.scrollerIndex):] self.scrollerIndex += dt * self.scrollSpeed # get the current time index if xmms.is_playing(): millisec = xmms.get_output_time() minutes = millisec / 60000 seconds = (millisec % 60000) / 1000.0 playTime = "%3d:%05.2f" % (minutes, seconds) else: playTime = " --:--.--" if xmms.is_paused(): spinner = self.spinnerPaused elif xmms.is_playing(): self.spinnerIndex %= len(self.spinnerPlaying) spinner = self.spinnerPlaying[int(self.spinnerIndex)] self.spinnerIndex += dt * self.spinnerSpeed else: spinner = self.spinnerIdle # Clock with a flashing colon self.colonIndex += dt * 3 self.colonIndex %= 2 clock = time.strftime("%%H%s%%M" % ": "[int(self.colonIndex)], time.localtime()) spinnerChar = self.vfd.userDefinedCharacters[0] self.vfd.defineCharacter(spinnerChar, spinner) self.vfd.writeScreen("%s\n%-9s%s %s" % (title, clock, playTime, spinnerChar))
def update(self): '''This Refreshes the Screen... It calculates times and such, and then draws''' time = xmms.get_output_time()/1000 num = xmms.get_playlist_pos() title = xmms.get_playlist_title(num) shuffle = xmms.is_shuffle() length = xmms.get_playlist_time(num) / 1000 self.win.border() self.shuffle.clear() if shuffle: self.shuffle.insstr(0,0,"S") t = format_time(time) self.timers.clear() self.timers.addstr(t) self.title.clear() self.title.addstr("%d. %s (%s)" % (num,title,format_time(length))) t = (time * 40) / length self.playtime.clear() self.playtime.insstr(0,0,'.' * t) self.playtime.insstr(0, min(t,39), '%',curses.A_BOLD) if t < 39: self.playtime.insstr(0,t+1,'.' * (39 -t)) self.volume.clear() v = xmms.get_main_volume() self.volume.insstr(0,0, 'Vol: %2d' % (v)) v = int(round(v / 10)) for i in range(0, 5): if (i * 2 < v): self.volume.hline(6-i, 0, '#', 2*i-1, curses.A_BOLD) else: self.volume.hline(6-i, 0, '_', 2*i-1) # # gratuitous use of lambda map(lambda a: a.refresh(), self.windows)
def mw_xmms_update(self): try: stime = xmms.get_output_time() stitle = xmms.get_playlist_title(xmms.get_playlist_pos()) if stitle: minutes = stime/1000.0/60 seconds = (minutes-int(minutes))*60 # Format the message self.wm_xmms_message.set_text('%s %d:%02d' % (stitle, minutes,seconds)) self.events.add_timer(event.TimerEvent(XMMSTimerEvent, after = 1)) except: # There was some problem, so we'll try again in 20 seconds. self.events.add_timer(event.TimerEvent(XMMSTimerEvent, after = 20)) import traceback traceback.print_exc()
def slowUpdate(self): # Get the current song title title = str(xmms.get_playlist_title(xmms.get_playlist_pos())) if len(title) > self.vfd.width: # Scroll it around so we can see the whole thing. At the beginning # of the scroll cycle it delays by scrollerDelay scroll cycles, # and there is a scrollerGap character gap between copies of the scrolled title. if title != self.lastTitle: self.scrollerIndex = -self.scrollerDelay self.lastTitle = title if self.scrollerIndex > 0: self.scrollerIndex %= self.scrollerGap + len(title) if self.scrollerIndex == 0: self.scrollerIndex = -self.scrollerDelay else: title = ("%s%s%s" % (title, " " * self.scrollerGap, title))[self.scrollerIndex:] self.scrollerIndex += 1 # get the current time index if xmms.is_playing(): millisec = xmms.get_output_time() minutes = millisec / 60000 seconds = (millisec % 60000) / 1000.0 playTime = "%3d:%02d" % (minutes, seconds) else: playTime = " --:--" # Status string if xmms.is_paused(): status = 'Paused' spinner = '-' elif xmms.is_playing(): status = 'Playing...' self.spinnerState = self.spinnerState[1:] + self.spinnerState[0] spinner = self.spinnerState[0] else: status = 'Idle' spinner = ' ' self.vfd.writeScreen("%s\n%-12s%s %s" % (title, status, playTime, spinner))
def update(self): '''Updates all windows''' # This block gets variables, like time, number, title. etc... time = xmms.get_output_time()/1000 num = xmms.get_playlist_pos() title = xmms.get_playlist_title(num) shuffle = xmms.is_shuffle() length = xmms.get_playlist_time(num) / 1000 t = format_time(time) self.timers.clear() self.timers.addstr(t) self.title.clear() self.title.addstr("%d. %s (%s)" % (num,title,format_time(length))) t = (time * 40) / length self.playtime.clear() self.playtime.insstr(0,0,'.' * t) self.playtime.insstr(0, min(t,39), '%',curses.A_BOLD) if t < 39: self.playtime.insstr(0,t+1,'.' * (39 -t)) self.volume.clear() v = xmms.get_main_volume() self.volume.insstr(0,0, 'Vol: %2d' % (v)) # draws the volume bar v = int(round(v / 10)) for i in range(0, 5): if (i * 2 < v): self.volume.hline(6-i, 0, '#', 2*i-1, curses.A_BOLD) else: self.volume.hline(6-i, 0, '_', 2*i-1) # # gratuitous use of lambda map(lambda a: a.refresh(), self.windows)
def getxmmsinfo(self): while self.listView.lastItem(): self.listView.takeItem(self.listView.lastItem()) self.xmms_playlist = [] cur_pos = xmms.get_playlist_pos() for i in range(xmms.get_playlist_length()): item = QListViewItem(self.listView) item.playlist_pos = i item.title = xmms.get_playlist_title(i) item.dur = int(xmms.get_playlist_time(i)) item.file = xmms.get_playlist_file(i) self.xmms_playlist.append(item) dur_s = str(item.dur / 60000) + ":" + ("0" + str( (item.dur / 1000) % 60))[-2:] pp = str(i + 1) item.setText(0, " " * (5 - len(pp)) + pp) item.setText(1, item.title) item.setText(2, dur_s) if cur_pos == i: self.listView.setSelected(item, True)
def a(): xmms.playlist_next() print xmms.is_playing() time.sleep(0.1) print xmms.get_playlist_title(xmms.get_playlist_pos())
# displays current playing song in xmms (xchat script) # (C) 2005 Igor Pozgaj <*****@*****.**> import xchat from xmms import get_playlist_title, get_playlist_pos __module_name__ = "nowPlaying" __module_version__ = "1.0" __module_description__ = "Displays what song is currently playing in Xmms" song = get_playlist_title (get_playlist_pos()) try: xchat.command ("me plays: " + song) except TypeError: xchat.prnt ("Xmms is not running")