forked from openlp/openlp
Core Media to 120
This commit is contained in:
parent
0ea45fd885
commit
0f0b8d04e7
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
@ -89,8 +89,7 @@ def get_media_players():
|
||||
overridden_player = u'auto'
|
||||
else:
|
||||
overridden_player = u''
|
||||
saved_players_list = saved_players.replace(u'[', u'').\
|
||||
replace(u']',u'').split(u',')
|
||||
saved_players_list = saved_players.replace(u'[', u'').replace(u']',u'').split(u',')
|
||||
return saved_players_list, overridden_player
|
||||
|
||||
|
||||
@ -107,9 +106,8 @@ def set_media_players(players_list, overridden_player=u'auto'):
|
||||
"""
|
||||
log.debug(u'set_media_players')
|
||||
players = u','.join(players_list)
|
||||
if Settings().value(u'media/override player',
|
||||
QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0] == \
|
||||
QtCore.Qt.Checked and overridden_player != u'auto':
|
||||
if Settings().value(u'media/override player', QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0] == \
|
||||
QtCore.Qt.Checked and overridden_player != u'auto':
|
||||
players = players.replace(overridden_player, u'[%s]' % overridden_player)
|
||||
Settings().setValue(u'media/players', QtCore.QVariant(players))
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
@ -66,33 +66,21 @@ class MediaController(object):
|
||||
self.timer = QtCore.QTimer()
|
||||
self.timer.setInterval(200)
|
||||
# Signals
|
||||
QtCore.QObject.connect(self.timer,
|
||||
QtCore.SIGNAL("timeout()"), self.media_state)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'playbackPlay'), self.media_play_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'playbackPause'), self.media_pause_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'playbackStop'), self.media_stop_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'seekSlider'), self.media_seek)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'volumeSlider'), self.media_volume)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'media_hide'), self.media_hide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'media_blank'), self.media_blank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'media_unblank'), self.media_unblank)
|
||||
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.media_state)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackPlay'), self.media_play_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackPause'), self.media_pause_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackStop'), self.media_stop_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'seekSlider'), self.media_seek)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'volumeSlider'), self.media_volume)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_hide'), self.media_hide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_blank'), self.media_blank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_unblank'), self.media_unblank)
|
||||
# Signals for background video
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'songs_hide'), self.media_hide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'songs_unblank'), self.media_unblank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'mediaitem_media_rebuild'), self._set_active_players)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'mediaitem_suffixes'),
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_hide'), self.media_hide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_unblank'), self.media_unblank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_media_rebuild'),
|
||||
self._set_active_players)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_suffixes'),
|
||||
self._generate_extensions_lists)
|
||||
|
||||
def _set_active_players(self):
|
||||
@ -113,16 +101,14 @@ class MediaController(object):
|
||||
for item in player.audio_extensions_list:
|
||||
if not item in self.audio_extensions_list:
|
||||
self.audio_extensions_list.append(item)
|
||||
self.mainWindow.serviceManagerContents. \
|
||||
supportedSuffixes(item[2:])
|
||||
self.mainWindow.serviceManagerContents.supportedSuffixes(item[2:])
|
||||
self.video_extensions_list = []
|
||||
for player in self.mediaPlayers.values():
|
||||
if player.isActive:
|
||||
for item in player.video_extensions_list:
|
||||
if item not in self.video_extensions_list:
|
||||
self.video_extensions_list.extend(item)
|
||||
self.mainWindow.serviceManagerContents. \
|
||||
supportedSuffixes(item[2:])
|
||||
self.mainWindow.serviceManagerContents.supportedSuffixes(item[2:])
|
||||
|
||||
def register_players(self, player):
|
||||
"""
|
||||
@ -143,20 +129,17 @@ class MediaController(object):
|
||||
AppLocation.get_directory(AppLocation.AppDir),
|
||||
u'core', u'ui', u'media')
|
||||
for filename in os.listdir(controller_dir):
|
||||
if filename.endswith(u'player.py') and \
|
||||
not filename == 'mediaplayer.py':
|
||||
if filename.endswith(u'player.py') and not filename == 'mediaplayer.py':
|
||||
path = os.path.join(controller_dir, filename)
|
||||
if os.path.isfile(path):
|
||||
modulename = u'openlp.core.ui.media.' + \
|
||||
os.path.splitext(filename)[0]
|
||||
modulename = u'openlp.core.ui.media.' + os.path.splitext(filename)[0]
|
||||
log.debug(u'Importing controller %s', modulename)
|
||||
try:
|
||||
__import__(modulename, globals(), locals(), [])
|
||||
# On some platforms importing vlc.py might cause
|
||||
# also OSError exceptions. (e.g. Mac OS X)
|
||||
except (ImportError, OSError):
|
||||
log.warn(u'Failed to import %s on path %s',
|
||||
modulename, path)
|
||||
log.warn(u'Failed to import %s on path %s', modulename, path)
|
||||
player_classes = MediaPlayer.__subclasses__()
|
||||
for player_class in player_classes:
|
||||
player = player_class(self)
|
||||
@ -165,8 +148,7 @@ class MediaController(object):
|
||||
return False
|
||||
savedPlayers, overriddenPlayer = get_media_players()
|
||||
invalidMediaPlayers = [mediaPlayer for mediaPlayer in savedPlayers
|
||||
if not mediaPlayer in self.mediaPlayers or not
|
||||
self.mediaPlayers[mediaPlayer].check_available()]
|
||||
if not mediaPlayer in self.mediaPlayers or not self.mediaPlayers[mediaPlayer].check_available()]
|
||||
if invalidMediaPlayers:
|
||||
for invalidPlayer in invalidMediaPlayers:
|
||||
savedPlayers.remove(invalidPlayer)
|
||||
@ -188,8 +170,7 @@ class MediaController(object):
|
||||
display = self._define_display(self.displayControllers[source])
|
||||
self.currentMediaPlayer[source].resize(display)
|
||||
self.currentMediaPlayer[source].update_ui(display)
|
||||
if self.currentMediaPlayer[source].state == \
|
||||
MediaState.Playing:
|
||||
if self.currentMediaPlayer[source].state == MediaState.Playing:
|
||||
any_active = True
|
||||
# There are still any active players - no need to stop timer.
|
||||
if any_active:
|
||||
@ -251,28 +232,20 @@ class MediaController(object):
|
||||
controller.media_info = MediaInfo()
|
||||
# Build a Media ToolBar
|
||||
controller.mediabar = OpenLPToolbar(controller)
|
||||
controller.mediabar.addToolbarAction(u'playbackPlay',
|
||||
text=u'media_playback_play',
|
||||
controller.mediabar.addToolbarAction(u'playbackPlay', text=u'media_playback_play',
|
||||
icon=u':/slides/media_playback_start.png',
|
||||
tooltip=translate('OpenLP.SlideController', 'Start playing media.'),
|
||||
triggers=controller.sendToPlugins)
|
||||
controller.mediabar.addToolbarAction(u'playbackPause',
|
||||
text=u'media_playback_pause',
|
||||
tooltip=translate('OpenLP.SlideController', 'Start playing media.'), triggers=controller.sendToPlugins)
|
||||
controller.mediabar.addToolbarAction(u'playbackPause', text=u'media_playback_pause',
|
||||
icon=u':/slides/media_playback_pause.png',
|
||||
tooltip=translate('OpenLP.SlideController',
|
||||
'Pause playing media.'),
|
||||
triggers=controller.sendToPlugins)
|
||||
controller.mediabar.addToolbarAction(u'playbackStop',
|
||||
text=u'media_playback_stop',
|
||||
tooltip=translate('OpenLP.SlideController', 'Pause playing media.'), triggers=controller.sendToPlugins)
|
||||
controller.mediabar.addToolbarAction(u'playbackStop', text=u'media_playback_stop',
|
||||
icon=u':/slides/media_playback_stop.png',
|
||||
tooltip=translate('OpenLP.SlideController', 'Stop playing media.'),
|
||||
triggers=controller.sendToPlugins)
|
||||
tooltip=translate('OpenLP.SlideController', 'Stop playing media.'), triggers=controller.sendToPlugins)
|
||||
# Build the seekSlider.
|
||||
controller.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
|
||||
controller.seekSlider.setMaximum(1000)
|
||||
controller.seekSlider.setTracking(False)
|
||||
controller.seekSlider.setToolTip(translate(
|
||||
'OpenLP.SlideController', 'Video position.'))
|
||||
controller.seekSlider.setToolTip(translate('OpenLP.SlideController', 'Video position.'))
|
||||
controller.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
|
||||
controller.seekSlider.setObjectName(u'seekSlider')
|
||||
controller.mediabar.addToolbarWidget(controller.seekSlider)
|
||||
@ -283,8 +256,7 @@ class MediaController(object):
|
||||
controller.volumeSlider.setMinimum(0)
|
||||
controller.volumeSlider.setMaximum(100)
|
||||
controller.volumeSlider.setTracking(True)
|
||||
controller.volumeSlider.setToolTip(translate(
|
||||
'OpenLP.SlideController', 'Audio Volume.'))
|
||||
controller.volumeSlider.setToolTip(translate('OpenLP.SlideController', 'Audio Volume.'))
|
||||
controller.volumeSlider.setValue(controller.media_info.volume)
|
||||
controller.volumeSlider.setGeometry(QtCore.QRect(90, 160, 221, 24))
|
||||
controller.volumeSlider.setObjectName(u'volumeSlider')
|
||||
@ -292,10 +264,8 @@ class MediaController(object):
|
||||
controller.controllerLayout.addWidget(controller.mediabar)
|
||||
controller.mediabar.setVisible(False)
|
||||
# Signals
|
||||
QtCore.QObject.connect(controller.seekSlider,
|
||||
QtCore.SIGNAL(u'valueChanged(int)'), controller.sendToPlugins)
|
||||
QtCore.QObject.connect(controller.volumeSlider,
|
||||
QtCore.SIGNAL(u'valueChanged(int)'), controller.sendToPlugins)
|
||||
QtCore.QObject.connect(controller.seekSlider, QtCore.SIGNAL(u'valueChanged(int)'), controller.sendToPlugins)
|
||||
QtCore.QObject.connect(controller.volumeSlider, QtCore.SIGNAL(u'valueChanged(int)'), controller.sendToPlugins)
|
||||
|
||||
|
||||
def setup_display(self, display, preview):
|
||||
@ -337,8 +307,7 @@ class MediaController(object):
|
||||
controller.mediabar.setVisible(value)
|
||||
if controller.isLive and controller.display:
|
||||
if self.currentMediaPlayer and value:
|
||||
if self.currentMediaPlayer[controller.controllerType] != \
|
||||
self.mediaPlayers[u'webkit']:
|
||||
if self.currentMediaPlayer[controller.controllerType] != self.mediaPlayers[u'webkit']:
|
||||
controller.display.setTransparency(False)
|
||||
|
||||
def resize(self, display, player):
|
||||
@ -382,8 +351,7 @@ class MediaController(object):
|
||||
else:
|
||||
controller.media_info.volume = controller.volumeSlider.value()
|
||||
controller.media_info.is_background = False
|
||||
controller.media_info.file_info = \
|
||||
QtCore.QFileInfo(serviceItem.get_frame_path())
|
||||
controller.media_info.file_info = QtCore.QFileInfo(serviceItem.get_frame_path())
|
||||
display = self._define_display(controller)
|
||||
if controller.isLive:
|
||||
isValid = self._check_file_type(controller, display, serviceItem)
|
||||
@ -394,45 +362,36 @@ class MediaController(object):
|
||||
controller.media_info.start_time = 0
|
||||
controller.media_info.end_time = 0
|
||||
else:
|
||||
controller.media_info.start_time = \
|
||||
display.serviceItem.start_time
|
||||
controller.media_info.start_time = display.serviceItem.start_time
|
||||
controller.media_info.end_time = serviceItem.end_time
|
||||
elif controller.previewDisplay:
|
||||
isValid = self._check_file_type(controller, display, serviceItem)
|
||||
if not isValid:
|
||||
# Media could not be loaded correctly
|
||||
critical_error_message_box(
|
||||
translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||
unicode(translate('MediaPlugin.MediaItem',
|
||||
'Unsupported File')))
|
||||
critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||
unicode(translate('MediaPlugin.MediaItem', 'Unsupported File')))
|
||||
return False
|
||||
# dont care about actual theme, set a black background
|
||||
if controller.isLive and not controller.media_info.is_background:
|
||||
display.frame.evaluateJavaScript(u'show_video( \
|
||||
"setBackBoard", null, null, null,"visible");')
|
||||
display.frame.evaluateJavaScript(u'show_video( "setBackBoard", null, null, null,"visible");')
|
||||
# now start playing - Preview is autoplay!
|
||||
autoplay = False
|
||||
# Preview requested
|
||||
if not controller.isLive:
|
||||
autoplay = True
|
||||
# Visible or background requested or Service Item wants to autostart
|
||||
elif not hidden or controller.media_info.is_background or \
|
||||
serviceItem.will_auto_start:
|
||||
elif not hidden or controller.media_info.is_background or serviceItem.will_auto_start:
|
||||
autoplay = True
|
||||
# Unblank on load set
|
||||
elif Settings().value(u'general/auto unblank',
|
||||
QtCore.QVariant(False)).toBool():
|
||||
elif Settings().value(u'general/auto unblank', QtCore.QVariant(False)).toBool():
|
||||
autoplay = True
|
||||
if autoplay:
|
||||
if not self.media_play(controller):
|
||||
critical_error_message_box(
|
||||
translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||
unicode(translate('MediaPlugin.MediaItem',
|
||||
'Unsupported File')))
|
||||
critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||
unicode(translate('MediaPlugin.MediaItem', 'Unsupported File')))
|
||||
return False
|
||||
self.set_controls_visible(controller, True)
|
||||
log.debug(u'use %s controller' %
|
||||
self.currentMediaPlayer[controller.controllerType])
|
||||
log.debug(u'use %s controller' % self.currentMediaPlayer[controller.controllerType])
|
||||
return True
|
||||
|
||||
def media_length(self, serviceItem):
|
||||
@ -448,26 +407,20 @@ class MediaController(object):
|
||||
self.media_reset(controller)
|
||||
controller.media_info = MediaInfo()
|
||||
controller.media_info.volume = 0
|
||||
controller.media_info.file_info = QtCore.QFileInfo(serviceItem
|
||||
.get_frame_path())
|
||||
controller.media_info.file_info = QtCore.QFileInfo(serviceItem.get_frame_path())
|
||||
display = controller.previewDisplay
|
||||
if not self._check_file_type(controller, display, serviceItem):
|
||||
# Media could not be loaded correctly
|
||||
critical_error_message_box(
|
||||
translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||
unicode(translate('MediaPlugin.MediaItem',
|
||||
'Unsupported File')))
|
||||
critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||
unicode(translate('MediaPlugin.MediaItem', 'Unsupported File')))
|
||||
return False
|
||||
if not self.media_play(controller):
|
||||
critical_error_message_box(
|
||||
translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||
unicode(translate('MediaPlugin.MediaItem',
|
||||
'Unsupported File')))
|
||||
critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||
unicode(translate('MediaPlugin.MediaItem', 'Unsupported File')))
|
||||
return False
|
||||
serviceItem.set_media_length(controller.media_info.length)
|
||||
self.media_stop(controller)
|
||||
log.debug(u'use %s controller' %
|
||||
self.currentMediaPlayer[controller.controllerType])
|
||||
log.debug(u'use %s controller' % self.currentMediaPlayer[controller.controllerType])
|
||||
return True
|
||||
|
||||
def _check_file_type(self, controller, display, serviceItem):
|
||||
@ -484,24 +437,20 @@ class MediaController(object):
|
||||
if serviceItem.title != UiStrings().Automatic:
|
||||
usedPlayers = [serviceItem.title.lower()]
|
||||
if controller.media_info.file_info.isFile():
|
||||
suffix = u'*.%s' % \
|
||||
controller.media_info.file_info.suffix().toLower()
|
||||
suffix = u'*.%s' % controller.media_info.file_info.suffix().toLower()
|
||||
for title in usedPlayers:
|
||||
player = self.mediaPlayers[title]
|
||||
if suffix in player.video_extensions_list:
|
||||
if not controller.media_info.is_background or \
|
||||
controller.media_info.is_background and \
|
||||
player.canBackground:
|
||||
if not controller.media_info.is_background or controller.media_info.is_background and \
|
||||
player.canBackground:
|
||||
self.resize(display, player)
|
||||
if player.load(display):
|
||||
self.currentMediaPlayer[controller.controllerType] \
|
||||
= player
|
||||
self.currentMediaPlayer[controller.controllerType] = player
|
||||
controller.media_info.media_type = MediaType.Video
|
||||
return True
|
||||
if suffix in player.audio_extensions_list:
|
||||
if player.load(display):
|
||||
self.currentMediaPlayer[controller.controllerType] \
|
||||
= player
|
||||
self.currentMediaPlayer[controller.controllerType] = player
|
||||
controller.media_info.media_type = MediaType.Audio
|
||||
return True
|
||||
else:
|
||||
@ -510,8 +459,7 @@ class MediaController(object):
|
||||
if player.canFolder:
|
||||
self.resize(display, player)
|
||||
if player.load(display):
|
||||
self.currentMediaPlayer[controller.controllerType] \
|
||||
= player
|
||||
self.currentMediaPlayer[controller.controllerType] = player
|
||||
controller.media_info.media_type = MediaType.Video
|
||||
return True
|
||||
# no valid player found
|
||||
@ -541,8 +489,7 @@ class MediaController(object):
|
||||
return False
|
||||
if status:
|
||||
display.frame.evaluateJavaScript(u'show_blank("desktop");')
|
||||
self.currentMediaPlayer[controller.controllerType]\
|
||||
.set_visible(display, True)
|
||||
self.currentMediaPlayer[controller.controllerType].set_visible(display, True)
|
||||
# Flash needs to be played and will not AutoPlay
|
||||
if controller.media_info.is_flash:
|
||||
controller.mediabar.actions[u'playbackPlay'].setVisible(True)
|
||||
@ -605,8 +552,7 @@ class MediaController(object):
|
||||
if controller.controllerType in self.currentMediaPlayer:
|
||||
display.frame.evaluateJavaScript(u'show_blank("black");')
|
||||
self.currentMediaPlayer[controller.controllerType].stop(display)
|
||||
self.currentMediaPlayer[controller.controllerType] \
|
||||
.set_visible(display, False)
|
||||
self.currentMediaPlayer[controller.controllerType].set_visible(display, False)
|
||||
controller.seekSlider.setSliderPosition(0)
|
||||
controller.mediabar.actions[u'playbackPlay'].setVisible(True)
|
||||
controller.mediabar.actions[u'playbackStop'].setVisible(False)
|
||||
@ -637,8 +583,7 @@ class MediaController(object):
|
||||
controller = msg[0]
|
||||
seekVal = msg[1][0]
|
||||
display = self._define_display(controller)
|
||||
self.currentMediaPlayer[controller.controllerType] \
|
||||
.seek(display, seekVal)
|
||||
self.currentMediaPlayer[controller.controllerType].seek(display, seekVal)
|
||||
|
||||
def media_reset(self, controller):
|
||||
"""
|
||||
@ -650,10 +595,8 @@ class MediaController(object):
|
||||
if controller.controllerType in self.currentMediaPlayer:
|
||||
display.override = {}
|
||||
self.currentMediaPlayer[controller.controllerType].reset(display)
|
||||
self.currentMediaPlayer[controller.controllerType] \
|
||||
.set_visible(display, False)
|
||||
display.frame.evaluateJavaScript(u'show_video( \
|
||||
"setBackBoard", null, null, null,"hidden");')
|
||||
self.currentMediaPlayer[controller.controllerType].set_visible(display, False)
|
||||
display.frame.evaluateJavaScript(u'show_video( "setBackBoard", null, null, null,"hidden");')
|
||||
del self.currentMediaPlayer[controller.controllerType]
|
||||
|
||||
def media_hide(self, msg):
|
||||
@ -668,11 +611,9 @@ class MediaController(object):
|
||||
return
|
||||
controller = self.mainWindow.liveController
|
||||
display = self._define_display(controller)
|
||||
if self.currentMediaPlayer[controller.controllerType].state \
|
||||
== MediaState.Playing:
|
||||
if self.currentMediaPlayer[controller.controllerType].state == MediaState.Playing:
|
||||
self.currentMediaPlayer[controller.controllerType].pause(display)
|
||||
self.currentMediaPlayer[controller.controllerType] \
|
||||
.set_visible(display, False)
|
||||
self.currentMediaPlayer[controller.controllerType].set_visible(display, False)
|
||||
|
||||
def media_blank(self, msg):
|
||||
"""
|
||||
@ -689,11 +630,9 @@ class MediaController(object):
|
||||
Receiver.send_message(u'live_display_hide', hide_mode)
|
||||
controller = self.mainWindow.liveController
|
||||
display = self._define_display(controller)
|
||||
if self.currentMediaPlayer[controller.controllerType].state \
|
||||
== MediaState.Playing:
|
||||
if self.currentMediaPlayer[controller.controllerType].state == MediaState.Playing:
|
||||
self.currentMediaPlayer[controller.controllerType].pause(display)
|
||||
self.currentMediaPlayer[controller.controllerType] \
|
||||
.set_visible(display, False)
|
||||
self.currentMediaPlayer[controller.controllerType].set_visible(display, False)
|
||||
|
||||
def media_unblank(self, msg):
|
||||
"""
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
@ -102,8 +102,7 @@ class PhononPlayer(MediaPlayer):
|
||||
ext = u'*%s' % extension
|
||||
if ext not in list:
|
||||
list.append(ext)
|
||||
log.info(u'MediaPlugin: %s extensions: %s' % (mimetype,
|
||||
u' '.join(extensions)))
|
||||
log.info(u'MediaPlugin: %s extensions: %s' % (mimetype, u' '.join(extensions)))
|
||||
# Add extensions for this mimetype from self.additional_extensions.
|
||||
# This hack clears mimetypes' and operating system's shortcomings
|
||||
# by providing possibly missing extensions.
|
||||
@ -112,8 +111,8 @@ class PhononPlayer(MediaPlayer):
|
||||
ext = u'*%s' % extension
|
||||
if ext not in list:
|
||||
list.append(ext)
|
||||
log.info(u'MediaPlugin: %s additional extensions: %s' % (mimetype,
|
||||
u' '.join(self.additional_extensions[mimetype])))
|
||||
log.info(u'MediaPlugin: %s additional extensions: %s' %
|
||||
(mimetype, u' '.join(self.additional_extensions[mimetype])))
|
||||
|
||||
def setup(self, display):
|
||||
display.phononWidget = Phonon.VideoWidget(display)
|
||||
@ -121,8 +120,7 @@ class PhononPlayer(MediaPlayer):
|
||||
display.mediaObject = Phonon.MediaObject(display)
|
||||
Phonon.createPath(display.mediaObject, display.phononWidget)
|
||||
if display.hasAudio:
|
||||
display.audio = Phonon.AudioOutput(
|
||||
Phonon.VideoCategory, display.mediaObject)
|
||||
display.audio = Phonon.AudioOutput(Phonon.VideoCategory, display.mediaObject)
|
||||
Phonon.createPath(display.mediaObject, display.audio)
|
||||
display.phononWidget.raise_()
|
||||
display.phononWidget.hide()
|
||||
@ -173,8 +171,7 @@ class PhononPlayer(MediaPlayer):
|
||||
if start_time > 0:
|
||||
self.seek(display, controller.media_info.start_time * 1000)
|
||||
self.volume(display, controller.media_info.volume)
|
||||
controller.media_info.length = \
|
||||
int(display.mediaObject.totalTime() / 1000)
|
||||
controller.media_info.length = int(display.mediaObject.totalTime() / 1000)
|
||||
controller.seekSlider.setMaximum(controller.media_info.length * 1000)
|
||||
self.state = MediaState.Playing
|
||||
display.phononWidget.raise_()
|
||||
@ -211,13 +208,11 @@ class PhononPlayer(MediaPlayer):
|
||||
display.phononWidget.setVisible(status)
|
||||
|
||||
def update_ui(self, display):
|
||||
if display.mediaObject.state() == Phonon.PausedState and \
|
||||
self.state != MediaState.Paused:
|
||||
if display.mediaObject.state() == Phonon.PausedState and self.state != MediaState.Paused:
|
||||
self.stop(display)
|
||||
controller = display.controller
|
||||
if controller.media_info.end_time > 0:
|
||||
if display.mediaObject.currentTime() > \
|
||||
controller.media_info.end_time * 1000:
|
||||
if display.mediaObject.currentTime() > controller.media_info.end_time * 1000:
|
||||
self.stop(display)
|
||||
self.set_visible(display, False)
|
||||
if not controller.seekSlider.isSliderDown():
|
||||
@ -228,14 +223,13 @@ class PhononPlayer(MediaPlayer):
|
||||
"""
|
||||
Add css style sheets to htmlbuilder
|
||||
"""
|
||||
background = unicode(QtGui.QColor(Settings().value(
|
||||
u'players/background color', QtCore.QVariant(u'#000000'))).name())
|
||||
background = unicode(QtGui.QColor(Settings().value(u'players/background color',
|
||||
QtCore.QVariant(u'#000000'))).name())
|
||||
return VIDEO_CSS % (background,background,background)
|
||||
|
||||
def get_info(self):
|
||||
return(translate('Media.player', 'Phonon is a media player which '
|
||||
'interacts with the operating system to provide media capabilities'
|
||||
'.') +
|
||||
'interacts with the operating system to provide media capabilities.') +
|
||||
u'<br/> <strong>' + translate('Media.player', 'Audio') +
|
||||
u'</strong><br/>' + unicode(self.audio_extensions_list) +
|
||||
u'<br/><strong>' + translate('Media.player', 'Video') +
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
@ -76,8 +76,7 @@ class PlayerTab(SettingsTab):
|
||||
self.formLayout.addRow(self.informationLabel)
|
||||
self.leftLayout.addWidget(self.bgColorGroupBox)
|
||||
self.leftLayout.addStretch()
|
||||
self.rightColumn.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
|
||||
self.rightColumn.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
|
||||
self.rightLayout.addStretch()
|
||||
self.mediaPlayerGroupBox = QtGui.QGroupBox(self.leftColumn)
|
||||
self.mediaPlayerGroupBox.setObjectName(u'mediaPlayerGroupBox')
|
||||
@ -91,28 +90,22 @@ class PlayerTab(SettingsTab):
|
||||
self.playerOrderLayout.setObjectName(u'playerOrderLayout')
|
||||
self.playerOrderlistWidget = QtGui.QListWidget(
|
||||
self.playerOrderGroupBox)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
|
||||
QtGui.QSizePolicy.Expanding)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.playerOrderlistWidget.\
|
||||
sizePolicy().hasHeightForWidth())
|
||||
sizePolicy.setHeightForWidth(self.playerOrderlistWidget.sizePolicy().hasHeightForWidth())
|
||||
self.playerOrderlistWidget.setSizePolicy(sizePolicy)
|
||||
self.playerOrderlistWidget.setVerticalScrollBarPolicy(
|
||||
QtCore.Qt.ScrollBarAsNeeded)
|
||||
self.playerOrderlistWidget.setHorizontalScrollBarPolicy(
|
||||
QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.playerOrderlistWidget.setEditTriggers(
|
||||
QtGui.QAbstractItemView.NoEditTriggers)
|
||||
self.playerOrderlistWidget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
|
||||
self.playerOrderlistWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.playerOrderlistWidget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
|
||||
self.playerOrderlistWidget.setObjectName(u'playerOrderlistWidget')
|
||||
self.playerOrderLayout.addWidget(self.playerOrderlistWidget)
|
||||
self.orderingButtonLayout = QtGui.QVBoxLayout()
|
||||
self.orderingButtonLayout.setObjectName(u'orderingButtonLayout')
|
||||
self.orderingButtonLayout.addStretch(1)
|
||||
self.orderingUpButton = create_button(self, u'orderingUpButton',
|
||||
role=u'up', click=self.onUpButtonClicked)
|
||||
self.orderingDownButton = create_button(self, u'orderingDownButton',
|
||||
role=u'down', click=self.onDownButtonClicked)
|
||||
self.orderingUpButton = create_button(self, u'orderingUpButton', role=u'up', click=self.onUpButtonClicked)
|
||||
self.orderingDownButton = create_button(self, u'orderingDownButton', role=u'down',
|
||||
click=self.onDownButtonClicked)
|
||||
self.orderingButtonLayout.addWidget(self.orderingUpButton)
|
||||
self.orderingButtonLayout.addWidget(self.orderingDownButton)
|
||||
self.orderingButtonLayout.addStretch(1)
|
||||
@ -121,28 +114,23 @@ class PlayerTab(SettingsTab):
|
||||
self.leftLayout.addStretch()
|
||||
self.rightLayout.addStretch()
|
||||
# Signals and slots
|
||||
QtCore.QObject.connect(self.backgroundColorButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onbackgroundColorButtonClicked)
|
||||
QtCore.QObject.connect(self.backgroundColorButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onbackgroundColorButtonClicked)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.mediaPlayerGroupBox.setTitle(
|
||||
translate('OpenLP.PlayerTab', 'Available Media Players'))
|
||||
self.playerOrderGroupBox.setTitle(
|
||||
translate('OpenLP.PlayerTab', 'Player Search Order'))
|
||||
self.mediaPlayerGroupBox.setTitle(translate('OpenLP.PlayerTab', 'Available Media Players'))
|
||||
self.playerOrderGroupBox.setTitle(translate('OpenLP.PlayerTab', 'Player Search Order'))
|
||||
self.bgColorGroupBox.setTitle(UiStrings().BackgroundColor)
|
||||
self.backgroundColorLabel.setText(UiStrings().DefaultColor)
|
||||
self.informationLabel.setText(
|
||||
translate('OpenLP.PlayerTab', 'Visible background for videos '
|
||||
'with aspect ratio different to screen.'))
|
||||
self.informationLabel.setText(translate('OpenLP.PlayerTab',
|
||||
'Visible background for videos with aspect ratio different to screen.'))
|
||||
self.retranslatePlayers()
|
||||
|
||||
def onbackgroundColorButtonClicked(self):
|
||||
new_color = QtGui.QColorDialog.getColor(
|
||||
QtGui.QColor(self.bg_color), self)
|
||||
new_color = QtGui.QColorDialog.getColor(QtGui.QColor(self.bg_color), self)
|
||||
if new_color.isValid():
|
||||
self.bg_color = new_color.name()
|
||||
self.backgroundColorButton.setStyleSheet(
|
||||
u'background-color: %s' % self.bg_color)
|
||||
self.backgroundColorButton.setStyleSheet(u'background-color: %s' % self.bg_color)
|
||||
|
||||
def onPlayerCheckBoxChanged(self, check_state):
|
||||
player = self.sender().playerName
|
||||
@ -163,8 +151,7 @@ class PlayerTab(SettingsTab):
|
||||
self.playerCheckBoxes[u'%s' % player].setEnabled(False)
|
||||
else:
|
||||
self.playerCheckBoxes[u'%s' % player].setEnabled(True)
|
||||
self.playerOrderlistWidget.addItem(
|
||||
self.mediaPlayers[unicode(player)].original_name)
|
||||
self.playerOrderlistWidget.addItem(self.mediaPlayers[unicode(player)].original_name)
|
||||
|
||||
def onUpButtonClicked(self):
|
||||
row = self.playerOrderlistWidget.currentRow()
|
||||
@ -189,16 +176,13 @@ class PlayerTab(SettingsTab):
|
||||
self.usedPlayers = self.savedUsedPlayers
|
||||
self.usedPlayers = get_media_players()[0]
|
||||
self.savedUsedPlayers = self.usedPlayers
|
||||
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settingsSection)
|
||||
self.updatePlayerList()
|
||||
self.bg_color = unicode(settings.value(
|
||||
u'background color', QtCore.QVariant(u'#000000')).toString())
|
||||
self.bg_color = unicode(settings.value(u'background color', QtCore.QVariant(u'#000000')).toString())
|
||||
self.initial_color = self.bg_color
|
||||
settings.endGroup()
|
||||
self.backgroundColorButton.setStyleSheet(
|
||||
u'background-color: %s' % self.bg_color)
|
||||
self.backgroundColorButton.setStyleSheet(u'background-color: %s' % self.bg_color)
|
||||
|
||||
def save(self):
|
||||
player_string_changed = False
|
||||
@ -229,8 +213,7 @@ class PlayerTab(SettingsTab):
|
||||
checkbox.setToolTip(player.get_info())
|
||||
checkbox.setPlayerName(player.name)
|
||||
self.playerCheckBoxes[player.name] = checkbox
|
||||
QtCore.QObject.connect(checkbox,QtCore.SIGNAL(u'stateChanged(int)'),
|
||||
self.onPlayerCheckBoxChanged)
|
||||
QtCore.QObject.connect(checkbox,QtCore.SIGNAL(u'stateChanged(int)'), self.onPlayerCheckBoxChanged)
|
||||
self.mediaPlayerLayout.addWidget(checkbox)
|
||||
if player.available and player.name in self.usedPlayers:
|
||||
checkbox.setChecked(True)
|
||||
@ -250,6 +233,4 @@ class PlayerTab(SettingsTab):
|
||||
if player.available:
|
||||
checkbox.setText(player.display_name)
|
||||
else:
|
||||
checkbox.setText(
|
||||
unicode(translate('OpenLP.PlayerTab',
|
||||
'%s (unavailable)')) % player.display_name)
|
||||
checkbox.setText(unicode(translate('OpenLP.PlayerTab', '%s (unavailable)')) % player.display_name)
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
@ -114,8 +114,7 @@ class VlcPlayer(MediaPlayer):
|
||||
command_line_options = u'--no-video-title-show'
|
||||
if not display.hasAudio:
|
||||
command_line_options += u' --no-audio --no-video-title-show'
|
||||
if Settings().value(u'advanced/hide mouse',
|
||||
QtCore.QVariant(True)).toBool() and display.controller.isLive:
|
||||
if Settings().value(u'advanced/hide mouse', QtCore.QVariant(True)).toBool() and display.controller.isLive:
|
||||
command_line_options += u' --mouse-hide-timeout=0'
|
||||
display.vlcInstance = vlc.Instance(command_line_options)
|
||||
display.vlcInstance.set_log_verbosity(2)
|
||||
@ -148,8 +147,7 @@ class VlcPlayer(MediaPlayer):
|
||||
log.debug(u'load vid in Vlc Controller')
|
||||
controller = display.controller
|
||||
volume = controller.media_info.volume
|
||||
file_path = str(
|
||||
controller.media_info.file_info.absoluteFilePath().toUtf8())
|
||||
file_path = str(controller.media_info.file_info.absoluteFilePath().toUtf8())
|
||||
path = os.path.normcase(file_path)
|
||||
# create the media
|
||||
display.vlcMedia = display.vlcInstance.media_new_path(path)
|
||||
@ -163,8 +161,7 @@ class VlcPlayer(MediaPlayer):
|
||||
# and once to just get media length.
|
||||
#
|
||||
# Media plugin depends on knowing media length before playback.
|
||||
controller.media_info.length = \
|
||||
int(display.vlcMediaPlayer.get_media().get_duration() / 1000)
|
||||
controller.media_info.length = int(display.vlcMediaPlayer.get_media().get_duration() / 1000)
|
||||
return True
|
||||
|
||||
def media_state_wait(self, display, mediaState):
|
||||
@ -187,16 +184,14 @@ class VlcPlayer(MediaPlayer):
|
||||
def play(self, display):
|
||||
controller = display.controller
|
||||
start_time = 0
|
||||
if self.state != MediaState.Paused and \
|
||||
controller.media_info.start_time > 0:
|
||||
if self.state != MediaState.Paused and controller.media_info.start_time > 0:
|
||||
start_time = controller.media_info.start_time
|
||||
display.vlcMediaPlayer.play()
|
||||
if not self.media_state_wait(display, vlc.State.Playing):
|
||||
return False
|
||||
if start_time > 0:
|
||||
self.seek(display, controller.media_info.start_time * 1000)
|
||||
controller.media_info.length = \
|
||||
int(display.vlcMediaPlayer.get_media().get_duration() / 1000)
|
||||
controller.media_info.length = int(display.vlcMediaPlayer.get_media().get_duration() / 1000)
|
||||
controller.seekSlider.setMaximum(controller.media_info.length * 1000)
|
||||
self.state = MediaState.Playing
|
||||
display.vlcWidget.raise_()
|
||||
@ -236,13 +231,11 @@ class VlcPlayer(MediaPlayer):
|
||||
self.stop(display)
|
||||
controller = display.controller
|
||||
if controller.media_info.end_time > 0:
|
||||
if display.vlcMediaPlayer.get_time() > \
|
||||
controller.media_info.end_time * 1000:
|
||||
if display.vlcMediaPlayer.get_time() > controller.media_info.end_time * 1000:
|
||||
self.stop(display)
|
||||
self.set_visible(display, False)
|
||||
if not controller.seekSlider.isSliderDown():
|
||||
controller.seekSlider.setSliderPosition( \
|
||||
display.vlcMediaPlayer.get_time())
|
||||
controller.seekSlider.setSliderPosition(display.vlcMediaPlayer.get_time())
|
||||
|
||||
def get_info(self):
|
||||
return(translate('Media.player', 'VLC is an external player which '
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
@ -283,8 +283,8 @@ class WebkitPlayer(MediaPlayer):
|
||||
"""
|
||||
Add css style sheets to htmlbuilder
|
||||
"""
|
||||
background = unicode(QtGui.QColor(Settings().value(
|
||||
u'players/background color', QtCore.QVariant(u'#000000'))).name())
|
||||
background = unicode(QtGui.QColor(Settings().value(u'players/background color',
|
||||
QtCore.QVariant(u'#000000'))).name())
|
||||
css = VIDEO_CSS % (background,background,background)
|
||||
return css + FLASH_CSS
|
||||
|
||||
@ -324,11 +324,9 @@ class WebkitPlayer(MediaPlayer):
|
||||
display.webView.setVisible(True)
|
||||
if controller.media_info.file_info.suffix() == u'swf':
|
||||
controller.media_info.is_flash = True
|
||||
js = u'show_flash("load","%s");' % \
|
||||
(path.replace(u'\\', u'\\\\'))
|
||||
js = u'show_flash("load","%s");' % (path.replace(u'\\', u'\\\\'))
|
||||
else:
|
||||
js = u'show_video("init", "%s", %s, %s);' % \
|
||||
(path.replace(u'\\', u'\\\\'), str(vol), loop)
|
||||
js = u'show_video("init", "%s", %s, %s);' % (path.replace(u'\\', u'\\\\'), str(vol), loop)
|
||||
display.frame.evaluateJavaScript(js)
|
||||
return True
|
||||
|
||||
@ -340,8 +338,7 @@ class WebkitPlayer(MediaPlayer):
|
||||
display.webLoaded = True
|
||||
length = 0
|
||||
start_time = 0
|
||||
if self.state != MediaState.Paused and \
|
||||
controller.media_info.start_time > 0:
|
||||
if self.state != MediaState.Paused and controller.media_info.start_time > 0:
|
||||
start_time = controller.media_info.start_time
|
||||
self.set_visible(display, True)
|
||||
if controller.media_info.is_flash:
|
||||
@ -407,19 +404,15 @@ class WebkitPlayer(MediaPlayer):
|
||||
else:
|
||||
is_visible = "hidden"
|
||||
if controller.media_info.is_flash:
|
||||
display.frame.evaluateJavaScript(u'show_flash( \
|
||||
"setVisible", null, null, "%s");' % (is_visible))
|
||||
display.frame.evaluateJavaScript(u'show_flash("setVisible", null, null, "%s");' % (is_visible))
|
||||
else:
|
||||
display.frame.evaluateJavaScript(u'show_video( \
|
||||
"setVisible", null, null, null, "%s");' % (is_visible))
|
||||
display.frame.evaluateJavaScript(u'show_video("setVisible", null, null, null, "%s");' % (is_visible))
|
||||
|
||||
def update_ui(self, display):
|
||||
controller = display.controller
|
||||
if controller.media_info.is_flash:
|
||||
currentTime = display.frame.evaluateJavaScript(
|
||||
u'show_flash("currentTime");').toInt()[0]
|
||||
length = display.frame.evaluateJavaScript(
|
||||
u'show_flash("length");').toInt()[0]
|
||||
currentTime = display.frame.evaluateJavaScript(u'show_flash("currentTime");').toInt()[0]
|
||||
length = display.frame.evaluateJavaScript(u'show_flash("length");').toInt()[0]
|
||||
else:
|
||||
if display.frame.evaluateJavaScript(
|
||||
u'show_video("isEnded");').toString() == 'true':
|
||||
@ -429,8 +422,7 @@ class WebkitPlayer(MediaPlayer):
|
||||
# check if conversion was ok and value is not 'NaN'
|
||||
if ok and currentTime != float('inf'):
|
||||
currentTime = int(currentTime * 1000)
|
||||
(length, ok) = display.frame.evaluateJavaScript(
|
||||
u'show_video("length");').toFloat()
|
||||
(length, ok) = display.frame.evaluateJavaScript(u'show_video("length");').toFloat()
|
||||
# check if conversion was ok and value is not 'NaN'
|
||||
if ok and length != float('inf'):
|
||||
length = int(length * 1000)
|
||||
|
Loading…
Reference in New Issue
Block a user