diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py
index b1511eae6..5e63c9b2c 100644
--- a/openlp/core/lib/htmlbuilder.py
+++ b/openlp/core/lib/htmlbuilder.py
@@ -325,22 +325,18 @@ sup {
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}
- else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
- {
- return document.getElementById(movieName);
- }
}
function show_flash(state, path){
var text = document.getElementById('flash');
- var flashMovie=getFlashMovieObject("OpenLPFlashMovie");
+ var flashMovie = getFlashMovieObject("OpenLPFlashMovie");
var src = "src = 'file:///" + path + "'";
var view_parm = " wmode='opaque'" +
- " width='" + window.innerWidth + "'" +
- " height='" + window.innerHeight + "'";
+ " width='" + window.innerWidth + "'" +
+ " height='" + window.innerHeight + "'";
var swf_parm = " autostart='false' loop='false' play='false'" +
- " hidden='false' swliveconnect='true'" +
- " name='OpenLPFlashMovie'>";
+ " hidden='false' swliveconnect='true'" +
+ " name='OpenLPFlashMovie'>";
switch(state){
case 'load':
@@ -349,12 +345,10 @@ sup {
text.style.visibility = 'visible';
flashMovie.Play();
break;
-
case 'play':
text.style.visibility = 'visible';
flashMovie.Play();
break;
-
case 'rewind':
ret = 'rewind';
alert(' Wert: ' + flashMovie.TGetProperty("/", 4));
@@ -364,7 +358,7 @@ sup {
break;
case 'stop':
flashMovie.StopPlay();
- text.innerHTML = ''
+ text.innerHTML = '';
text.style.visibility = 'hidden';
break;
}
diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py
index a2985c0b8..c6ac9d35a 100644
--- a/openlp/core/ui/__init__.py
+++ b/openlp/core/ui/__init__.py
@@ -56,7 +56,7 @@ from firsttimelanguageform import FirstTimeLanguageForm
from themeform import ThemeForm
from filerenameform import FileRenameForm
from starttimeform import StartTimeForm
-from maindisplay import MainDisplay
+from maindisplay import MainDisplay, Display
from servicenoteform import ServiceNoteForm
from serviceitemeditform import ServiceItemEditForm
from screen import ScreenList
diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py
index 0b87cf67e..ff7ad1808 100644
--- a/openlp/core/ui/maindisplay.py
+++ b/openlp/core/ui/maindisplay.py
@@ -55,6 +55,30 @@ class DisplayWidget(QtGui.QGraphicsView):
self.parent = parent
self.live = live
+class Display(QtGui.QFrame):
+ """
+ This is the display screen for preview Widgets.
+ """
+ def __init__(self, parent):
+ QtGui.QFrame.__init__(self, parent)
+ self.parent = parent
+
+ def setup(self):
+ """
+ Set up and build the preview screen
+ """
+ self.webView = QtWebKit.QWebView(self)
+ self.webView.setGeometry(0, 0,
+ self.parent.width(), self.parent.height())
+ self.webView.settings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True)
+ self.page = self.webView.page()
+ self.frame = self.page.mainFrame()
+ screen = {}
+ screen[u'size'] = self.size()
+ serviceItem = ServiceItem()
+ self.webView.setHtml(build_html(serviceItem, screen,
+ None, None, None))
+ self.webView.hide()
class MainDisplay(DisplayWidget):
"""
@@ -103,7 +127,7 @@ class MainDisplay(DisplayWidget):
self.webView = QtWebKit.QWebView(self)
self.webView.setGeometry(0, 0,
self.screen[u'size'].width(), self.screen[u'size'].height())
- self.webView.settings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled,True)
+ self.webView.settings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True)
self.page = self.webView.page()
self.frame = self.page.mainFrame()
QtCore.QObject.connect(self.webView,
@@ -156,7 +180,6 @@ class MainDisplay(DisplayWidget):
self.primary = False
else:
self.primary = True
- Receiver.send_message(u'media_set_display', self)
log.debug(
u'Finished setup for monitor %s' % self.screens.monitor_number)
diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py
index 32a28d474..60544ccea 100644
--- a/openlp/core/ui/mainwindow.py
+++ b/openlp/core/ui/mainwindow.py
@@ -979,7 +979,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
for fileId, filename in enumerate(recentFilesToDisplay):
log.debug('Recent file name: %s', filename)
action = base_action(self, u'')
- action.setText(u'&%d %s' %
+ action.setText(u'&%d %s' %
(fileId + 1, QtCore.QFileInfo(filename).fileName()))
action.setData(QtCore.QVariant(filename))
self.connect(action, QtCore.SIGNAL(u'triggered()'),
diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py
index 68bd9d5e0..d30e7b144 100644
--- a/openlp/core/ui/slidecontroller.py
+++ b/openlp/core/ui/slidecontroller.py
@@ -33,7 +33,7 @@ from PyQt4.phonon import Phonon
from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \
ItemCapabilities, translate
from openlp.core.lib.ui import UiStrings, shortcut_action
-from openlp.core.ui import HideMode, MainDisplay
+from openlp.core.ui import HideMode, MainDisplay, Display
from openlp.core.utils.actions import ActionList, CategoryOrder
log = logging.getLogger(__name__)
@@ -234,19 +234,15 @@ class SlideController(QtGui.QWidget):
self.songMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Go To'), self.toolbar))
self.toolbar.makeWidgetsInvisible([u'Song Menu'])
- # Build the seekSlider.
- self.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
- self.seekSlider.setMaximum(1000)
- # Build the volumeSlider.
- 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)
- else:
- # Build the seekSlider.
- self.seekSlider = Phonon.SeekSlider()
- self.volumeSlider = Phonon.VolumeSlider()
+ # Build the seekSlider.
+ self.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
+ self.seekSlider.setMaximum(1000)
+ # Build the volumeSlider.
+ 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.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
self.seekSlider.setObjectName(u'seekSlider')
self.mediabar.addToolbarWidget(u'Seek Slider', self.seekSlider)
@@ -271,15 +267,9 @@ class SlideController(QtGui.QWidget):
self.slideLayout.setSpacing(0)
self.slideLayout.setMargin(0)
self.slideLayout.setObjectName(u'SlideLayout')
- self.mediaObject = Phonon.MediaObject(self)
- self.video = Phonon.VideoWidget()
- self.video.setVisible(False)
- self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject)
- Phonon.createPath(self.mediaObject, self.video)
- Phonon.createPath(self.mediaObject, self.audio)
- if not self.isLive:
- self.video.setGeometry(QtCore.QRect(0, 0, 300, 225))
- self.slideLayout.insertWidget(0, self.video)
+ self.previewDisplay = Display(self)
+ self.previewDisplay.setGeometry(QtCore.QRect(0, 0, 300, 300))
+ self.slideLayout.insertWidget(0, self.previewDisplay)
# Actual preview screen
self.slidePreview = QtGui.QLabel(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
@@ -402,8 +392,7 @@ class SlideController(QtGui.QWidget):
def liveEscape(self):
self.display.setVisible(False)
- #self.display.videoStop()
- Receiver.send_message('media_stop', self.display)
+ Receiver.send_message('media_stop', self)
def servicePrevious(self):
Receiver.send_message('servicemanager_previous_item')
@@ -427,6 +416,10 @@ class SlideController(QtGui.QWidget):
self.ratio = float(self.screens.current[u'size'].width()) / \
float(self.screens.current[u'size'].height())
self.previewSizeChanged()
+ Receiver.send_message(u'setup_display', self.display)
+ self.previewDisplay.resize(self.slidePreview.size())
+ self.previewDisplay.setup()
+ Receiver.send_message(u'setup_display', self.previewDisplay)
if self.serviceItem:
self.refreshServiceItem()
@@ -522,7 +515,7 @@ class SlideController(QtGui.QWidget):
elif item.is_media():
#self.toolbar.setVisible(False)
self.mediabar.setVisible(True)
- self.volumeSlider.setAudioOutput(self.audio)
+# self.volumeSlider.setAudioOutput(self.audio)
def refreshServiceItem(self):
"""
@@ -1060,16 +1053,9 @@ class SlideController(QtGui.QWidget):
"""
log.debug(u'SlideController onMediaStart')
file = os.path.join(item.get_frame_path(), item.get_frame_title())
- if self.isLive:
- Receiver.send_message(u'media_video', [self.display, file, self.volume, False])
- self.volumeSlider.setValue(self.volume)
- else:
- self.mediaObject.stop()
- self.mediaObject.clearQueue()
- self.mediaObject.setCurrentSource(Phonon.MediaSource(file))
- self.seekSlider.setMediaObject(self.mediaObject)
- self.seekSlider.show()
- self.onMediaPlay()
+ Receiver.send_message(u'media_video', [self, file, self.volume, False])
+ self.volumeSlider.setValue(self.volume)
+ self.slidePreview.hide()
def mediaSeek(self):
"""
@@ -1077,7 +1063,7 @@ class SlideController(QtGui.QWidget):
"""
log.debug(u'SlideController mediaSeek')
self.seekPos = self.seekSlider.value()
- Receiver.send_message(u'media_seek', [self.display, self.seekPos])
+ Receiver.send_message(u'media_seek', [self, self.seekPos])
def mediaVolume(self):
"""
@@ -1085,7 +1071,7 @@ class SlideController(QtGui.QWidget):
"""
log.debug(u'SlideController mediaVolume')
self.volume = self.volumeSlider.value()
- Receiver.send_message(u'media_volume', [self.display, self.volume])
+ Receiver.send_message(u'media_volume', [self, self.volume])
def onMediaPause(self):
@@ -1093,33 +1079,22 @@ class SlideController(QtGui.QWidget):
Respond to the Pause from the media Toolbar
"""
log.debug(u'SlideController onMediaPause')
- if self.isLive:
- Receiver.send_message(u'media_pause', self.display)
- else:
- self.mediaObject.pause()
+ Receiver.send_message(u'media_pause', self)
def onMediaPlay(self):
"""
Respond to the Play from the media Toolbar
"""
log.debug(u'SlideController onMediaPlay')
- if self.isLive:
- Receiver.send_message(u'media_play', self.display)
- else:
- self.slidePreview.hide()
- self.video.show()
- self.mediaObject.play()
+ Receiver.send_message(u'media_play', self)
+ self.slidePreview.hide()
def onMediaStop(self):
"""
Respond to the Stop from the media Toolbar
"""
log.debug(u'SlideController onMediaStop')
- if self.isLive:
- Receiver.send_message(u'media_stop', self.display)
- else:
- self.mediaObject.stop()
- self.video.hide()
+ Receiver.send_message(u'media_stop', self)
self.slidePreview.clear()
self.slidePreview.show()
@@ -1128,12 +1103,7 @@ class SlideController(QtGui.QWidget):
Respond to a request to close the Video
"""
log.debug(u'SlideController onMediaClose')
- if self.isLive:
- Receiver.send_message(u'media_reset', self.display)
- else:
- self.mediaObject.stop()
- self.mediaObject.clearQueue()
- self.video.hide()
+ Receiver.send_message(u'media_reset', self)
self.slidePreview.clear()
self.slidePreview.show()
diff --git a/openlp/plugins/media/lib/__init__.py b/openlp/plugins/media/lib/__init__.py
index 5e078763d..bd69e4716 100644
--- a/openlp/plugins/media/lib/__init__.py
+++ b/openlp/plugins/media/lib/__init__.py
@@ -32,16 +32,16 @@ class MediaBackends(object):
Phonon = 1
Vlc = 2
-class MediaStates(object):
+class MediaState(object):
"""
- An enumeratioin for possible States of the Media Player
+ An enumeration for possible States of the Media Player
(copied from Phonon::State
"""
- LoadingState = 0
- StoppedState = 1
- PlayingState = 2
- PausedState = 4
- OffState = 6
+ Loading = 0
+ Stopped = 1
+ Playing = 2
+ Paused = 4
+ Off = 6
class MediaController(object):
"""
@@ -50,11 +50,14 @@ class MediaController(object):
"""
def __init__(self, parent):
self.parent = parent
- self.state = MediaStates.OffState
+ self.state = MediaState.Off
def load(self, display, path, volume):
pass
+ def resize(self, display, controller):
+ pass
+
def play(self, display):
pass
@@ -64,16 +67,19 @@ class MediaController(object):
def stop(self, display):
pass
+ def volume(self, display, vol):
+ pass
+
def seek(self, display, seekVal):
pass
def reset(self, display):
pass
- def updateUI(self, display):
+ def update_ui(self, controller, display):
pass
- def getSupportedFileTypes(self):
+ def get_supported_file_types(self):
pass
from mediaitem import MediaMediaItem
diff --git a/openlp/plugins/media/lib/mediacontroller.py b/openlp/plugins/media/lib/mediacontroller.py
index 200af77bf..4bbf144d2 100644
--- a/openlp/plugins/media/lib/mediacontroller.py
+++ b/openlp/plugins/media/lib/mediacontroller.py
@@ -31,11 +31,11 @@ import sys, types
from PyQt4 import QtCore
import vlc
-from PyQt4 import QtCore, QtGui
+from PyQt4 import QtCore, QtGui, QtWebKit
from PyQt4.phonon import Phonon
from openlp.core.lib import Receiver
-from openlp.plugins.media.lib import MediaBackends, MediaStates
+from openlp.plugins.media.lib import MediaBackends, MediaState
from webkitcontroller import WebkitController
from phononcontroller import PhononController
from vlccontroller import VlcController
@@ -44,83 +44,53 @@ log = logging.getLogger(__name__)
class MediaManager(object):
"""
- The implementation of a Media Manager
- The idea is to separate the media related implementation into the plugin files
- and unify the access from other parts of code
- The media manager adds an own class for every type of backend
- Currently these are QtWebkit, Phonon and planed Vlc.
- On the other hand currently the previewController display only use phonon for media output.
- So I would suggest to rename the maindisplay.py to display.py and modify the code,
- so that the display class can be used for the maindisplay as well as for the previewController display.
-
- Workflow idea:
- - OpenLP is starting
- - Live display and preview display are call setup
- - Live display and preview display send signal with a pointer to their own to the media controller ('media_set_display')
- - media controller register all available displays and create for each display all types of media backends (see setDisplay)
- - in the OpenLP configuration dialog the user no longe will decide between using Webkit OR Phonon.
- - instead of this there is a list widget with all available backends and the user can switch off/on the backends
- and change the priority order
- (this is necessary, because of not all backends can play all media files and text over video is currently only with QtWebkit possible)
- - later on, if the user add a new media service item the signal ('media_video') will be send
- - as a result of this the media manager checks which controller is needed for this filetyp
- and assign the related backend controller to the right display
- - Now all related media stuff (play, pause, ...) will be routed to the related backend controller and there processed
- - if one or more medias loaded a generic 200ms Timer will be started peridiodically to refresh the UI
- - Signal ('media_reset') will close the related video and disconnect the backend from the display
-
- Advantages:
- - clean and easy interface from other parts of code (slidecontroller and display classes)
- - more and better configuration possibilities inside the special backend controllers
- - same handling for preview and live display (or later on other additionally displays with their slide controllers)
-
- Disadvantages:
- - because of there will be display widgets created outside of the maindisplay.py file it is more complicate to read the code
- - some more signals are send arround the system
-
- Notices:
- - the flash support uses the flash plugin from Mozilla. So there is a js-check that this plugin is installed.
- - maybe there would be the installed flashplugin of the IE possible could also used, but I'm not sure about this?
- - I would suggest to not hide the main toolbar in case of media, instead of this the media toolbar should be
- visible as second toolbar (so the screen can be blanked also during a running video, ...)
+ The implementation of a Media Manager
+ The idea is to separate the media related implementation into the plugin files
+ and unify the access from other parts of code
+ The media manager adds an own class for every type of backend
+ Currently these are QtWebkit, Phonon and planed Vlc.
+ On the other hand currently the previewController display only use phonon for media output.
+ So I would suggest to rename the maindisplay.py to display.py and modify the code,
+ so that the display class can be used for the maindisplay as well as for the previewController display.
"""
+
def __init__(self, parent):
self.parent = parent
-
self.availableBackends = [
MediaBackends.Webkit,
MediaBackends.Phonon,
MediaBackends.Vlc]
self.curDisplayMediaController = {}
+ #one controller for every backend
self.displayWebkitController = WebkitController(self)
self.displayPhononController = PhononController(self)
self.displayVlcController = VlcController(self)
-
+ #Timer for video state
self.Timer = QtCore.QTimer()
self.Timer.setInterval(200)
-
+ #signals
QtCore.QObject.connect(self.Timer,
- QtCore.SIGNAL("timeout()"), self.videoState)
+ QtCore.SIGNAL("timeout()"), self.video_state)
QtCore.QObject.connect(Receiver.get_receiver(),
- QtCore.SIGNAL(u'media_set_display'), self.setDisplay)
+ QtCore.SIGNAL(u'setup_display'), self.setup_display)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'media_video'), self.video)
QtCore.QObject.connect(Receiver.get_receiver(),
- QtCore.SIGNAL(u'media_play'), self.videoPlay)
+ QtCore.SIGNAL(u'media_play'), self.video_play)
QtCore.QObject.connect(Receiver.get_receiver(),
- QtCore.SIGNAL(u'media_pause'), self.videoPause)
+ QtCore.SIGNAL(u'media_pause'), self.video_pause)
QtCore.QObject.connect(Receiver.get_receiver(),
- QtCore.SIGNAL(u'media_stop'), self.videoStop)
+ QtCore.SIGNAL(u'media_stop'), self.video_stop)
QtCore.QObject.connect(Receiver.get_receiver(),
- QtCore.SIGNAL(u'media_seek'), self.videoSeek)
+ QtCore.SIGNAL(u'media_seek'), self.video_seek)
QtCore.QObject.connect(Receiver.get_receiver(),
- QtCore.SIGNAL(u'media_volume'), self.videoVolume)
+ QtCore.SIGNAL(u'media_volume'), self.video_volume)
QtCore.QObject.connect(Receiver.get_receiver(),
- QtCore.SIGNAL(u'media_reset'), self.videoReset)
+ QtCore.SIGNAL(u'media_reset'), self.video_reset)
- def videoState(self):
+ def video_state(self):
"""
- check if there is an assigned media backend and do some
+ Check if there is an assigned media backend and do some
updating stuff (e.g. update the UI)
"""
isAnyonePlaying = False
@@ -128,67 +98,94 @@ class MediaManager(object):
self.Timer.stop()
else:
for display in self.curDisplayMediaController.keys():
- self.curDisplayMediaController[display].updateUI(display)
- if self.curDisplayMediaController[display].state == MediaStates.PlayingState:
+ if display == self.parent.previewController.previewDisplay or \
+ display == self.parent.previewController.display:
+ self.curDisplayMediaController[display].update_ui(self.parent.previewController, display)
+ else:
+ self.curDisplayMediaController[display].update_ui(self.parent.liveController, display)
+ if self.curDisplayMediaController[display].state == MediaState.Playing:
isAnyonePlaying = True
if not isAnyonePlaying:
self.Timer.stop()
- def setDisplay(self, display):
- self.setupVlcController(display)
- self.setupPhononController(display)
- self.setupWebkitController(display)
+ 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 setupWebkitController(self, 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 setupPhononController(self, display):
+ def setup_phonon_controller(self, display):
display.phononWidget = Phonon.VideoWidget(display)
display.phononWidget.setVisible(False)
- display.phononWidget.setGeometry(QtCore.QRect(0, 0,
- display.screen[u'size'].width(), display.screen[u'size'].height()))
+ 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 setupVlcController(self, display):
+ 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.setGeometry(QtCore.QRect(0, 0,
- display.screen[u'size'].width(), display.screen[u'size'].height()))
+ display.vlcWidget.resize(display.size())
display.vlcWidget.raise_()
+ def resize(self, controller):
+ for display in self.curDisplayMediaController.keys():
+ display.resize(controller.slidePreview.size())
+ self.curDisplayMediaController[display].resize(display, controller)
+
def video(self, msg):
"""
Loads and starts a video to run with the option of sound
"""
- display = msg[0]
+ controller = msg[0]
videoPath = msg[1]
volume = msg[2]
isBackground = msg[3]
-
log.debug(u'video')
- display.webLoaded = True
- display.setGeometry(display.screen[u'size'])
- # We are running a background theme
- display.override[u'theme'] = u''
- display.override[u'video'] = True
vol = float(volume) / float(10)
- self.checkFileType(display, videoPath, isBackground)
- self.curDisplayMediaController[display].load(display, videoPath, volume)
- if display.isLive:
+ #stop running videos
+ self.video_reset(controller)
+ if controller.isLive:
+ # 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.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)
+ self.curDisplayMediaController[display].load(display, videoPath, volume)
+ #check size of all media_widgets
+ self.resize(controller)
+ #now start playing
+ for display in self.curDisplayMediaController.keys():
+ if display.parent == controller:
+ self.curDisplayMediaController[display].pause(display)
- def checkFileType(self, display, videoPath, isBackground):
+ def check_file_type(self, display, videoPath, isBackground):
"""
- Used to choose the right media backend type
- from the prioritized backend list
+ 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()
@@ -199,127 +196,104 @@ class MediaManager(object):
elif videoPath.endswith(u'.wmv'):
useVlc = False
usePhonon = True
-
if useVlc:
self.curDisplayMediaController[display] = self.displayVlcController
display.phononWidget.setVisible(False)
- display.webView.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.webView.setVisible(False)
display.vlcWidget.setVisible(False)
+ display.webView.setVisible(False)
else:
self.curDisplayMediaController[display] = self.displayWebkitController
display.phononWidget.setVisible(False)
- display.webView.setVisible(True)
display.vlcWidget.setVisible(False)
+ display.webView.setVisible(True)
if len(self.curDisplayMediaController) > 0:
if not self.Timer.isActive():
self.Timer.start()
-
- def resetVideo(self):
- """
- Used after Video plugin has changed the background
- """
- log.debug(u'resetVideo')
- if display.phononActive:
- display.mediaObject.stop()
- display.mediaObject.clearQueue()
- display.webView.setVisible(True)
- display.phononWidget.setVisible(False)
- display.phononActive = False
- else:
- display.frame.evaluateJavaScript(u'show_video("close");')
- display.frame.evaluateJavaScript(u'show_flash("close");')
- display.override = {}
- # Update the preview frame.
- if display.isLive:
- Receiver.send_message(u'maindisplay_active')
-
- def videoPlay(self, display):
+ def video_play(self, controller):
"""
Responds to the request to play a loaded video
"""
- log.debug(u'videoPlay')
- self.curDisplayMediaController[display].play(display)
+ 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 display.isLive:
- if not self.Timer.isActive():
- self.Timer.start()
- display.setVisible(True)
+ if not self.Timer.isActive():
+ self.Timer.start()
+ display.setVisible(True)
- def videoPause(self, display):
+ def video_pause(self, controller):
"""
Responds to the request to pause a loaded video
"""
log.debug(u'videoPause')
- if display in self.curDisplayMediaController:
- self.curDisplayMediaController[display].pause(display)
- return
+ for display in self.curDisplayMediaController.keys():
+ if display.parent == controller:
+ self.curDisplayMediaController[display].pause(display)
- def videoStop(self, display):
+ def video_stop(self, controller):
"""
Responds to the request to stop a loaded video
"""
- log.debug(u'videoStop')
- if type(display) is types.ListType:
- return
- if display in self.curDisplayMediaController:
- self.curDisplayMediaController[display].stop(display)
- if display.isLive:
- display.setVisible(False)
+ log.debug(u'video_stop')
+ for display in self.curDisplayMediaController.keys():
+ if display.parent == controller:
+ self.curDisplayMediaController[display].stop(display)
-
- def videoVolume(self, msg):
+ def video_volume(self, msg):
"""
Changes the volume of a running video
"""
- display = msg[0]
+ controller = msg[0]
volume = msg[1]
- log.debug(u'videoVolume %d' % volume)
+ log.debug(u'video_volume %d' % volume)
vol = float(volume) / float(10)
- if display.phononActive:
- display.audio.setVolume(vol)
- else:
- display.frame.evaluateJavaScript(u'show_video(null, null, %s);' %
- str(vol))
+ for display in self.curDisplayMediaController.keys():
+ if display.parent == controller:
+ self.curDisplayMediaController[display].volume(display, vol)
- def videoFinished(self):
+ def video_finished(self):
"""
Blank the Video when it has finished so the final frame is not left
hanging
"""
display.videoStop()
display.hideDisplay(HideMode.Blank)
- display.phononActive = False
display.videoHide = True
- def videoTick(self, tick):
+ def video_tick(self, tick):
"""
Triggered on video tick every 200 milli seconds
"""
if tick > display.serviceItem.end_time * 1000:
display.videoFinished()
- def videoSeek(self, msg):
+ def video_seek(self, msg):
"""
Responds to the request to change the seek Slider of a loaded video
"""
- log.debug(u'videoSeek')
- display = msg[0]
+ log.debug(u'video_seek')
+ controller = msg[0]
seekVal = msg[1]
- if display in self.curDisplayMediaController:
- self.curDisplayMediaController[display].seek(display, seekVal)
+ for display in self.curDisplayMediaController.keys():
+ if display.parent == controller:
+ self.curDisplayMediaController[display].seek(display, seekVal)
- def videoReset(self, display):
+ def video_reset(self, controller):
"""
Responds to the request to reset a loaded video
"""
- log.debug(u'videoReset')
- print "videoReset"
- if display in self.curDisplayMediaController:
- self.curDisplayMediaController[display].reset(display)
- self.curDisplayMediaController[display]
+ log.debug(u'video_reset')
+ for display in self.curDisplayMediaController.keys():
+ if display.parent == controller:
+ self.curDisplayMediaController[display].reset(display)
+ del self.curDisplayMediaController[display]
+ if controller.isLive:
+ Receiver.send_message(u'maindisplay_active')
diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py
index 9cb661a57..abf22c40a 100644
--- a/openlp/plugins/media/lib/mediaitem.py
+++ b/openlp/plugins/media/lib/mediaitem.py
@@ -91,7 +91,7 @@ class MediaMediaItem(MediaManagerItem):
self.resetAction.setVisible(False)
#self.parent.liveController.display.resetVideo()
Receiver.send_message(u'media_reset',
- self.parent.liveController.display)
+ self.parent.liveController)
def videobackgroundReplaced(self):
"""
@@ -110,9 +110,8 @@ class MediaMediaItem(MediaManagerItem):
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
if os.path.exists(filename):
(path, name) = os.path.split(filename)
- #self.parent.liveController.display.video(filename, 0, True)
Receiver.send_message(u'media_video',
- [self.parent.liveController.display, filename, 0, True])
+ [self.parent.liveController, filename, 0, True])
self.resetAction.setVisible(True)
else:
critical_error_message_box(UiStrings().LiveBGError,
@@ -136,7 +135,7 @@ class MediaMediaItem(MediaManagerItem):
# self.mediaObject.stop()
# self.mediaObject.clearQueue()
# self.mediaObject.setCurrentSource(Phonon.MediaSource(filename))
-# if not self.mediaStateWait(Phonon.StoppedState):
+# if not self.mediaStateWait(Phonon.Stopped):
# Due to string freeze, borrow a message from presentations
# This will be corrected in 1.9.6
# critical_error_message_box(
@@ -147,7 +146,7 @@ class MediaMediaItem(MediaManagerItem):
# File too big for processing
if os.path.getsize(filename) <= 52428800: # 50MiB
# self.mediaObject.play()
-# if not self.mediaStateWait(Phonon.PlayingState) \
+# if not self.mediaStateWait(Phonon.Playing) \
# or self.mediaObject.currentSource().type() \
# == Phonon.MediaSource.Invalid:
# # Due to string freeze, borrow a message from presentations
@@ -213,4 +212,4 @@ class MediaMediaItem(MediaManagerItem):
img = QtGui.QPixmap(u':/media/media_video.png').toImage()
item_name.setIcon(build_icon(img))
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
- self.listView.addItem(item_name)
\ No newline at end of file
+ self.listView.addItem(item_name)
diff --git a/openlp/plugins/media/lib/phononcontroller.py b/openlp/plugins/media/lib/phononcontroller.py
index d8b71d29a..f4fe8056d 100644
--- a/openlp/plugins/media/lib/phononcontroller.py
+++ b/openlp/plugins/media/lib/phononcontroller.py
@@ -27,16 +27,32 @@
from PyQt4.phonon import Phonon
-from openlp.plugins.media.lib import MediaController, MediaStates
+from openlp.plugins.media.lib import MediaController, MediaState
class PhononController(MediaController):
"""
Specialiced MediaController class
to reflect Features of the Phonon backend
"""
+
def __init__(self, parent):
- self.parent = parent
MediaController.__init__(self, parent)
+ self.parent = parent
+ 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"
@@ -47,47 +63,46 @@ class PhononController(MediaController):
# Need the timer to trigger set the trigger to 200ms
# Value taken from web documentation.
vol = float(volume) / float(10)
- if display.serviceItem.end_time != 0:
- display.mediaObject.setTickInterval(200)
- display.mediaObject.play()
display.audio.setVolume(vol)
- self.state = MediaStates.PlayingState
+ def resize(self, display):
+ display.phononWidget.resize(display.size())
def play(self, display):
+ vol = float(display.parent.volume) / float(10)
+ display.audio.setVolume(vol)
display.mediaObject.play()
- self.state = MediaStates.PlayingState
+ self.state = MediaState.Playing
def pause(self, display):
display.mediaObject.pause()
- self.state = MediaStates.PausedState
+ self.state = MediaState.Paused
def stop(self, display):
display.mediaObject.stop()
- self.state = MediaStates.StoppedState
+ self.state = MediaState.Stopped
+
+ def volume(self, display, vol):
+ display.audio.setVolume(vol)
def seek(self, display, seekVal):
- print "seek"
display.mediaObject.seek(seekVal)
def reset(self, display):
display.mediaObject.stop()
display.mediaObject.clearQueue()
- display.webView.setVisible(True)
display.phononWidget.setVisible(False)
- display.phononActive = False
+ #display.webView.setVisible(True)
- def updateUI(self, display):
- display.parent.seekSlider.setMaximum(display.mediaObject.totalTime())
- if not display.parent.seekSlider.isSliderDown():
- display.parent.seekSlider.setSliderPosition(display.mediaObject.currentTime())
-# if newState == Phonon.PlayingState \
-# and oldState != Phonon.PausedState \
+ def update_ui(self, controller, display):
+ controller.seekSlider.setMaximum(display.mediaObject.totalTime())
+ if not controller.seekSlider.isSliderDown():
+ controller.seekSlider.setSliderPosition(display.mediaObject.currentTime())
+# if newState == Phonon.Playing \
+# and oldState != Phonon.Paused \
# and self.serviceItem.start_time > 0:
# # set start time in milliseconds
# self.mediaObject.seek(self.serviceItem.start_time * 1000)
- pass
-
- def getSupportedFileTypes(self):
+ def get_supported_file_types(self):
pass
diff --git a/openlp/plugins/media/lib/vlccontroller.py b/openlp/plugins/media/lib/vlccontroller.py
index 7d36a51a4..d75dbd4cb 100644
--- a/openlp/plugins/media/lib/vlccontroller.py
+++ b/openlp/plugins/media/lib/vlccontroller.py
@@ -27,7 +27,7 @@
import sys
-from openlp.plugins.media.lib import MediaController, MediaStates
+from openlp.plugins.media.lib import MediaController, MediaState
class VlcController(MediaController):
"""
@@ -35,8 +35,23 @@ class VlcController(MediaController):
to reflect Features of the Vlc backend
"""
def __init__(self, parent):
- self.parent = parent
MediaController.__init__(self, parent)
+ self.parent = parent
+ 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 Vlc Controller"
@@ -61,34 +76,38 @@ class VlcController(MediaController):
display.vlcMediaPlayer.set_hwnd(int(display.vlcWidget.winId()))
elif sys.platform == "darwin": # for MacOS
display.vlcMediaPlayer.set_agl(int(display.vlcWidget.winId()))
- # start playing
- self.play(display)
- self.state = MediaStates.PlayingState
+
+ def resize(self, display):
+ display.vlcWidget.resize(display.size())
def play(self, display):
display.vlcMediaPlayer.play()
- self.state = MediaStates.PlayingState
+ self.state = MediaState.Playing
def pause(self, display):
display.vlcMediaPlayer.pause()
- self.state = MediaStates.PausedState
+ self.state = MediaState.Paused
def stop(self, display):
display.vlcMediaPlayer.stop()
- self.state = MediaStates.StoppedState
+ self.state = MediaState.Stopped
+
+ def volume(self, display, vol):
+ pass
def seek(self, display, seekVal):
if display.vlcMediaPlayer.is_seekable():
display.vlcMediaPlayer.set_position(seekVal/1000.0)
def reset(self, display):
- pass
+ display.vlcWidget.setVisible(False)
+ #display.webView.setVisible(True)
- def updateUI(self, display):
- display.parent.seekSlider.setMaximum(1000)
- if not display.parent.seekSlider.isSliderDown():
+ def update_ui(self, controller, display):
+ controller.seekSlider.setMaximum(1000)
+ if not controller.seekSlider.isSliderDown():
currentPos = display.vlcMediaPlayer.get_position() * 1000
- display.parent.seekSlider.setSliderPosition(currentPos)
+ controller.seekSlider.setSliderPosition(currentPos)
- def getSupportedFileTypes(self):
+ def get_supported_file_types(self):
pass
diff --git a/openlp/plugins/media/lib/webkitcontroller.py b/openlp/plugins/media/lib/webkitcontroller.py
index c021b9e7d..b8ef4d814 100644
--- a/openlp/plugins/media/lib/webkitcontroller.py
+++ b/openlp/plugins/media/lib/webkitcontroller.py
@@ -25,17 +25,20 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
-from openlp.plugins.media.lib import MediaController, MediaStates
+from openlp.plugins.media.lib import MediaController, MediaState
class WebkitController(MediaController):
"""
Specialiced MediaController class
to reflect Features of the QtWebkit backend
"""
+
def __init__(self, parent):
- self.parent = parent
MediaController.__init__(self, parent)
+ self.parent = parent
self.isFlash = False
+ self.additional_extensions = {
+ u'video/shockwave': [u'.swf']}
def load(self, display, path, volume):
print "load vid in Webkit Controller"
@@ -48,48 +51,60 @@ class WebkitController(MediaController):
(path.replace(u'\\', u'\\\\'))
self.isFlash = True
else:
- js = u'show_video("init", "%s", %s, false); show_video("play");' % \
+ js = u'show_video("init", "%s", %s, false);' % \
(path.replace(u'\\', u'\\\\'), str(vol))
self.isFlash = False
display.frame.evaluateJavaScript(js)
- self.state = MediaStates.PlayingState
+
+ def resize(self, display, controller):
+ if display == controller.previewDisplay:
+ print display.size()
+ display.webView.resize(display.size())
def play(self, display):
if self.isFlash:
display.frame.evaluateJavaScript(u'show_flash("play","");')
else:
display.frame.evaluateJavaScript(u'show_video("play");')
- self.state = MediaStates.PlayingState
+ self.state = MediaState.Playing
def pause(self, display):
if self.isFlash:
display.frame.evaluateJavaScript(u'show_flash("pause","");')
else:
display.frame.evaluateJavaScript(u'show_video("pause");')
- self.state = MediaStates.PausedState
+ self.state = MediaState.Paused
def stop(self, display):
if self.isFlash:
display.frame.evaluateJavaScript(u'show_flash("stop","");')
else:
display.frame.evaluateJavaScript(u'show_video("stop");')
- self.state = MediaStates.StoppedState
+ self.state = MediaState.Stopped
+
+ def volume(self, display, vol):
+ if not self.isFlash:
+ display.frame.evaluateJavaScript(u'show_video(null, null, %s);' %
+ str(vol))
def seek(self, display, seekVal):
if not self.isFlash:
- print seekVal, float(seekVal)/1000
display.frame.evaluateJavaScript(u'show_video("seek", "%f");' % (float(seekVal)/1000))
def reset(self, display):
- display.frame.evaluateJavaScript(u'show_video("close");')
+ if self.isFlash:
+ display.frame.evaluateJavaScript(u'show_flash("close","");')
+ else:
+ display.frame.evaluateJavaScript(u'show_video("close");')
- def updateUI(self, display):
+ def update_ui(self, controller, display):
+ return
if not self.isFlash:
length = display.frame.evaluateJavaScript(u'show_video("length");')
- display.parent.seekSlider.setMaximum(length.toFloat()[0]*1000)
- if not display.parent.seekSlider.isSliderDown():
+ controller.seekSlider.setMaximum(length.toFloat()[0]*1000)
+ if not controller.seekSlider.isSliderDown():
currentTime = display.frame.evaluateJavaScript(u'show_video("currentTime");')
- display.parent.seekSlider.setSliderPosition(currentTime.toFloat()[0]*1000)
+ controller.seekSlider.setSliderPosition(currentTime.toFloat()[0]*1000)
- def getSupportedFileTypes(self):
+ def get_supported_file_types(self):
pass
diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py
index 99eb5b94d..391a66511 100644
--- a/openlp/plugins/media/mediaplugin.py
+++ b/openlp/plugins/media/mediaplugin.py
@@ -123,3 +123,12 @@ class MediaPlugin(Plugin):
'Add the selected Media to the service')
}
self.setPluginUiTextStrings(tooltips)
+
+ def finalise(self):
+ """
+ Time to tidy up on exit
+ """
+ log.info(u'Media Finalising')
+ self.mediaManager.Timer.stop()
+ self.mediaManager.video_reset(self.previewController)
+ self.mediaManager.video_reset(self.liveController)