forked from openlp/openlp
further progress
This commit is contained in:
parent
2ccf6a67fa
commit
aebc0e240e
@ -101,7 +101,7 @@ sup {
|
||||
var current_video = '1';
|
||||
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
|
||||
// video tag loop attribute.
|
||||
// But QtWebKit doesn't support this. Neither does it support the
|
||||
@ -183,7 +183,7 @@ sup {
|
||||
case 'currentTime':
|
||||
return vid.currentTime;
|
||||
case 'seek':
|
||||
vid.currentTime = path;
|
||||
vid.currentTime = seekVal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -356,11 +356,21 @@ sup {
|
||||
// PercentLoaded()
|
||||
// GotoFrame()
|
||||
break;
|
||||
case 'stop':
|
||||
case 'pause':
|
||||
flashMovie.StopPlay();
|
||||
text.innerHTML = '';
|
||||
text.style.visibility = 'hidden';
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,9 +104,6 @@ class MainDisplay(DisplayWidget):
|
||||
QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_phonon_creation'),
|
||||
self.createMediaObject)
|
||||
|
||||
def retranslateUi(self):
|
||||
"""
|
||||
@ -120,8 +117,6 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
log.debug(u'Start setup for monitor %s (live = %s)' %
|
||||
(self.screens.monitor_number, self.isLive))
|
||||
self.usePhonon = QtCore.QSettings().value(
|
||||
u'media/use phonon', QtCore.QVariant(True)).toBool()
|
||||
self.phononActive = False
|
||||
self.screen = self.screens.current
|
||||
self.setVisible(False)
|
||||
@ -187,24 +182,6 @@ class MainDisplay(DisplayWidget):
|
||||
log.debug(
|
||||
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):
|
||||
"""
|
||||
Add the slide text from slideController
|
||||
@ -239,10 +216,7 @@ class MainDisplay(DisplayWidget):
|
||||
u'top' if shrink else u'')
|
||||
height = self.frame.evaluateJavaScript(js)
|
||||
if shrink:
|
||||
if self.phononActive:
|
||||
shrinkItem = self.webView
|
||||
else:
|
||||
shrinkItem = self
|
||||
shrinkItem = self
|
||||
if text:
|
||||
alert_height = int(height.toString())
|
||||
shrinkItem.resize(self.width(), alert_height)
|
||||
@ -425,7 +399,6 @@ class MainDisplay(DisplayWidget):
|
||||
Store the images so they can be replaced when required
|
||||
"""
|
||||
log.debug(u'hideDisplay mode = %d', mode)
|
||||
Receiver.send_message(u'media_pause', self)
|
||||
if mode == HideMode.Screen:
|
||||
self.frame.evaluateJavaScript(u'show_blank("desktop");')
|
||||
self.setVisible(False)
|
||||
@ -436,7 +409,6 @@ class MainDisplay(DisplayWidget):
|
||||
if mode != HideMode.Screen:
|
||||
if self.isHidden():
|
||||
self.setVisible(True)
|
||||
if self.phononActive:
|
||||
self.webView.setVisible(True)
|
||||
self.hideMode = mode
|
||||
|
||||
@ -448,11 +420,9 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
log.debug(u'showDisplay')
|
||||
self.frame.evaluateJavaScript('show_blank("show");')
|
||||
print "showDisplay", self.isHidden()
|
||||
if self.isHidden():
|
||||
self.setVisible(True)
|
||||
if self.phononActive:
|
||||
self.webView.setVisible(False)
|
||||
Receiver.send_message(u'media_play', self)
|
||||
self.hideMode = None
|
||||
# Trigger actions when display is active again
|
||||
if self.isLive:
|
||||
|
@ -303,9 +303,9 @@ class SlideController(QtGui.QWidget):
|
||||
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
|
||||
if self.isLive:
|
||||
QtCore.QObject.connect(self.seekSlider,
|
||||
QtCore.SIGNAL(u'sliderReleased()'), self.mediaSeek)
|
||||
QtCore.SIGNAL(u'sliderMoved(int)'), self.mediaSeek)
|
||||
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.SIGNAL(u'maindisplay_active'), self.updatePreview)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
@ -854,6 +854,7 @@ class SlideController(QtGui.QWidget):
|
||||
"""
|
||||
Tell the plugin to hide the display screen.
|
||||
"""
|
||||
print "hidePlugin", hide
|
||||
log.debug(u'hidePlugin %s ', hide)
|
||||
if self.serviceItem is not None:
|
||||
if hide:
|
||||
|
@ -51,6 +51,10 @@ class MediaController(object):
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
self.state = MediaState.Off
|
||||
self.hasOwnWidget = False
|
||||
|
||||
def setup(self, display):
|
||||
pass
|
||||
|
||||
def load(self, display, path, volume):
|
||||
pass
|
||||
@ -76,9 +80,16 @@ class MediaController(object):
|
||||
def reset(self, display):
|
||||
pass
|
||||
|
||||
def set_visible(self, display, status):
|
||||
pass
|
||||
|
||||
def update_ui(self, controller, display):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def is_available():
|
||||
pass
|
||||
|
||||
def get_supported_file_types(self):
|
||||
pass
|
||||
|
||||
|
@ -27,10 +27,12 @@
|
||||
|
||||
import logging
|
||||
|
||||
import sys, types
|
||||
import sys, os
|
||||
from PyQt4 import QtCore
|
||||
import vlc
|
||||
|
||||
#try:
|
||||
# import vlc
|
||||
#except:
|
||||
# pass
|
||||
from PyQt4 import QtCore, QtGui, QtWebKit
|
||||
from PyQt4.phonon import Phonon
|
||||
|
||||
@ -56,15 +58,15 @@ class MediaManager(object):
|
||||
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
self.availableBackends = [
|
||||
MediaBackends.Webkit,
|
||||
MediaBackends.Phonon,
|
||||
MediaBackends.Vlc]
|
||||
self.backend = {}
|
||||
self.curDisplayMediaController = {}
|
||||
#one controller for every backend
|
||||
self.displayWebkitController = WebkitController(self)
|
||||
self.displayPhononController = PhononController(self)
|
||||
self.displayVlcController = VlcController(self)
|
||||
if WebkitController.is_available():
|
||||
self.backend['webkit'] = WebkitController(self)
|
||||
if PhononController.is_available():
|
||||
self.backend['phonon'] = PhononController(self)
|
||||
if VlcController.is_available():
|
||||
self.backend['vlc'] = VlcController(self)
|
||||
#Timer for video state
|
||||
self.Timer = QtCore.QTimer()
|
||||
self.Timer.setInterval(200)
|
||||
@ -87,6 +89,12 @@ class MediaManager(object):
|
||||
QtCore.SIGNAL(u'media_volume'), self.video_volume)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
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):
|
||||
"""
|
||||
@ -111,48 +119,26 @@ class MediaManager(object):
|
||||
def setup_display(self, display):
|
||||
# check controller relevant displays
|
||||
if display == self.parent.previewController.previewDisplay or \
|
||||
display == self.parent.liveController.previewDisplay or \
|
||||
display == self.parent.liveController.display:
|
||||
self.setup_vlc_controller(display)
|
||||
self.setup_phonon_controller(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_()
|
||||
for backend_typ in self.backend.values():
|
||||
backend_typ.setup(display)
|
||||
|
||||
def resize(self, controller):
|
||||
for display in self.curDisplayMediaController.keys():
|
||||
display.resize(controller.slidePreview.size())
|
||||
self.curDisplayMediaController[display].resize(display, controller)
|
||||
"""
|
||||
after Mainwindow changes or Splitter moved all related media
|
||||
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):
|
||||
"""
|
||||
Loads and starts a video to run with the option of sound
|
||||
"""
|
||||
controller = msg[0]
|
||||
videoPath = msg[1]
|
||||
videoPath = os.path.abspath(msg[1])
|
||||
volume = msg[2]
|
||||
isBackground = msg[3]
|
||||
log.debug(u'video')
|
||||
@ -163,14 +149,13 @@ class MediaManager(object):
|
||||
# We are running a background theme
|
||||
controller.display.override[u'theme'] = u''
|
||||
controller.display.override[u'video'] = True
|
||||
display = controller.previewDisplay
|
||||
self.check_file_type(display, videoPath, False)
|
||||
self.curDisplayMediaController[display].load(display, videoPath, volume)
|
||||
# display = controller.previewDisplay
|
||||
# self.check_file_type(display, videoPath, False)
|
||||
# self.curDisplayMediaController[display].load(display, videoPath, volume)
|
||||
display = controller.display
|
||||
self.check_file_type(display, videoPath, False)
|
||||
self.curDisplayMediaController[display].load(display, videoPath, volume)
|
||||
controller.display.webLoaded = True
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
else:
|
||||
display = controller.previewDisplay
|
||||
self.check_file_type(display, videoPath, False)
|
||||
@ -180,37 +165,24 @@ class MediaManager(object):
|
||||
#now start playing
|
||||
for display in self.curDisplayMediaController.keys():
|
||||
if display.parent == controller:
|
||||
self.curDisplayMediaController[display].pause(display)
|
||||
self.curDisplayMediaController[display].play(display)
|
||||
|
||||
def check_file_type(self, display, videoPath, isBackground):
|
||||
"""
|
||||
Used to choose the right media backend type
|
||||
from the prioritized backend list
|
||||
"""
|
||||
usePhonon = QtCore.QSettings().value(
|
||||
u'media/use phonon', QtCore.QVariant(True)).toBool()
|
||||
useVlc = True
|
||||
if videoPath.endswith(u'.swf'):
|
||||
useVlc = False
|
||||
usePhonon = False
|
||||
if videoPath.endswith(u'.swf') or isBackground:
|
||||
self.curDisplayMediaController[display] = self.backend['webkit']
|
||||
elif videoPath.endswith(u'.wmv'):
|
||||
useVlc = False
|
||||
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)
|
||||
self.curDisplayMediaController[display] = self.backend['phonon']
|
||||
else:
|
||||
self.curDisplayMediaController[display] = self.displayWebkitController
|
||||
display.phononWidget.setVisible(False)
|
||||
display.vlcWidget.setVisible(False)
|
||||
display.webView.setVisible(True)
|
||||
self.curDisplayMediaController[display] = self.backend['vlc']
|
||||
for key in self.backend.keys():
|
||||
if self.backend[key] == self.curDisplayMediaController[display]:
|
||||
self.backend[key].set_visible(display, True)
|
||||
# else:
|
||||
# self.backend[key].set_visible(display, False)
|
||||
if len(self.curDisplayMediaController) > 0:
|
||||
if not self.Timer.isActive():
|
||||
self.Timer.start()
|
||||
@ -221,13 +193,12 @@ class MediaManager(object):
|
||||
"""
|
||||
log.debug(u'video_play')
|
||||
for display in self.curDisplayMediaController.keys():
|
||||
print display, display.parent, controller
|
||||
if display.parent == controller:
|
||||
self.curDisplayMediaController[display].play(display)
|
||||
# show screen
|
||||
if not self.Timer.isActive():
|
||||
self.Timer.start()
|
||||
display.setVisible(True)
|
||||
#display.setVisible(True)
|
||||
|
||||
def video_pause(self, controller):
|
||||
"""
|
||||
@ -246,6 +217,7 @@ class MediaManager(object):
|
||||
for display in self.curDisplayMediaController.keys():
|
||||
if display.parent == controller:
|
||||
self.curDisplayMediaController[display].stop(display)
|
||||
self.curDisplayMediaController[display].set_visible(display, False)
|
||||
|
||||
def video_volume(self, msg):
|
||||
"""
|
||||
@ -286,6 +258,7 @@ class MediaManager(object):
|
||||
if display.parent == controller:
|
||||
self.curDisplayMediaController[display].seek(display, seekVal)
|
||||
|
||||
|
||||
def video_reset(self, controller):
|
||||
"""
|
||||
Responds to the request to reset a loaded video
|
||||
@ -295,5 +268,48 @@ class MediaManager(object):
|
||||
if display.parent == controller:
|
||||
self.curDisplayMediaController[display].reset(display)
|
||||
del self.curDisplayMediaController[display]
|
||||
if controller.isLive:
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
# if controller.isLive:
|
||||
#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)
|
||||
|
@ -25,6 +25,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4.phonon import Phonon
|
||||
|
||||
from openlp.plugins.media.lib import MediaController, MediaState
|
||||
@ -53,10 +54,43 @@ class PhononController(MediaController):
|
||||
u'video/x-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):
|
||||
print "load vid in Phonon Controller"
|
||||
display.phononActive = True
|
||||
display.mediaObject.stop()
|
||||
display.mediaObject.clearQueue()
|
||||
display.mediaObject.setCurrentSource(Phonon.MediaSource(path))
|
||||
@ -65,10 +99,11 @@ class PhononController(MediaController):
|
||||
vol = float(volume) / float(10)
|
||||
display.audio.setVolume(vol)
|
||||
|
||||
def resize(self, display):
|
||||
def resize(self, display, controller):
|
||||
display.phononWidget.resize(display.size())
|
||||
|
||||
def play(self, display):
|
||||
self.set_visible(display, True)
|
||||
vol = float(display.parent.volume) / float(10)
|
||||
display.audio.setVolume(vol)
|
||||
display.mediaObject.play()
|
||||
@ -92,7 +127,11 @@ class PhononController(MediaController):
|
||||
display.mediaObject.stop()
|
||||
display.mediaObject.clearQueue()
|
||||
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):
|
||||
controller.seekSlider.setMaximum(display.mediaObject.totalTime())
|
||||
|
@ -26,7 +26,11 @@
|
||||
###############################################################################
|
||||
|
||||
import sys
|
||||
|
||||
try:
|
||||
import vlc
|
||||
except:
|
||||
pass
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.plugins.media.lib import MediaController, MediaState
|
||||
|
||||
class VlcController(MediaController):
|
||||
@ -37,6 +41,28 @@ class VlcController(MediaController):
|
||||
def __init__(self, parent):
|
||||
MediaController.__init__(self, 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.additional_extensions = {
|
||||
u'audio/ac3': [u'.ac3'],
|
||||
@ -58,7 +84,8 @@ class VlcController(MediaController):
|
||||
vol = float(volume) / float(10)
|
||||
|
||||
# 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
|
||||
display.vlcMediaPlayer.set_media(display.vlcMedia)
|
||||
|
||||
@ -77,10 +104,11 @@ class VlcController(MediaController):
|
||||
elif sys.platform == "darwin": # for MacOS
|
||||
display.vlcMediaPlayer.set_agl(int(display.vlcWidget.winId()))
|
||||
|
||||
def resize(self, display):
|
||||
def resize(self, display, controller):
|
||||
display.vlcWidget.resize(display.size())
|
||||
|
||||
def play(self, display):
|
||||
self.set_visible(display, True)
|
||||
display.vlcMediaPlayer.play()
|
||||
self.state = MediaState.Playing
|
||||
|
||||
@ -100,8 +128,14 @@ class VlcController(MediaController):
|
||||
display.vlcMediaPlayer.set_position(seekVal/1000.0)
|
||||
|
||||
def reset(self, display):
|
||||
display.vlcMediaPlayer.stop()
|
||||
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):
|
||||
controller.seekSlider.setMaximum(1000)
|
||||
|
@ -25,6 +25,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
from PyQt4 import QtCore, QtGui, QtWebKit
|
||||
from openlp.plugins.media.lib import MediaController, MediaState
|
||||
|
||||
class WebkitController(MediaController):
|
||||
@ -40,12 +41,38 @@ class WebkitController(MediaController):
|
||||
self.additional_extensions = {
|
||||
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):
|
||||
print "load vid in Webkit Controller"
|
||||
vol = float(volume) / float(10)
|
||||
display.webView.setVisible(True)
|
||||
display.phononWidget.setVisible(False)
|
||||
display.vlcWidget.setVisible(False)
|
||||
if path.endswith(u'.swf'):
|
||||
js = u'show_flash("load","%s");' % \
|
||||
(path.replace(u'\\', u'\\\\'))
|
||||
@ -58,10 +85,10 @@ class WebkitController(MediaController):
|
||||
|
||||
def resize(self, display, controller):
|
||||
if display == controller.previewDisplay:
|
||||
print display.size()
|
||||
display.webView.resize(display.size())
|
||||
|
||||
def play(self, display):
|
||||
self.set_visible(display, True)
|
||||
if self.isFlash:
|
||||
display.frame.evaluateJavaScript(u'show_flash("play","");')
|
||||
else:
|
||||
@ -89,22 +116,28 @@ class WebkitController(MediaController):
|
||||
|
||||
def seek(self, display, seekVal):
|
||||
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):
|
||||
if self.isFlash:
|
||||
display.frame.evaluateJavaScript(u'show_flash("close","");')
|
||||
else:
|
||||
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):
|
||||
return
|
||||
if not self.isFlash:
|
||||
currentTime = display.frame.evaluateJavaScript(u'show_video("currentTime");')
|
||||
length = display.frame.evaluateJavaScript(u'show_video("length");')
|
||||
controller.seekSlider.setMaximum(length.toFloat()[0]*1000)
|
||||
if not controller.seekSlider.isSliderDown():
|
||||
currentTime = display.frame.evaluateJavaScript(u'show_video("currentTime");')
|
||||
controller.seekSlider.setSliderPosition(currentTime.toFloat()[0]*1000)
|
||||
if int(currentTime.toFloat()[0]*1000) > 0:
|
||||
controller.seekSlider.setMaximum(int(length.toFloat()[0]*1000))
|
||||
if not controller.seekSlider.isSliderDown():
|
||||
controller.seekSlider.setSliderPosition(int(currentTime.toFloat()[0]*1000))
|
||||
|
||||
def get_supported_file_types(self):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user