def playNext(self, atf=None): filename = None stop = None selection = 0 ## Plays the next file in the queue (if it exists). # Are we random? if self.wTree.get_object("mnuiRandom").get_active(): selection = randint(0, queue.length()-1) isvideo = queue.isTrackVideo(selection) # If we've just started Whaawmp, self.isvideo is None # in this case, disable gapless until we are sure it'll work if self.isvideo is None: filename = queue.getTrackRemove(selection) stop = True elif atf: # For gapless playback, both the current and next items _must_ be # audio only if not isvideo and not self.isvideo: filename = queue.getTrackRemove(selection) stop = False elif atf is False: # We are a queue of videos, or standalone files filename = queue.getTrackRemove(selection) stop = True if filename is not None and stop is not None: self.isvideo = isvideo self.playFile(filename, stop)
def onPlayerMessage(self, bus, message): t = message.type if (t == gst.MESSAGE_EOS): if (self.wTree.get_object("mnuiRepeatOne").get_active()): player.seek(0) else: if (self.wTree.get_object("mnuiRepeatAll").get_active()): queue.append(player.uri) # At the end of a stream, play next item from queue. # Or stop if the queue is empty. if (queue.length() > 0): self.playNext(atf=False) elif (self.wTree.get_object("mnuiQuitOnStop").get_active()): # Quit of the 'quit on stop' option is enabled. self.quit() else: # Otherwise, just stop. player.stop() elif (t == gst.MESSAGE_ERROR): # On an error, empty the currently playing file (also stops it). self.playFile(None) # Show an error about the failure. msg = message.parse_error() signals.emit('error', str(msg[0]) + '\n\n' + str(msg[1]), _('Error!')) elif (t == gst.MESSAGE_STATE_CHANGED and message.src == player.player): self.onPlayerStateChange(message) elif (t == gst.MESSAGE_TAG): # Tags!! self.setPlayingTitle(message.parse_tag())
def togglePlayPause(self, widget=None): ## Toggles the player play/pause. if (not player.togglePlayPause()): # If toggling fails: # Check the queue. if (queue.length()): self.playNext(atf=False) else: # Otherwise show the open file dialogue. self.showOpenDialogue() return