Exemplo n.º 1
0
	def __init__(self, win, top = 6,left = 10):
		win.clear()
		
		self.win = win
		self.win.border()
		
		# This Sets the keys
		self.keys = key_strokes()

		self.timers = self.win.subwin(2, 10, top+1, left + 3)
		self.title = self.win.subwin(3, 40, top+1, left + 15)
		self.playtime = self.win.subwin(2, 40, top+4, left + 15)
		self.volume = self.win.subwin(7, 10, top+3, left + 2)
		self.shuffle = self.win.subwin(1,1,top+10, left + 5)
			
		self.windows = [self.timers, self.playtime, self.shuffle, self.volume, self.win, self.title]
		
		# This makes the set of which key is bound to which function
		key = self.keys
		self.keymaps = {
			key["x"] : xmms.play,
			key["c"] : xmms.pause,
			key["v"] : xmms.stop,
			key["z"] : xmms.playlist_prev,
			key["b"] : xmms.playlist_next,
			key["s"] : xmms.toggle_shuffle,
			key["up"] : lambda : xmms.set_main_volume(min(100, xmms.get_main_volume() + 10)),
			key["down"] : lambda : xmms.set_main_volume(max(0, xmms.get_main_volume() - 10)),
			key["right"] : lambda : xmms.jump_to_time(xmms.get_output_time()+5000),
			key["left"] : lambda : xmms.jump_to_time(max(0,xmms.get_output_time()-5000))
		};
Exemplo n.º 2
0
	def __init__(self, stdscr, top = 6,left = 10):
		self.stdscr = stdscr
		self.win = curses.newwin(13, 60, top, left)
		self.win.border()
		
		# Gets a list of recognised key - strokes
		self.keys = key_strokes()

		# The next block represents the various widgets
		self.timers = self.win.subwin(2, 10, top+1, left + 3)
		self.title = self.win.subwin(3, 40, top+1, left + 15)
		self.playtime = self.win.subwin(2, 40, top+4, left + 15)
		self.volume = self.win.subwin(7, 10, top+3, left + 2)
		self.jump = self.win.subwin(6, 45, top+6, left + 12)
		self.shuffle = self.win.subwin(1,1,top+10, left + 5)
		if xmms.is_shuffle():
			self.shuffle.insstr(0,0,"S")
			
		self.windows = [self.timers, self.playtime, self.shuffle, self.volume, self.win, self.jump, self.title]
		
		key = self.keys

		# maks the keys to their appropriate function
		self.keymaps = {
			key["x"] : xmms.play,
			key["c"] : xmms.pause,
			key["v"] : xmms.stop,
			key["z"] : xmms.playlist_prev,
			key["b"] : xmms.playlist_next,
			key["s"] : self.toggle_shuffle,
			key["j"] : self.search,
			key["q"] : sys.exit,
			key["esc"] : sys.exit,
			key["up"] : lambda : xmms.set_main_volume(min(100, xmms.get_main_volume() + 10)),
			key["down"] : lambda : xmms.set_main_volume(max(0, xmms.get_main_volume() - 10)),
			key["right"] : lambda : xmms.jump_to_time(xmms.get_output_time()+5000),
			key["left"] : lambda : xmms.jump_to_time(max(0,xmms.get_output_time()-5000))
		};
Exemplo n.º 3
0
    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))
Exemplo n.º 4
0
    def paintEvent(self, qe):
        if not self.isVisible() or not xmms.is_running():
            return
        self.time = QTime.currentTime()

        pts = QPointArray()
        paint = QPainter(self)

        xmms_pos = (1.0 * xmms.get_output_time() /
                    xmms.get_playlist_time(xmms.get_playlist_pos()))
        # paint.setBrush(QColor(255, 255 * xmms_pos, 255 * xmms_pos))
        paint.setPen(QColor(255, 255, 255))

        h = self.height() / 3
        if hasattr(self, "soundinfocache"):
            self.soundinfocache.repaint(paint, h, self.width())
            paint.drawText(0, 500, self.soundinfocache.title)
        s = xmms_pos * self.width()
        paint.drawRect(max(0, s), 0, 1, self.height())
        paint.drawRect(0, h * (2 - xmms_pos), self.width(), 1)
Exemplo n.º 5
0
	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)
Exemplo n.º 6
0
        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()
Exemplo n.º 7
0
    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))
Exemplo n.º 8
0
	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)
Exemplo n.º 9
0
    def eventhandler(self, event, menuw=None):
        """
        eventhandler for xmms. If an event is not bound in this
        function it will be passed over to the items eventhandler
        """

        # save this event so update_thread doesn't get fooled
        self.last_event = event

        if event == PLAY_END and event.arg:
            self.stop()
            if self.playerGUI.try_next_player():
                return True

        if event in ( STOP, PLAY_END, USER_END ):
            self.playerGUI.stop()
            return self.item.eventhandler(event)

        elif event == PAUSE or event == PLAY:
            xmms.pause()
            return True

        elif event == SEEK:
            curtime = xmms.get_output_time()
            nexttime = curtime + (event.arg * 1000)

            # trim down seek time if it past end of the song
            while nexttime > xmms.get_playlist_time(xmms.get_playlist_pos()):
                event.arg/=2
                nexttime = curtime + (event.arg * 1000)
            xmms.jump_to_time(nexttime)
            return True

        else:
            # everything else: give event to the items eventhandler
            return self.item.eventhandler(event)
Exemplo n.º 10
0
    def eventhandler(self, event, menuw=None):
        """
        eventhandler for xmms. If an event is not bound in this
        function it will be passed over to the items eventhandler
        """

        # save this event so update_thread doesn't get fooled
        self.last_event = event

        if event == PLAY_END and event.arg:
            self.stop()
            if self.playerGUI.try_next_player():
                return True

        if event in (STOP, PLAY_END, USER_END):
            self.playerGUI.stop()
            return self.item.eventhandler(event)

        elif event == PAUSE or event == PLAY:
            xmms.pause()
            return True

        elif event == SEEK:
            curtime = xmms.get_output_time()
            nexttime = curtime + (event.arg * 1000)

            # trim down seek time if it past end of the song
            while nexttime > xmms.get_playlist_time(xmms.get_playlist_pos()):
                event.arg /= 2
                nexttime = curtime + (event.arg * 1000)
            xmms.jump_to_time(nexttime)
            return True

        else:
            # everything else: give event to the items eventhandler
            return self.item.eventhandler(event)
Exemplo n.º 11
0
 def refresh(self):
     curtime = xmms.get_output_time()
     curtime = int(curtime / 1000)
     self.elapsed = self.item.elapsed = curtime
     self.playerGUI.refresh()
Exemplo n.º 12
0
 def drawTime(self):
     pos = int(1.0 * xmms.get_output_time() / self.item.dur * self.width())
     print pos
Exemplo n.º 13
0
 def getElapsed(self):
     return xmms.get_output_time() / 1000.0
Exemplo n.º 14
0
	def getElapsed(self):
		return xmms.get_output_time()/1000.0
Exemplo n.º 15
0
 def refresh(self):
     curtime = xmms.get_output_time()
     curtime = int(curtime / 1000)
     self.elapsed = self.item.elapsed = curtime
     self.playerGUI.refresh()