forked from openlp/openlp
Clean up Phonon media Object creation
bzr-revno: 1503
This commit is contained in:
commit
0f7f03da30
@ -71,7 +71,7 @@ class Renderer(object):
|
||||
log.debug(u'Initilisation started')
|
||||
self.screens = screens
|
||||
self.image_manager = ImageManager()
|
||||
self.display = MainDisplay(self, screens, False)
|
||||
self.display = MainDisplay(self, screens, False, False)
|
||||
self.display.imageManager = self.image_manager
|
||||
self.theme_manager = theme_manager
|
||||
self.service_theme = u''
|
||||
|
@ -60,16 +60,19 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
This is the display screen.
|
||||
"""
|
||||
def __init__(self, parent, screens, live):
|
||||
def __init__(self, parent, screens, live, needsPhonon=True):
|
||||
DisplayWidget.__init__(self, live, parent=None)
|
||||
self.parent = parent
|
||||
self.screens = screens
|
||||
self.isLive = live
|
||||
self.needsPhonon = needsPhonon
|
||||
self.alertTab = None
|
||||
self.hideMode = None
|
||||
self.videoHide = False
|
||||
self.override = {}
|
||||
self.retranslateUi()
|
||||
self.mediaObject = None
|
||||
self.firstTime = True
|
||||
self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;')
|
||||
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool |
|
||||
QtCore.Qt.WindowStaysOnTopHint)
|
||||
@ -78,6 +81,9 @@ 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):
|
||||
"""
|
||||
@ -102,19 +108,9 @@ class MainDisplay(DisplayWidget):
|
||||
self.videoWidget.setGeometry(QtCore.QRect(0, 0,
|
||||
self.screen[u'size'].width(), self.screen[u'size'].height()))
|
||||
log.debug(u'Setup Phonon for monitor %s' % self.screens.monitor_number)
|
||||
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)
|
||||
if self.isLive:
|
||||
if not self.firstTime:
|
||||
self.createMediaObject()
|
||||
log.debug(u'Setup webView for monitor %s' % self.screens.monitor_number)
|
||||
self.webView = QtWebKit.QWebView(self)
|
||||
self.webView.setGeometry(0, 0,
|
||||
@ -175,6 +171,24 @@ 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
|
||||
@ -348,6 +362,8 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
Loads and starts a video to run with the option of sound
|
||||
"""
|
||||
if not self.mediaObject:
|
||||
self.createMediaObject()
|
||||
log.debug(u'video')
|
||||
self.webLoaded = True
|
||||
self.setGeometry(self.screen[u'size'])
|
||||
|
@ -277,15 +277,16 @@ 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.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)
|
||||
self.video.setGeometry(QtCore.QRect(0, 0, 300, 225))
|
||||
self.slideLayout.insertWidget(0, self.video)
|
||||
self.slideLayout.insertWidget(0, self.video)
|
||||
# Actual preview screen
|
||||
self.slidePreview = QtGui.QLabel(self)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
||||
|
@ -99,6 +99,7 @@ class VersionThread(QtCore.QThread):
|
||||
local_version.get(u'revision') and \
|
||||
remote_version[u'revision'] > local_version[u'revision']:
|
||||
Receiver.send_message(u'openlp_version_check', u'%s' % version)
|
||||
Receiver.send_message(u'openlp_phonon_creation')
|
||||
|
||||
|
||||
class AppLocation(object):
|
||||
|
@ -50,10 +50,13 @@ class MediaMediaItem(MediaManagerItem):
|
||||
u':/media/media_video.png').toImage()
|
||||
MediaManagerItem.__init__(self, parent, self, icon)
|
||||
self.singleServiceItem = False
|
||||
self.mediaObject = Phonon.MediaObject(self)
|
||||
self.mediaObject = None
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'video_background_replaced'),
|
||||
self.videobackgroundReplaced)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_phonon_creation'),
|
||||
self.createPhonon)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media')
|
||||
@ -209,4 +212,9 @@ 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)
|
||||
self.listView.addItem(item_name)
|
||||
|
||||
def createPhonon(self):
|
||||
if not self.mediaObject:
|
||||
self.mediaObject = Phonon.MediaObject(self)
|
||||
|
||||
|
@ -473,4 +473,4 @@ class SongMediaItem(MediaManagerItem):
|
||||
Locale aware collation of song titles
|
||||
"""
|
||||
return locale.strcoll(unicode(song_1.title.lower()),
|
||||
unicode(song_2.title.lower()))
|
||||
unicode(song_2.title.lower()))
|
||||
|
Loading…
Reference in New Issue
Block a user