Now with pausing too!

This commit is contained in:
Raoul Snyman 2011-08-30 23:20:32 +02:00
parent c41e7c49df
commit 0d16b05779
2 changed files with 25 additions and 2 deletions

View File

@ -617,6 +617,9 @@ class AudioPlayer(QtCore.QObject):
if len(self.playlist) > self.currentIndex: if len(self.playlist) > self.currentIndex:
self.mediaObject.enqueue(self.playlist[self.currentIndex]) self.mediaObject.enqueue(self.playlist[self.currentIndex])
def connectVolumeSlider(self, slider):
slider.setAudioOutput(self.audioObject)
def reset(self): def reset(self):
""" """
Reset the audio player, clearing the playlist and the queue. Reset the audio player, clearing the playlist and the queue.
@ -632,8 +635,7 @@ class AudioPlayer(QtCore.QObject):
""" """
log.debug(u'AudioPlayer.play() called') log.debug(u'AudioPlayer.play() called')
if self.currentIndex == -1: if self.currentIndex == -1:
self.currentIndex += 1 self.onAboutToFinish()
self.mediaObject.enqueue(self.playlist[self.currentIndex])
self.mediaObject.play() self.mediaObject.play()
def pause(self): def pause(self):

View File

@ -256,6 +256,13 @@ class SlideController(QtGui.QWidget):
self.songMenu.setMenu(QtGui.QMenu( self.songMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Go To'), self.toolbar)) translate('OpenLP.SlideController', 'Go To'), self.toolbar))
self.toolbar.makeWidgetsInvisible([u'Song Menu']) self.toolbar.makeWidgetsInvisible([u'Song Menu'])
# Stuff for items with background audio.
#self.toolbar.addToolbarSeparator(u'Audio Separator')
self.audioPauseItem = self.toolbar.addToolbarButton(
u'Pause Audio', u':/slides/media_playback_pause.png',
translate('OpenLP.SlideController', 'Pause audio.'),
self.onAudioPauseClicked, True)
self.audioPauseItem.setVisible(False)
# Build the volumeSlider. # Build the volumeSlider.
self.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal) self.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
self.volumeSlider.setTickInterval(1) self.volumeSlider.setTickInterval(1)
@ -619,11 +626,14 @@ class SlideController(QtGui.QWidget):
if self.isLive: if self.isLive:
self.songMenu.menu().clear() self.songMenu.menu().clear()
self.display.audioPlayer.reset() self.display.audioPlayer.reset()
self.setAudioItemsVisibility(False)
self.audioPauseItem.setChecked(False)
if self.serviceItem.is_capable(ItemCapabilities.HasBackgroundAudio): if self.serviceItem.is_capable(ItemCapabilities.HasBackgroundAudio):
log.debug(u'Starting to play...') log.debug(u'Starting to play...')
self.display.audioPlayer.addToPlaylist( self.display.audioPlayer.addToPlaylist(
self.serviceItem.background_audio) self.serviceItem.background_audio)
self.display.audioPlayer.play() self.display.audioPlayer.play()
self.setAudioItemsVisibility(True)
row = 0 row = 0
text = [] text = []
for framenumber, frame in enumerate(self.serviceItem.get_frames()): for framenumber, frame in enumerate(self.serviceItem.get_frames()):
@ -1103,6 +1113,17 @@ class SlideController(QtGui.QWidget):
self.playSlidesLoop.setChecked(False) self.playSlidesLoop.setChecked(False)
self.onToggleLoop() self.onToggleLoop()
def setAudioItemsVisibility(self, visible):
self.audioPauseItem.setVisible(visible)
def onAudioPauseClicked(self, checked):
if not self.audioPauseItem.isVisible():
return
if checked:
self.display.audioPlayer.pause()
else:
self.display.audioPlayer.play()
def timerEvent(self, event): def timerEvent(self, event):
""" """
If the timer event is for this window select next slide If the timer event is for this window select next slide