further progress

This commit is contained in:
rimach crichter@web.de 2011-05-17 21:50:00 +02:00
parent 2ccf6a67fa
commit aebc0e240e
8 changed files with 242 additions and 128 deletions

View File

@ -101,7 +101,7 @@ sup {
var current_video = '1'; var current_video = '1';
var transition = %s; var transition = %s;
function show_video(state, path, volume, loop){ function show_video(state, path, volume, loop, seekVal){
// Note, the preferred method for looping would be to use the // Note, the preferred method for looping would be to use the
// video tag loop attribute. // video tag loop attribute.
// But QtWebKit doesn't support this. Neither does it support the // But QtWebKit doesn't support this. Neither does it support the
@ -183,7 +183,7 @@ sup {
case 'currentTime': case 'currentTime':
return vid.currentTime; return vid.currentTime;
case 'seek': case 'seek':
vid.currentTime = path; vid.currentTime = seekVal;
break; break;
} }
} }
@ -356,11 +356,21 @@ sup {
// PercentLoaded() // PercentLoaded()
// GotoFrame() // GotoFrame()
break; break;
case 'stop': case 'pause':
flashMovie.StopPlay(); flashMovie.StopPlay();
text.innerHTML = '';
text.style.visibility = 'hidden'; text.style.visibility = 'hidden';
break; break;
case 'stop':
flashMovie.StopPlay();
// flashMovie.GotoFrame(0);
text.style.visibility = 'hidden';
break;
case 'close':
flashMovie.StopPlay();
text.style.visibility = 'hidden';
break;
text.innerHTML = '';
break;
} }
} }

View File

@ -104,9 +104,6 @@ class MainDisplay(DisplayWidget):
QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay) QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay) QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlp_phonon_creation'),
self.createMediaObject)
def retranslateUi(self): def retranslateUi(self):
""" """
@ -120,8 +117,6 @@ class MainDisplay(DisplayWidget):
""" """
log.debug(u'Start setup for monitor %s (live = %s)' % log.debug(u'Start setup for monitor %s (live = %s)' %
(self.screens.monitor_number, self.isLive)) (self.screens.monitor_number, self.isLive))
self.usePhonon = QtCore.QSettings().value(
u'media/use phonon', QtCore.QVariant(True)).toBool()
self.phononActive = False self.phononActive = False
self.screen = self.screens.current self.screen = self.screens.current
self.setVisible(False) self.setVisible(False)
@ -187,24 +182,6 @@ class MainDisplay(DisplayWidget):
log.debug( log.debug(
u'Finished setup for monitor %s' % self.screens.monitor_number) u'Finished setup for monitor %s' % self.screens.monitor_number)
def createMediaObject(self):
self.firstTime = False
log.debug(u'Creating Phonon objects - Start for %s', self.isLive)
self.mediaObject = Phonon.MediaObject(self)
self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject)
Phonon.createPath(self.mediaObject, self.videoWidget)
Phonon.createPath(self.mediaObject, self.audio)
QtCore.QObject.connect(self.mediaObject,
QtCore.SIGNAL(u'stateChanged(Phonon::State, Phonon::State)'),
self.videoState)
QtCore.QObject.connect(self.mediaObject,
QtCore.SIGNAL(u'finished()'),
self.videoFinished)
QtCore.QObject.connect(self.mediaObject,
QtCore.SIGNAL(u'tick(qint64)'),
self.videoTick)
log.debug(u'Creating Phonon objects - Finished for %s', self.isLive)
def text(self, slide): def text(self, slide):
""" """
Add the slide text from slideController Add the slide text from slideController
@ -239,10 +216,7 @@ class MainDisplay(DisplayWidget):
u'top' if shrink else u'') u'top' if shrink else u'')
height = self.frame.evaluateJavaScript(js) height = self.frame.evaluateJavaScript(js)
if shrink: if shrink:
if self.phononActive: shrinkItem = self
shrinkItem = self.webView
else:
shrinkItem = self
if text: if text:
alert_height = int(height.toString()) alert_height = int(height.toString())
shrinkItem.resize(self.width(), alert_height) shrinkItem.resize(self.width(), alert_height)
@ -425,7 +399,6 @@ class MainDisplay(DisplayWidget):
Store the images so they can be replaced when required Store the images so they can be replaced when required
""" """
log.debug(u'hideDisplay mode = %d', mode) log.debug(u'hideDisplay mode = %d', mode)
Receiver.send_message(u'media_pause', self)
if mode == HideMode.Screen: if mode == HideMode.Screen:
self.frame.evaluateJavaScript(u'show_blank("desktop");') self.frame.evaluateJavaScript(u'show_blank("desktop");')
self.setVisible(False) self.setVisible(False)
@ -436,7 +409,6 @@ class MainDisplay(DisplayWidget):
if mode != HideMode.Screen: if mode != HideMode.Screen:
if self.isHidden(): if self.isHidden():
self.setVisible(True) self.setVisible(True)
if self.phononActive:
self.webView.setVisible(True) self.webView.setVisible(True)
self.hideMode = mode self.hideMode = mode
@ -448,11 +420,9 @@ class MainDisplay(DisplayWidget):
""" """
log.debug(u'showDisplay') log.debug(u'showDisplay')
self.frame.evaluateJavaScript('show_blank("show");') self.frame.evaluateJavaScript('show_blank("show");')
print "showDisplay", self.isHidden()
if self.isHidden(): if self.isHidden():
self.setVisible(True) self.setVisible(True)
if self.phononActive:
self.webView.setVisible(False)
Receiver.send_message(u'media_play', self)
self.hideMode = None self.hideMode = None
# Trigger actions when display is active again # Trigger actions when display is active again
if self.isLive: if self.isLive:

View File

@ -303,9 +303,9 @@ class SlideController(QtGui.QWidget):
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
if self.isLive: if self.isLive:
QtCore.QObject.connect(self.seekSlider, QtCore.QObject.connect(self.seekSlider,
QtCore.SIGNAL(u'sliderReleased()'), self.mediaSeek) QtCore.SIGNAL(u'sliderMoved(int)'), self.mediaSeek)
QtCore.QObject.connect(self.volumeSlider, QtCore.QObject.connect(self.volumeSlider,
QtCore.SIGNAL(u'sliderReleased()'), self.mediaVolume) QtCore.SIGNAL(u'sliderMoved(int)'), self.mediaVolume)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_active'), self.updatePreview) QtCore.SIGNAL(u'maindisplay_active'), self.updatePreview)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
@ -854,6 +854,7 @@ class SlideController(QtGui.QWidget):
""" """
Tell the plugin to hide the display screen. Tell the plugin to hide the display screen.
""" """
print "hidePlugin", hide
log.debug(u'hidePlugin %s ', hide) log.debug(u'hidePlugin %s ', hide)
if self.serviceItem is not None: if self.serviceItem is not None:
if hide: if hide:

View File

@ -51,6 +51,10 @@ class MediaController(object):
def __init__(self, parent): def __init__(self, parent):
self.parent = parent self.parent = parent
self.state = MediaState.Off self.state = MediaState.Off
self.hasOwnWidget = False
def setup(self, display):
pass
def load(self, display, path, volume): def load(self, display, path, volume):
pass pass
@ -76,9 +80,16 @@ class MediaController(object):
def reset(self, display): def reset(self, display):
pass pass
def set_visible(self, display, status):
pass
def update_ui(self, controller, display): def update_ui(self, controller, display):
pass pass
@staticmethod
def is_available():
pass
def get_supported_file_types(self): def get_supported_file_types(self):
pass pass

View File

@ -27,10 +27,12 @@
import logging import logging
import sys, types import sys, os
from PyQt4 import QtCore from PyQt4 import QtCore
import vlc #try:
# import vlc
#except:
# pass
from PyQt4 import QtCore, QtGui, QtWebKit from PyQt4 import QtCore, QtGui, QtWebKit
from PyQt4.phonon import Phonon from PyQt4.phonon import Phonon
@ -56,15 +58,15 @@ class MediaManager(object):
def __init__(self, parent): def __init__(self, parent):
self.parent = parent self.parent = parent
self.availableBackends = [ self.backend = {}
MediaBackends.Webkit,
MediaBackends.Phonon,
MediaBackends.Vlc]
self.curDisplayMediaController = {} self.curDisplayMediaController = {}
#one controller for every backend #one controller for every backend
self.displayWebkitController = WebkitController(self) if WebkitController.is_available():
self.displayPhononController = PhononController(self) self.backend['webkit'] = WebkitController(self)
self.displayVlcController = VlcController(self) if PhononController.is_available():
self.backend['phonon'] = PhononController(self)
if VlcController.is_available():
self.backend['vlc'] = VlcController(self)
#Timer for video state #Timer for video state
self.Timer = QtCore.QTimer() self.Timer = QtCore.QTimer()
self.Timer.setInterval(200) self.Timer.setInterval(200)
@ -87,6 +89,12 @@ class MediaManager(object):
QtCore.SIGNAL(u'media_volume'), self.video_volume) QtCore.SIGNAL(u'media_volume'), self.video_volume)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'media_reset'), self.video_reset) QtCore.SIGNAL(u'media_reset'), self.video_reset)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'media_hide'), self.video_hide)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'media_blank'), self.video_blank)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'media_unblank'), self.video_unblank)
def video_state(self): def video_state(self):
""" """
@ -111,48 +119,26 @@ class MediaManager(object):
def setup_display(self, display): def setup_display(self, display):
# check controller relevant displays # check controller relevant displays
if display == self.parent.previewController.previewDisplay or \ if display == self.parent.previewController.previewDisplay or \
display == self.parent.liveController.previewDisplay or \
display == self.parent.liveController.display: display == self.parent.liveController.display:
self.setup_vlc_controller(display) for backend_typ in self.backend.values():
self.setup_phonon_controller(display) backend_typ.setup(display)
self.setup_webkit_controller(display)
def setup_webkit_controller(self, display):
if display == self.parent.previewController.previewDisplay or \
display == self.parent.liveController.previewDisplay:
display.webView.resize(display.size())
display.webView.raise_()
def setup_phonon_controller(self, display):
display.phononWidget = Phonon.VideoWidget(display)
display.phononWidget.setVisible(False)
display.phononWidget.resize(display.size())
display.mediaObject = Phonon.MediaObject(display)
display.audio = Phonon.AudioOutput(Phonon.VideoCategory, display.mediaObject)
Phonon.createPath(display.mediaObject, display.phononWidget)
Phonon.createPath(display.mediaObject, display.audio)
display.phononWidget.raise_()
def setup_vlc_controller(self, display):
display.vlcWidget = QtGui.QFrame(display)
# creating a basic vlc instance
display.vlcInstance = vlc.Instance()
# creating an empty vlc media player
display.vlcMediaPlayer = display.vlcInstance.media_player_new()
display.vlcWidget.resize(display.size())
display.vlcWidget.raise_()
def resize(self, controller): def resize(self, controller):
for display in self.curDisplayMediaController.keys(): """
display.resize(controller.slidePreview.size()) after Mainwindow changes or Splitter moved all related media
self.curDisplayMediaController[display].resize(display, controller) widgets have to be resized
"""
pass
#has to be clarified
#for display in self.curDisplayMediaController.keys():
# self.curDisplayMediaController[display].resize(display, controller)
def video(self, msg): def video(self, msg):
""" """
Loads and starts a video to run with the option of sound Loads and starts a video to run with the option of sound
""" """
controller = msg[0] controller = msg[0]
videoPath = msg[1] videoPath = os.path.abspath(msg[1])
volume = msg[2] volume = msg[2]
isBackground = msg[3] isBackground = msg[3]
log.debug(u'video') log.debug(u'video')
@ -163,14 +149,13 @@ class MediaManager(object):
# We are running a background theme # We are running a background theme
controller.display.override[u'theme'] = u'' controller.display.override[u'theme'] = u''
controller.display.override[u'video'] = True controller.display.override[u'video'] = True
display = controller.previewDisplay # display = controller.previewDisplay
self.check_file_type(display, videoPath, False) # self.check_file_type(display, videoPath, False)
self.curDisplayMediaController[display].load(display, videoPath, volume) # self.curDisplayMediaController[display].load(display, videoPath, volume)
display = controller.display display = controller.display
self.check_file_type(display, videoPath, False) self.check_file_type(display, videoPath, False)
self.curDisplayMediaController[display].load(display, videoPath, volume) self.curDisplayMediaController[display].load(display, videoPath, volume)
controller.display.webLoaded = True controller.display.webLoaded = True
Receiver.send_message(u'maindisplay_active')
else: else:
display = controller.previewDisplay display = controller.previewDisplay
self.check_file_type(display, videoPath, False) self.check_file_type(display, videoPath, False)
@ -180,37 +165,24 @@ class MediaManager(object):
#now start playing #now start playing
for display in self.curDisplayMediaController.keys(): for display in self.curDisplayMediaController.keys():
if display.parent == controller: if display.parent == controller:
self.curDisplayMediaController[display].pause(display) self.curDisplayMediaController[display].play(display)
def check_file_type(self, display, videoPath, isBackground): def check_file_type(self, display, videoPath, isBackground):
""" """
Used to choose the right media backend type Used to choose the right media backend type
from the prioritized backend list from the prioritized backend list
""" """
usePhonon = QtCore.QSettings().value( if videoPath.endswith(u'.swf') or isBackground:
u'media/use phonon', QtCore.QVariant(True)).toBool() self.curDisplayMediaController[display] = self.backend['webkit']
useVlc = True
if videoPath.endswith(u'.swf'):
useVlc = False
usePhonon = False
elif videoPath.endswith(u'.wmv'): elif videoPath.endswith(u'.wmv'):
useVlc = False self.curDisplayMediaController[display] = self.backend['phonon']
usePhonon = True
if useVlc:
self.curDisplayMediaController[display] = self.displayVlcController
display.phononWidget.setVisible(False)
display.vlcWidget.setVisible(True)
display.webView.setVisible(False)
elif usePhonon and not isBackground:
self.curDisplayMediaController[display] = self.displayPhononController
display.phononWidget.setVisible(True)
display.vlcWidget.setVisible(False)
display.webView.setVisible(False)
else: else:
self.curDisplayMediaController[display] = self.displayWebkitController self.curDisplayMediaController[display] = self.backend['vlc']
display.phononWidget.setVisible(False) for key in self.backend.keys():
display.vlcWidget.setVisible(False) if self.backend[key] == self.curDisplayMediaController[display]:
display.webView.setVisible(True) self.backend[key].set_visible(display, True)
# else:
# self.backend[key].set_visible(display, False)
if len(self.curDisplayMediaController) > 0: if len(self.curDisplayMediaController) > 0:
if not self.Timer.isActive(): if not self.Timer.isActive():
self.Timer.start() self.Timer.start()
@ -221,13 +193,12 @@ class MediaManager(object):
""" """
log.debug(u'video_play') log.debug(u'video_play')
for display in self.curDisplayMediaController.keys(): for display in self.curDisplayMediaController.keys():
print display, display.parent, controller
if display.parent == controller: if display.parent == controller:
self.curDisplayMediaController[display].play(display) self.curDisplayMediaController[display].play(display)
# show screen # show screen
if not self.Timer.isActive(): if not self.Timer.isActive():
self.Timer.start() self.Timer.start()
display.setVisible(True) #display.setVisible(True)
def video_pause(self, controller): def video_pause(self, controller):
""" """
@ -246,6 +217,7 @@ class MediaManager(object):
for display in self.curDisplayMediaController.keys(): for display in self.curDisplayMediaController.keys():
if display.parent == controller: if display.parent == controller:
self.curDisplayMediaController[display].stop(display) self.curDisplayMediaController[display].stop(display)
self.curDisplayMediaController[display].set_visible(display, False)
def video_volume(self, msg): def video_volume(self, msg):
""" """
@ -286,6 +258,7 @@ class MediaManager(object):
if display.parent == controller: if display.parent == controller:
self.curDisplayMediaController[display].seek(display, seekVal) self.curDisplayMediaController[display].seek(display, seekVal)
def video_reset(self, controller): def video_reset(self, controller):
""" """
Responds to the request to reset a loaded video Responds to the request to reset a loaded video
@ -295,5 +268,48 @@ class MediaManager(object):
if display.parent == controller: if display.parent == controller:
self.curDisplayMediaController[display].reset(display) self.curDisplayMediaController[display].reset(display)
del self.curDisplayMediaController[display] del self.curDisplayMediaController[display]
if controller.isLive: # if controller.isLive:
Receiver.send_message(u'maindisplay_active') #Receiver.send_message(u'maindisplay_active')
def video_hide(self, msg):
"""
Hide the related video Widget
"""
print "hide"
isLive = msg[1]
if isLive:
controller = self.parent.liveController
for display in self.curDisplayMediaController.keys():
if display.parent == controller:
if self.curDisplayMediaController[display].state == MediaState.Playing:
self.curDisplayMediaController[display].pause(display)
self.curDisplayMediaController[display].set_visible(display, False)
def video_blank(self, msg):
"""
Blank the related video Widget
"""
print "blank"
isLive = msg[1]
if isLive:
controller = self.parent.liveController
for display in self.curDisplayMediaController.keys():
if display.parent == controller:
if self.curDisplayMediaController[display].state == MediaState.Playing:
self.curDisplayMediaController[display].pause(display)
self.curDisplayMediaController[display].set_visible(display, False)
def video_unblank(self, msg):
"""
Unblank the related video Widget
"""
print "unblank"
Receiver.send_message(u'maindisplay_show')
isLive = msg[1]
if isLive:
controller = self.parent.liveController
for display in self.curDisplayMediaController.keys():
if display.parent == controller:
if self.curDisplayMediaController[display].state == MediaState.Paused:
self.curDisplayMediaController[display].play(display)
self.curDisplayMediaController[display].set_visible(display, True)

View File

@ -25,6 +25,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from PyQt4 import QtCore, QtGui
from PyQt4.phonon import Phonon from PyQt4.phonon import Phonon
from openlp.plugins.media.lib import MediaController, MediaState from openlp.plugins.media.lib import MediaController, MediaState
@ -53,10 +54,43 @@ class PhononController(MediaController):
u'video/x-wmv': [u'.wmv'], u'video/x-wmv': [u'.wmv'],
u'video/x-ms-wmv': [u'.wmv']} u'video/x-ms-wmv': [u'.wmv']}
def setup(self, display):
display.phononWidget = Phonon.VideoWidget(display)
display.phononWidget.setVisible(False)
display.phononWidget.resize(display.size())
display.mediaObject = Phonon.MediaObject(display)
display.audio = Phonon.AudioOutput(Phonon.VideoCategory, display.mediaObject)
Phonon.createPath(display.mediaObject, display.phononWidget)
Phonon.createPath(display.mediaObject, display.audio)
display.phononWidget.raise_()
display.phononWidget.hide()
self.hasOwnWidget = True
@staticmethod
def is_available():
# usePhonon = QtCore.QSettings().value(
# u'media/use phonon', QtCore.QVariant(True)).toBool()
return True
def get_supported_file_types(self):
self.supported_file_types = ['avi']
self.additional_extensions = {
u'audio/ac3': [u'.ac3'],
u'audio/flac': [u'.flac'],
u'audio/x-m4a': [u'.m4a'],
u'audio/midi': [u'.mid', u'.midi'],
u'audio/x-mp3': [u'.mp3'],
u'audio/mpeg': [u'.mp3', u'.mp2', u'.mpga', u'.mpega', u'.m4a'],
u'audio/qcelp': [u'.qcp'],
u'audio/x-wma': [u'.wma'],
u'audio/x-ms-wma': [u'.wma'],
u'video/x-flv': [u'.flv'],
u'video/x-matroska': [u'.mpv', u'.mkv'],
u'video/x-wmv': [u'.wmv'],
u'video/x-ms-wmv': [u'.wmv']}
def load(self, display, path, volume): def load(self, display, path, volume):
print "load vid in Phonon Controller" print "load vid in Phonon Controller"
display.phononActive = True
display.mediaObject.stop() display.mediaObject.stop()
display.mediaObject.clearQueue() display.mediaObject.clearQueue()
display.mediaObject.setCurrentSource(Phonon.MediaSource(path)) display.mediaObject.setCurrentSource(Phonon.MediaSource(path))
@ -65,10 +99,11 @@ class PhononController(MediaController):
vol = float(volume) / float(10) vol = float(volume) / float(10)
display.audio.setVolume(vol) display.audio.setVolume(vol)
def resize(self, display): def resize(self, display, controller):
display.phononWidget.resize(display.size()) display.phononWidget.resize(display.size())
def play(self, display): def play(self, display):
self.set_visible(display, True)
vol = float(display.parent.volume) / float(10) vol = float(display.parent.volume) / float(10)
display.audio.setVolume(vol) display.audio.setVolume(vol)
display.mediaObject.play() display.mediaObject.play()
@ -92,7 +127,11 @@ class PhononController(MediaController):
display.mediaObject.stop() display.mediaObject.stop()
display.mediaObject.clearQueue() display.mediaObject.clearQueue()
display.phononWidget.setVisible(False) display.phononWidget.setVisible(False)
#display.webView.setVisible(True) self.state = MediaState.Off
def set_visible(self, display, status):
if self.hasOwnWidget:
display.phononWidget.setVisible(status)
def update_ui(self, controller, display): def update_ui(self, controller, display):
controller.seekSlider.setMaximum(display.mediaObject.totalTime()) controller.seekSlider.setMaximum(display.mediaObject.totalTime())

View File

@ -26,7 +26,11 @@
############################################################################### ###############################################################################
import sys import sys
try:
import vlc
except:
pass
from PyQt4 import QtCore, QtGui
from openlp.plugins.media.lib import MediaController, MediaState from openlp.plugins.media.lib import MediaController, MediaState
class VlcController(MediaController): class VlcController(MediaController):
@ -37,6 +41,28 @@ class VlcController(MediaController):
def __init__(self, parent): def __init__(self, parent):
MediaController.__init__(self, parent) MediaController.__init__(self, parent)
self.parent = parent self.parent = parent
def setup(self, display):
display.vlcWidget = QtGui.QFrame(display)
# creating a basic vlc instance
display.vlcInstance = vlc.Instance()
display.vlcInstance.set_log_verbosity(2)
# creating an empty vlc media player
display.vlcMediaPlayer = display.vlcInstance.media_player_new()
display.vlcWidget.resize(display.size())
display.vlcWidget.raise_()
display.vlcWidget.hide()
self.hasOwnWidget = True
@staticmethod
def is_available():
try:
import vlc
return True
except:
return False
def get_supported_file_types(self):
self.supported_file_types = ['avi'] self.supported_file_types = ['avi']
self.additional_extensions = { self.additional_extensions = {
u'audio/ac3': [u'.ac3'], u'audio/ac3': [u'.ac3'],
@ -58,7 +84,8 @@ class VlcController(MediaController):
vol = float(volume) / float(10) vol = float(volume) / float(10)
# create the media # create the media
display.vlcMedia = display.vlcInstance.media_new(unicode(path)) #display.vlcMedia = display.vlcInstance.media_new(unicode(path))
display.vlcMedia = display.vlcInstance.media_new_path(unicode(path))
# put the media in the media player # put the media in the media player
display.vlcMediaPlayer.set_media(display.vlcMedia) display.vlcMediaPlayer.set_media(display.vlcMedia)
@ -77,10 +104,11 @@ class VlcController(MediaController):
elif sys.platform == "darwin": # for MacOS elif sys.platform == "darwin": # for MacOS
display.vlcMediaPlayer.set_agl(int(display.vlcWidget.winId())) display.vlcMediaPlayer.set_agl(int(display.vlcWidget.winId()))
def resize(self, display): def resize(self, display, controller):
display.vlcWidget.resize(display.size()) display.vlcWidget.resize(display.size())
def play(self, display): def play(self, display):
self.set_visible(display, True)
display.vlcMediaPlayer.play() display.vlcMediaPlayer.play()
self.state = MediaState.Playing self.state = MediaState.Playing
@ -100,8 +128,14 @@ class VlcController(MediaController):
display.vlcMediaPlayer.set_position(seekVal/1000.0) display.vlcMediaPlayer.set_position(seekVal/1000.0)
def reset(self, display): def reset(self, display):
display.vlcMediaPlayer.stop()
display.vlcWidget.setVisible(False) display.vlcWidget.setVisible(False)
#display.webView.setVisible(True) self.state = MediaState.Off
def set_visible(self, display, status):
print display.vlcWidget.isVisible(), status
if self.hasOwnWidget:
display.vlcWidget.setVisible(status)
def update_ui(self, controller, display): def update_ui(self, controller, display):
controller.seekSlider.setMaximum(1000) controller.seekSlider.setMaximum(1000)

View File

@ -25,6 +25,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from PyQt4 import QtCore, QtGui, QtWebKit
from openlp.plugins.media.lib import MediaController, MediaState from openlp.plugins.media.lib import MediaController, MediaState
class WebkitController(MediaController): class WebkitController(MediaController):
@ -40,12 +41,38 @@ class WebkitController(MediaController):
self.additional_extensions = { self.additional_extensions = {
u'video/shockwave': [u'.swf']} u'video/shockwave': [u'.swf']}
def setup(self, display):
# if display == self.parent.previewController.previewDisplay or \
# display == self.parent.liveController.previewDisplay:
# display.webView.resize(display.size())
display.webView.raise_()
self.hasOwnWidget = False
@staticmethod
def is_available():
return True
def get_supported_file_types(self):
self.supported_file_types = ['avi']
self.additional_extensions = {
u'audio/ac3': [u'.ac3'],
u'audio/flac': [u'.flac'],
u'audio/x-m4a': [u'.m4a'],
u'audio/midi': [u'.mid', u'.midi'],
u'audio/x-mp3': [u'.mp3'],
u'audio/mpeg': [u'.mp3', u'.mp2', u'.mpga', u'.mpega', u'.m4a'],
u'audio/qcelp': [u'.qcp'],
u'audio/x-wma': [u'.wma'],
u'audio/x-ms-wma': [u'.wma'],
u'video/x-flv': [u'.flv'],
u'video/x-matroska': [u'.mpv', u'.mkv'],
u'video/x-wmv': [u'.wmv'],
u'video/x-ms-wmv': [u'.wmv']}
def load(self, display, path, volume): def load(self, display, path, volume):
print "load vid in Webkit Controller" print "load vid in Webkit Controller"
vol = float(volume) / float(10) vol = float(volume) / float(10)
display.webView.setVisible(True) display.webView.setVisible(True)
display.phononWidget.setVisible(False)
display.vlcWidget.setVisible(False)
if path.endswith(u'.swf'): if path.endswith(u'.swf'):
js = u'show_flash("load","%s");' % \ js = u'show_flash("load","%s");' % \
(path.replace(u'\\', u'\\\\')) (path.replace(u'\\', u'\\\\'))
@ -58,10 +85,10 @@ class WebkitController(MediaController):
def resize(self, display, controller): def resize(self, display, controller):
if display == controller.previewDisplay: if display == controller.previewDisplay:
print display.size()
display.webView.resize(display.size()) display.webView.resize(display.size())
def play(self, display): def play(self, display):
self.set_visible(display, True)
if self.isFlash: if self.isFlash:
display.frame.evaluateJavaScript(u'show_flash("play","");') display.frame.evaluateJavaScript(u'show_flash("play","");')
else: else:
@ -89,22 +116,28 @@ class WebkitController(MediaController):
def seek(self, display, seekVal): def seek(self, display, seekVal):
if not self.isFlash: if not self.isFlash:
display.frame.evaluateJavaScript(u'show_video("seek", "%f");' % (float(seekVal)/1000)) seek = float(seekVal)/1000
display.frame.evaluateJavaScript(u'show_video("seek", null, null, null, "%f");' % (seek))
def reset(self, display): def reset(self, display):
if self.isFlash: if self.isFlash:
display.frame.evaluateJavaScript(u'show_flash("close","");') display.frame.evaluateJavaScript(u'show_flash("close","");')
else: else:
display.frame.evaluateJavaScript(u'show_video("close");') display.frame.evaluateJavaScript(u'show_video("close");')
self.state = MediaState.Off
def set_visible(self, display, status):
if self.hasOwnWidget:
display.webView.setVisible(status)
def update_ui(self, controller, display): def update_ui(self, controller, display):
return
if not self.isFlash: if not self.isFlash:
currentTime = display.frame.evaluateJavaScript(u'show_video("currentTime");')
length = display.frame.evaluateJavaScript(u'show_video("length");') length = display.frame.evaluateJavaScript(u'show_video("length");')
controller.seekSlider.setMaximum(length.toFloat()[0]*1000) if int(currentTime.toFloat()[0]*1000) > 0:
if not controller.seekSlider.isSliderDown(): controller.seekSlider.setMaximum(int(length.toFloat()[0]*1000))
currentTime = display.frame.evaluateJavaScript(u'show_video("currentTime");') if not controller.seekSlider.isSliderDown():
controller.seekSlider.setSliderPosition(currentTime.toFloat()[0]*1000) controller.seekSlider.setSliderPosition(int(currentTime.toFloat()[0]*1000))
def get_supported_file_types(self): def get_supported_file_types(self):
pass pass