def beginSong(self, file): self.selectedSong = None manager.setCpuSpeed('load') manager.display.fill((0, 0, 0)) winWidth, winHeight = manager.displaySize winCenter = winWidth / 2 rowA = winHeight / 3 rowC = winHeight * 5 / 6 self.__writeSongTitle(file, rowA) text = self.subtitleFont.render("Loading", True, (255, 255, 255)) rect = text.get_rect() rect = rect.move(winCenter - rect.centerx, rowC) manager.display.blit(text, rect) pygame.display.flip() # This will call the songFinishedCallback, so call it early. self.shutdown() self.writeMarkedSongs() player = file.MakePlayer(self.songDb, self.errorPopupCallback, self.songFinishedCallback) if player == None: return # Start playing. try: player.Play() except: self.errorPopupCallback("Error starting player.\n%s\n%s" % (sys.exc_info()[0], sys.exc_info()[1])) return # Go to sleep until the song is over. try: manager.WaitForPlayer() except: self.errorPopupCallback("Error while playing song.\n%s\n%s" % (sys.exc_info()[0], sys.exc_info()[1])) return # The song is over. Now recover control and redisplay the # song list. manager.OpenCPUControl() manager.setCpuSpeed('menu_fast') self.heldStartTicks = pygame.time.get_ticks() manager.InitPlayer(self) manager.OpenDisplay() # In case the screen has been resized during the song. self.setupScrollWindow() self.screenDirty = True # Discard any events that occurred while we were resetting the # display. for event in pygame.event.get(): pass
def main(): player = mpgPlayer(None, None) player.Play() manager.WaitForPlayer()