Add Volume slider and document APIs

This commit is contained in:
Tim Bentley 2010-08-02 06:16:07 +01:00
parent c10fc012a3
commit 82aa9c333a
2 changed files with 48 additions and 0 deletions

View File

@ -197,23 +197,40 @@ class MainDisplay(DisplayWidget):
u'src', unicode(u'data:image/png;base64,%s' % image_to_byte(image)))
def resetImage(self):
"""
Reset the backgound image to the service item image.
Used after Image plugin has changed the background
"""
log.debug(u'resetImage')
self.frame.findFirstElement(u'img').setAttribute(
u'src', unicode(u'data:image/png;base64,%s' % image_to_byte(self.serviceItem.bg_frame)))
def resetVideo(self):
"""
Reset the backgound image to the service item image.
Used after Video plugin has changed the background
"""
log.debug(u'resetVideo')
self.frame.findFirstElement('img').setAttribute(u'src',u'display: none;' )
def videoPlay(self):
"""
Responds to the request to play a loaded video
"""
log.debug(u'videoPlay')
self.frame.evaluateJavaScript("document.getElementById('video').play()")
def videoPause(self):
"""
Responds to the request to pause a loaded video
"""
log.debug(u'videoPause')
self.frame.evaluateJavaScript("document.getElementById('video').pause()")
def videoStop(self):
"""
Responds to the request to stop a loaded video
"""
log.debug(u'videoStop')
self.frame.evaluateJavaScript("document.getElementById('video').pause()")
self.frame.evaluateJavaScript(
@ -222,10 +239,16 @@ class MainDisplay(DisplayWidget):
"document.getElementById('image').style.visibility = 'visible'")
def videoVolume(self, amount):
"""
Changes the volume of a running video
"""
log.debug(u'videoVolume')
self.frame.evaluateJavaScript("document.getElementById('video').volume = 0")
def video(self, videoPath, noSound=False):
"""
Loads and starts a video to run with the option of sound
"""
log.debug(u'video')
self.frame.findFirstElement('video').setAttribute('src', videoPath)
self.frame.evaluateJavaScript(
@ -243,6 +266,9 @@ class MainDisplay(DisplayWidget):
self.loaded = True
def preview(self):
"""
Generates a preview of the image displayed.
"""
log.debug(u'preview')
# Wait for the webview to update before geting the preview.
# Important otherwise first preview will miss the background !

View File

@ -99,6 +99,7 @@ class SlideController(QtGui.QWidget):
self.songEditList = [
u'Edit Song',
]
self.volume = 10
self.timer_id = 0
self.songEdit = False
self.selectedRow = 0
@ -261,6 +262,15 @@ class SlideController(QtGui.QWidget):
self.volumeSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
self.volumeSlider.setObjectName(u'volumeSlider')
self.Mediabar.addToolbarWidget(u'Audio Volume', self.volumeSlider)
else:
self.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
self.volumeSlider.setTickInterval(1)
self.volumeSlider.setTickPosition(QtGui.QSlider.TicksAbove)
self.volumeSlider.setMinimum(0)
self.volumeSlider.setMaximum(10)
self.volumeSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
self.volumeSlider.setObjectName(u'volumeSlider')
self.Mediabar.addToolbarWidget(u'Audio Volume', self.volumeSlider)
self.ControllerLayout.addWidget(self.Mediabar)
# Build the Song Toolbar
if isLive:
@ -379,6 +389,9 @@ class SlideController(QtGui.QWidget):
QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'%s_slide_cache' % self.typePrefix), self.slideCache)
if self.isLive:
QtCore.QObject.connect(self.volumeSlider,
QtCore.SIGNAL(u'sliderReleased()'), self.mediaVolume)
def screenSizeChanged(self):
"""
@ -925,6 +938,7 @@ class SlideController(QtGui.QWidget):
if self.isLive:
file = os.path.join(item.get_frame_path(), item.get_frame_title())
self.display.video(file)
self.volumeSlider.setValue(self.volume)
else:
self.mediaObject.stop()
self.mediaObject.clearQueue()
@ -934,6 +948,14 @@ class SlideController(QtGui.QWidget):
self.seekSlider.show()
self.onMediaPlay()
def mediaVolume(self):
"""
Respond to the release of Volume Slider
"""
log.debug(u'SlideController mediaVolume')
self.volume = self.volumeSlider.value()
self.display.videoVolume(self.volume)
def onMediaPause(self):
"""
Respond to the Pause from the media Toolbar