2011-06-05 21:10:49 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-04-13 13:00:22 +00:00
|
|
|
##########################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# ---------------------------------------------------------------------- #
|
|
|
|
# Copyright (c) 2008-2019 OpenLP Developers #
|
|
|
|
# ---------------------------------------------------------------------- #
|
|
|
|
# This program is free software: you can redistribute it and/or modify #
|
|
|
|
# it under the terms of the GNU General Public License as published by #
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or #
|
|
|
|
# (at your option) any later version. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, #
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
|
|
# GNU General Public License for more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License #
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
|
|
|
##########################################################################
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2019-04-12 21:03:23 +00:00
|
|
|
The :mod:`~openlp.core.ui.media.mediacontroller` module is the control module for all media playing.
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2011-06-05 21:10:49 +00:00
|
|
|
import logging
|
2018-10-20 14:41:32 +00:00
|
|
|
|
|
|
|
try:
|
2018-11-04 17:13:56 +00:00
|
|
|
from pymediainfo import MediaInfo
|
2018-10-20 14:41:32 +00:00
|
|
|
pymediainfo_available = True
|
|
|
|
except ImportError:
|
|
|
|
pymediainfo_available = False
|
|
|
|
|
|
|
|
from subprocess import check_output
|
2019-03-24 07:53:19 +00:00
|
|
|
from PyQt5 import QtCore
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2018-10-20 14:41:32 +00:00
|
|
|
from openlp.core.state import State
|
2016-08-12 19:16:39 +00:00
|
|
|
from openlp.core.api.http import register_endpoint
|
2018-10-20 14:41:32 +00:00
|
|
|
from openlp.core.common.i18n import translate
|
2017-10-23 22:09:57 +00:00
|
|
|
from openlp.core.common.mixins import LogMixin, RegistryProperties
|
|
|
|
from openlp.core.common.registry import Registry, RegistryBase
|
2017-10-07 07:05:07 +00:00
|
|
|
from openlp.core.common.settings import Settings
|
2018-08-25 14:08:19 +00:00
|
|
|
from openlp.core.lib.serviceitem import ItemCapabilities
|
2013-01-11 00:19:11 +00:00
|
|
|
from openlp.core.lib.ui import critical_error_message_box
|
2012-10-20 19:52:04 +00:00
|
|
|
from openlp.core.ui import DisplayControllerType
|
2019-06-11 18:40:20 +00:00
|
|
|
from openlp.core.ui.media import MediaState, ItemMediaInfo, MediaType, parse_optical_path, VIDEO_EXT, AUDIO_EXT
|
2016-08-12 19:16:39 +00:00
|
|
|
from openlp.core.ui.media.endpoint import media_endpoint
|
2019-06-11 18:40:20 +00:00
|
|
|
from openlp.core.ui.media.vlcplayer import VlcPlayer, get_vlc
|
2011-06-05 21:10:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2015-12-20 21:30:47 +00:00
|
|
|
TICK_TIME = 200
|
|
|
|
|
2013-02-02 06:32:29 +00:00
|
|
|
|
2017-10-23 22:09:57 +00:00
|
|
|
class MediaController(RegistryBase, LogMixin, RegistryProperties):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2019-09-21 04:56:43 +00:00
|
|
|
The implementation of the Media Controller which manages how media is played.
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2018-10-13 10:24:01 +00:00
|
|
|
|
|
|
|
def setup(self):
|
2018-11-04 17:13:56 +00:00
|
|
|
self.vlc_player = None
|
2013-03-06 17:46:19 +00:00
|
|
|
self.current_media_players = {}
|
2011-08-29 19:55:58 +00:00
|
|
|
# Timer for video state
|
2016-02-16 21:14:38 +00:00
|
|
|
self.live_timer = QtCore.QTimer()
|
|
|
|
self.live_timer.setInterval(TICK_TIME)
|
|
|
|
self.preview_timer = QtCore.QTimer()
|
|
|
|
self.preview_timer.setInterval(TICK_TIME)
|
2011-08-29 19:55:58 +00:00
|
|
|
# Signals
|
2016-02-16 21:14:38 +00:00
|
|
|
self.live_timer.timeout.connect(self.media_state_live)
|
|
|
|
self.preview_timer.timeout.connect(self.media_state_preview)
|
2013-08-31 18:17:38 +00:00
|
|
|
Registry().register_function('playbackPlay', self.media_play_msg)
|
|
|
|
Registry().register_function('playbackPause', self.media_pause_msg)
|
|
|
|
Registry().register_function('playbackStop', self.media_stop_msg)
|
2016-02-14 08:38:21 +00:00
|
|
|
Registry().register_function('playbackLoop', self.media_loop_msg)
|
2013-08-31 18:17:38 +00:00
|
|
|
Registry().register_function('seek_slider', self.media_seek_msg)
|
|
|
|
Registry().register_function('volume_slider', self.media_volume_msg)
|
|
|
|
Registry().register_function('media_hide', self.media_hide)
|
|
|
|
Registry().register_function('media_blank', self.media_blank)
|
|
|
|
Registry().register_function('media_unblank', self.media_unblank)
|
2011-09-28 20:54:43 +00:00
|
|
|
# Signals for background video
|
2013-08-31 18:17:38 +00:00
|
|
|
Registry().register_function('songs_hide', self.media_hide)
|
2017-06-25 17:03:31 +00:00
|
|
|
Registry().register_function('songs_blank', self.media_blank)
|
2013-08-31 18:17:38 +00:00
|
|
|
Registry().register_function('songs_unblank', self.media_unblank)
|
2016-08-12 19:16:39 +00:00
|
|
|
register_endpoint(media_endpoint)
|
2011-11-24 21:10:37 +00:00
|
|
|
|
2013-12-31 20:29:03 +00:00
|
|
|
def bootstrap_initialise(self):
|
2011-07-10 21:43:07 +00:00
|
|
|
"""
|
2012-10-20 19:52:04 +00:00
|
|
|
Check to see if we have any media Player's available.
|
2011-07-10 21:43:07 +00:00
|
|
|
"""
|
2018-10-13 10:24:01 +00:00
|
|
|
self.setup()
|
2018-11-04 17:13:56 +00:00
|
|
|
self.vlc_player = VlcPlayer(self)
|
2019-04-12 21:03:23 +00:00
|
|
|
State().add_service('mediacontroller', 0)
|
2019-04-20 20:29:12 +00:00
|
|
|
State().add_service('media_live', 0)
|
2019-09-21 04:56:43 +00:00
|
|
|
getvlc = get_vlc()
|
|
|
|
if getvlc and pymediainfo_available:
|
2019-04-12 21:03:23 +00:00
|
|
|
State().update_pre_conditions('mediacontroller', True)
|
2019-04-09 16:47:23 +00:00
|
|
|
State().update_pre_conditions('media_live', True)
|
2018-11-04 17:13:56 +00:00
|
|
|
else:
|
2019-01-30 07:18:03 +00:00
|
|
|
if hasattr(self.main_window, 'splash') and self.main_window.splash.isVisible():
|
|
|
|
self.main_window.splash.hide()
|
2019-09-21 04:56:43 +00:00
|
|
|
text_vlc = translate('OpenLP.MediaController',
|
|
|
|
'The media integration library is missing (python - vlc is not installed)')
|
|
|
|
text_info = translate('OpenLP.MediaController',
|
|
|
|
'The media integration library is missing (python - pymediainfo is not installed)')
|
|
|
|
if not getvlc and not pymediainfo_available:
|
|
|
|
State().missing_text('media_live', "{text}\n{base}".format(text=text_vlc, base=text_info))
|
|
|
|
if getvlc and not pymediainfo_available:
|
|
|
|
State().missing_text('media_live', "{text}".format(text=text_info))
|
|
|
|
if not getvlc and pymediainfo_available:
|
|
|
|
State().missing_text('media_live', "{text}".format(text=text_vlc))
|
2012-04-28 11:13:16 +00:00
|
|
|
return True
|
2011-07-10 21:43:07 +00:00
|
|
|
|
2019-03-24 07:53:19 +00:00
|
|
|
def bootstrap_post_set_up(self):
|
|
|
|
"""
|
|
|
|
Set up the controllers.
|
|
|
|
:return:
|
|
|
|
"""
|
2019-05-05 05:59:29 +00:00
|
|
|
if State().check_preconditions('mediacontroller'):
|
|
|
|
try:
|
|
|
|
self.setup_display(self.live_controller.display, False)
|
|
|
|
except AttributeError:
|
|
|
|
State().update_pre_conditions('media_live', False)
|
2019-09-23 20:07:46 +00:00
|
|
|
State().missing_text('media_live', translate(
|
|
|
|
'OpenLP.MediaController',
|
|
|
|
'No Displays have been configured, so Live Media has been disabled'))
|
2019-05-05 05:59:29 +00:00
|
|
|
self.setup_display(self.preview_controller.preview_display, True)
|
2019-03-24 07:53:19 +00:00
|
|
|
|
|
|
|
def display_controllers(self, controller_type):
|
|
|
|
"""
|
|
|
|
Decides which controller to use.
|
|
|
|
|
|
|
|
:param controller_type: The controller type where a player will be placed
|
|
|
|
"""
|
|
|
|
if controller_type == DisplayControllerType.Live:
|
|
|
|
return self.live_controller
|
2019-09-21 04:56:43 +00:00
|
|
|
return self.preview_controller
|
2019-03-24 07:53:19 +00:00
|
|
|
|
2016-02-16 21:14:38 +00:00
|
|
|
def media_state_live(self):
|
2016-02-21 09:29:16 +00:00
|
|
|
"""
|
|
|
|
Check if there is a running Live media Player and do updating stuff (e.g. update the UI)
|
|
|
|
"""
|
2019-03-24 07:53:19 +00:00
|
|
|
display = self._define_display(self.display_controllers(DisplayControllerType.Live))
|
2016-03-07 21:52:09 +00:00
|
|
|
if DisplayControllerType.Live in self.current_media_players:
|
2016-02-21 09:29:16 +00:00
|
|
|
self.current_media_players[DisplayControllerType.Live].resize(display)
|
2019-03-24 07:53:19 +00:00
|
|
|
self.current_media_players[DisplayControllerType.Live].update_ui(self.live_controller, display)
|
|
|
|
self.tick(self.display_controllers(DisplayControllerType.Live))
|
2016-02-26 16:00:04 +00:00
|
|
|
if self.current_media_players[DisplayControllerType.Live].get_live_state() is not MediaState.Playing:
|
2016-02-21 09:29:16 +00:00
|
|
|
self.live_timer.stop()
|
2016-02-26 16:00:04 +00:00
|
|
|
else:
|
|
|
|
self.live_timer.stop()
|
2019-03-24 07:53:19 +00:00
|
|
|
self.media_stop(self.display_controllers(DisplayControllerType.Live))
|
|
|
|
if self.display_controllers(DisplayControllerType.Live).media_info.can_loop_playback:
|
|
|
|
self.media_play(self.display_controllers(DisplayControllerType.Live), True)
|
2016-02-16 21:14:38 +00:00
|
|
|
|
|
|
|
def media_state_preview(self):
|
2016-02-21 09:29:16 +00:00
|
|
|
"""
|
|
|
|
Check if there is a running Preview media Player and do updating stuff (e.g. update the UI)
|
|
|
|
"""
|
2019-03-24 07:53:19 +00:00
|
|
|
display = self._define_display(self.display_controllers(DisplayControllerType.Preview))
|
2016-03-07 21:52:09 +00:00
|
|
|
if DisplayControllerType.Preview in self.current_media_players:
|
2016-02-21 09:29:16 +00:00
|
|
|
self.current_media_players[DisplayControllerType.Preview].resize(display)
|
2019-03-24 07:53:19 +00:00
|
|
|
self.current_media_players[DisplayControllerType.Preview].update_ui(self.preview_controller, display)
|
|
|
|
self.tick(self.display_controllers(DisplayControllerType.Preview))
|
2016-02-26 16:00:04 +00:00
|
|
|
if self.current_media_players[DisplayControllerType.Preview].get_preview_state() is not MediaState.Playing:
|
2016-02-21 09:29:16 +00:00
|
|
|
self.preview_timer.stop()
|
2011-06-05 21:10:49 +00:00
|
|
|
else:
|
2016-02-26 16:00:04 +00:00
|
|
|
self.preview_timer.stop()
|
2019-03-24 07:53:19 +00:00
|
|
|
self.media_stop(self.display_controllers(DisplayControllerType.Preview))
|
|
|
|
if self.display_controllers(DisplayControllerType.Preview).media_info.can_loop_playback:
|
|
|
|
self.media_play(self.display_controllers(DisplayControllerType.Preview), True)
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2012-10-20 19:52:04 +00:00
|
|
|
def setup_display(self, display, preview):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2014-03-17 19:05:55 +00:00
|
|
|
After a new display is configured, all media related widgets will be created too
|
2012-10-13 20:54:56 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param display: Display on which the output is to be played
|
|
|
|
:param preview: Whether the display is a main or preview display
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2019-03-24 07:53:19 +00:00
|
|
|
display.media_info = ItemMediaInfo()
|
2013-03-06 22:54:16 +00:00
|
|
|
display.has_audio = True
|
2019-03-24 07:53:19 +00:00
|
|
|
# if display.is_live and preview:
|
|
|
|
# return
|
2012-10-20 19:52:04 +00:00
|
|
|
if preview:
|
2013-03-06 22:54:16 +00:00
|
|
|
display.has_audio = False
|
2019-03-24 07:53:19 +00:00
|
|
|
self.vlc_player.setup(display, preview)
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2019-06-14 17:54:04 +00:00
|
|
|
@staticmethod
|
|
|
|
def set_controls_visible(controller, value):
|
2012-10-13 20:54:56 +00:00
|
|
|
"""
|
2014-03-17 19:05:55 +00:00
|
|
|
After a new display is configured, all media related widget will be created too
|
2012-10-13 20:54:56 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param controller: The controller on which controls act.
|
|
|
|
:param value: control name to be changed.
|
2012-10-13 20:54:56 +00:00
|
|
|
"""
|
2011-06-05 21:10:49 +00:00
|
|
|
# Generic controls
|
|
|
|
controller.mediabar.setVisible(value)
|
|
|
|
|
2016-02-14 15:43:54 +00:00
|
|
|
@staticmethod
|
|
|
|
def resize(display, player):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2014-03-17 19:05:55 +00:00
|
|
|
After Mainwindow changes or Splitter moved all related media widgets have to be resized
|
2012-10-13 20:54:56 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param display: The display on which output is playing.
|
|
|
|
:param player: The player which is doing the playing.
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2011-11-11 16:45:25 +00:00
|
|
|
player.resize(display)
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2019-03-24 07:53:19 +00:00
|
|
|
def load_video(self, source, service_item, hidden=False, video_behind_text=False):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
|
|
|
Loads and starts a video to run with the option of sound
|
2012-10-13 20:54:56 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param source: Where the call originated form
|
|
|
|
:param service_item: The player which is doing the playing
|
|
|
|
:param hidden: The player which is doing the playing
|
|
|
|
:param video_behind_text: Is the video to be played behind text.
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2018-11-01 20:51:42 +00:00
|
|
|
is_valid = True
|
2019-03-24 07:53:19 +00:00
|
|
|
controller = self.display_controllers(source)
|
2011-06-05 21:10:49 +00:00
|
|
|
# stop running videos
|
2012-10-15 18:38:58 +00:00
|
|
|
self.media_reset(controller)
|
2018-11-18 17:29:47 +00:00
|
|
|
controller.media_info = ItemMediaInfo()
|
2013-03-23 07:07:06 +00:00
|
|
|
controller.media_info.volume = controller.volume_slider.value()
|
2013-03-06 22:50:49 +00:00
|
|
|
controller.media_info.is_background = video_behind_text
|
2016-02-14 15:43:54 +00:00
|
|
|
# background will always loop video.
|
2016-04-13 18:38:49 +00:00
|
|
|
controller.media_info.can_loop_playback = video_behind_text
|
2018-10-21 15:35:59 +00:00
|
|
|
if service_item.is_capable(ItemCapabilities.HasBackgroundAudio):
|
|
|
|
controller.media_info.file_info = service_item.background_audio
|
|
|
|
else:
|
2018-11-01 20:51:42 +00:00
|
|
|
controller.media_info.file_info = [service_item.get_frame_path()]
|
2012-10-29 17:25:08 +00:00
|
|
|
display = self._define_display(controller)
|
2013-02-20 20:43:20 +00:00
|
|
|
if controller.is_live:
|
2014-03-04 22:33:50 +00:00
|
|
|
# if this is an optical device use special handling
|
2019-06-11 19:48:34 +00:00
|
|
|
if service_item.is_capable(ItemCapabilities.CanStream):
|
2019-06-12 18:04:47 +00:00
|
|
|
is_valid = self._check_file_type(controller, display, True)
|
2019-06-11 19:48:34 +00:00
|
|
|
controller.media_info.media_type = MediaType.Stream
|
|
|
|
elif service_item.is_capable(ItemCapabilities.IsOptical):
|
2014-03-04 22:33:50 +00:00
|
|
|
log.debug('video is optical and live')
|
|
|
|
path = service_item.get_frame_path()
|
2014-06-14 21:48:07 +00:00
|
|
|
(name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(path)
|
2014-04-22 20:42:07 +00:00
|
|
|
is_valid = self.media_setup_optical(name, title, audio_track, subtitle_track, start, end, display,
|
|
|
|
controller)
|
2014-03-26 18:39:54 +00:00
|
|
|
else:
|
2014-03-04 22:33:50 +00:00
|
|
|
log.debug('video is not optical and live')
|
2016-01-24 10:13:33 +00:00
|
|
|
controller.media_info.length = service_item.media_length
|
2018-11-18 17:29:47 +00:00
|
|
|
is_valid = self._check_file_type(controller, display)
|
2019-03-27 17:46:12 +00:00
|
|
|
# display.override['theme'] = ''
|
|
|
|
# display.override['video'] = True
|
2011-12-06 21:42:34 +00:00
|
|
|
if controller.media_info.is_background:
|
|
|
|
# ignore start/end time
|
|
|
|
controller.media_info.start_time = 0
|
|
|
|
controller.media_info.end_time = 0
|
|
|
|
else:
|
2013-03-06 22:23:01 +00:00
|
|
|
controller.media_info.start_time = service_item.start_time
|
|
|
|
controller.media_info.end_time = service_item.end_time
|
2013-03-04 16:55:13 +00:00
|
|
|
elif controller.preview_display:
|
2019-06-11 19:48:34 +00:00
|
|
|
if service_item.is_capable(ItemCapabilities.CanStream):
|
|
|
|
controller.media_info.media_type = MediaType.Stream
|
2019-06-12 18:04:47 +00:00
|
|
|
is_valid = self._check_file_type(controller, display, True)
|
2019-06-11 19:48:34 +00:00
|
|
|
elif service_item.is_capable(ItemCapabilities.IsOptical):
|
2014-03-04 22:33:50 +00:00
|
|
|
log.debug('video is optical and preview')
|
|
|
|
path = service_item.get_frame_path()
|
2014-06-14 21:48:07 +00:00
|
|
|
(name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(path)
|
2014-04-22 20:42:07 +00:00
|
|
|
is_valid = self.media_setup_optical(name, title, audio_track, subtitle_track, start, end, display,
|
|
|
|
controller)
|
2014-03-26 18:39:54 +00:00
|
|
|
else:
|
2014-03-04 22:33:50 +00:00
|
|
|
log.debug('video is not optical and preview')
|
2016-01-24 10:13:33 +00:00
|
|
|
controller.media_info.length = service_item.media_length
|
2018-11-18 17:29:47 +00:00
|
|
|
is_valid = self._check_file_type(controller, display)
|
2013-03-06 22:49:13 +00:00
|
|
|
if not is_valid:
|
2011-08-29 19:55:58 +00:00
|
|
|
# Media could not be loaded correctly
|
2012-12-11 19:55:47 +00:00
|
|
|
critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
2014-03-20 19:10:31 +00:00
|
|
|
translate('MediaPlugin.MediaItem', 'Unsupported File'))
|
2011-07-18 21:25:10 +00:00
|
|
|
return False
|
2019-09-21 04:56:43 +00:00
|
|
|
log.debug('video media type: {tpe} '.format(tpe=str(controller.media_info.media_type)))
|
2011-11-24 21:10:37 +00:00
|
|
|
# dont care about actual theme, set a black background
|
2012-09-07 16:58:13 +00:00
|
|
|
# now start playing - Preview is autoplay!
|
|
|
|
autoplay = False
|
2019-06-14 17:54:04 +00:00
|
|
|
if service_item.is_capable(ItemCapabilities.CanStream):
|
|
|
|
autoplay = True
|
2012-09-07 16:58:13 +00:00
|
|
|
# Preview requested
|
2013-02-20 20:43:20 +00:00
|
|
|
if not controller.is_live:
|
2012-09-07 16:58:13 +00:00
|
|
|
autoplay = True
|
2012-11-04 20:11:10 +00:00
|
|
|
# Visible or background requested or Service Item wants to autostart
|
2013-03-06 22:23:01 +00:00
|
|
|
elif not hidden or controller.media_info.is_background or service_item.will_auto_start:
|
2012-09-07 16:58:13 +00:00
|
|
|
autoplay = True
|
|
|
|
# Unblank on load set
|
2013-08-31 18:17:38 +00:00
|
|
|
elif Settings().value('core/auto unblank'):
|
2012-09-07 16:58:13 +00:00
|
|
|
autoplay = True
|
|
|
|
if autoplay:
|
2012-10-26 20:20:23 +00:00
|
|
|
if not self.media_play(controller):
|
2012-12-11 19:55:47 +00:00
|
|
|
critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
2014-03-20 19:10:31 +00:00
|
|
|
translate('MediaPlugin.MediaItem', 'Unsupported File'))
|
2012-09-08 18:29:05 +00:00
|
|
|
return False
|
2011-12-01 18:07:15 +00:00
|
|
|
self.set_controls_visible(controller, True)
|
2019-09-21 04:56:43 +00:00
|
|
|
log.debug('use {nm} controller'.format(nm=self.current_media_players[controller.controller_type].display_name))
|
2011-12-01 18:07:15 +00:00
|
|
|
return True
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2018-03-18 15:33:50 +00:00
|
|
|
@staticmethod
|
2018-10-21 15:35:59 +00:00
|
|
|
def media_length(media_path):
|
2012-09-09 06:54:09 +00:00
|
|
|
"""
|
2018-03-18 15:33:50 +00:00
|
|
|
Uses Media Info to obtain the media length
|
2012-09-14 16:35:07 +00:00
|
|
|
|
2018-11-01 20:51:42 +00:00
|
|
|
:param media_path: The file path to be checked..
|
2012-09-09 06:54:09 +00:00
|
|
|
"""
|
2018-11-04 17:13:56 +00:00
|
|
|
if MediaInfo.can_parse():
|
|
|
|
media_data = MediaInfo.parse(media_path)
|
2018-10-20 14:41:32 +00:00
|
|
|
else:
|
2018-11-01 20:51:42 +00:00
|
|
|
xml = check_output(['mediainfo', '-f', '--Output=XML', '--Inform=OLDXML', media_path])
|
2018-10-20 14:41:32 +00:00
|
|
|
if not xml.startswith(b'<?xml'):
|
2018-11-01 20:51:42 +00:00
|
|
|
xml = check_output(['mediainfo', '-f', '--Output=XML', media_path])
|
2018-11-04 17:13:56 +00:00
|
|
|
media_data = MediaInfo(xml.decode("utf-8"))
|
2016-01-24 10:13:33 +00:00
|
|
|
# duration returns in milli seconds
|
2018-10-21 15:35:59 +00:00
|
|
|
return media_data.tracks[0].duration
|
2012-09-09 06:54:09 +00:00
|
|
|
|
2014-03-04 22:33:50 +00:00
|
|
|
def media_setup_optical(self, filename, title, audio_track, subtitle_track, start, end, display, controller):
|
2014-06-14 21:48:07 +00:00
|
|
|
"""
|
|
|
|
Setup playback of optical media
|
|
|
|
|
|
|
|
:param filename: Path of the optical device/drive.
|
|
|
|
:param title: The main/title track to play.
|
|
|
|
:param audio_track: The audio track to play.
|
|
|
|
:param subtitle_track: The subtitle track to play.
|
2016-02-14 15:43:54 +00:00
|
|
|
:param start: Start position in milliseconds.
|
|
|
|
:param end: End position in milliseconds.
|
2014-06-14 21:48:07 +00:00
|
|
|
:param display: The display to play the media.
|
2016-02-14 15:43:54 +00:00
|
|
|
:param controller: The media controller.
|
|
|
|
:return: True if setup succeeded else False.
|
2014-06-14 21:48:07 +00:00
|
|
|
"""
|
2014-03-04 22:33:50 +00:00
|
|
|
# stop running videos
|
|
|
|
self.media_reset(controller)
|
|
|
|
# Setup media info
|
2018-11-18 17:29:47 +00:00
|
|
|
controller.media_info = ItemMediaInfo()
|
2014-03-04 22:33:50 +00:00
|
|
|
controller.media_info.file_info = QtCore.QFileInfo(filename)
|
2014-05-23 13:39:25 +00:00
|
|
|
if audio_track == -1 and subtitle_track == -1:
|
|
|
|
controller.media_info.media_type = MediaType.CD
|
|
|
|
else:
|
|
|
|
controller.media_info.media_type = MediaType.DVD
|
2017-11-22 21:56:56 +00:00
|
|
|
controller.media_info.start_time = start
|
|
|
|
controller.media_info.end_time = end
|
|
|
|
controller.media_info.length = (end - start)
|
2014-03-04 22:33:50 +00:00
|
|
|
controller.media_info.title_track = title
|
|
|
|
controller.media_info.audio_track = audio_track
|
|
|
|
controller.media_info.subtitle_track = subtitle_track
|
|
|
|
# When called from mediaitem display is None
|
|
|
|
if display is None:
|
|
|
|
display = controller.preview_display
|
2019-02-13 20:28:10 +00:00
|
|
|
self.vlc_player.load(display, filename)
|
2018-11-04 17:13:56 +00:00
|
|
|
self.resize(display, self.vlc_player)
|
|
|
|
self.current_media_players[controller.controller_type] = self.vlc_player
|
2014-05-23 13:39:25 +00:00
|
|
|
if audio_track == -1 and subtitle_track == -1:
|
|
|
|
controller.media_info.media_type = MediaType.CD
|
|
|
|
else:
|
|
|
|
controller.media_info.media_type = MediaType.DVD
|
2014-03-04 22:33:50 +00:00
|
|
|
return True
|
|
|
|
|
2019-06-12 18:04:47 +00:00
|
|
|
def _check_file_type(self, controller, display, stream=False):
|
2016-02-13 22:10:11 +00:00
|
|
|
"""
|
|
|
|
Select the correct media Player type from the prioritized Player list
|
|
|
|
|
|
|
|
:param controller: First element is the controller which should be used
|
|
|
|
:param display: Which display to use
|
2019-06-12 18:04:47 +00:00
|
|
|
:param stream: Are we streaming or not
|
2016-02-13 22:10:11 +00:00
|
|
|
"""
|
2019-06-12 18:04:47 +00:00
|
|
|
if stream:
|
2019-06-11 19:48:34 +00:00
|
|
|
self.resize(display, self.vlc_player)
|
2019-06-12 18:04:47 +00:00
|
|
|
display.media_info.media_type = MediaType.Stream
|
2019-06-11 19:48:34 +00:00
|
|
|
if self.vlc_player.load(display, None):
|
|
|
|
self.current_media_players[controller.controller_type] = self.vlc_player
|
|
|
|
return True
|
2019-06-12 18:04:47 +00:00
|
|
|
return True
|
2018-11-01 20:51:42 +00:00
|
|
|
for file in controller.media_info.file_info:
|
|
|
|
if file.is_file:
|
|
|
|
suffix = '*%s' % file.suffix.lower()
|
|
|
|
file = str(file)
|
2019-05-26 10:30:37 +00:00
|
|
|
if suffix in VIDEO_EXT:
|
2018-11-01 20:51:42 +00:00
|
|
|
if not controller.media_info.is_background or controller.media_info.is_background and \
|
2019-03-24 07:53:19 +00:00
|
|
|
self.vlc_player.can_background:
|
|
|
|
self.resize(display, self.vlc_player)
|
|
|
|
if self.vlc_player.load(display, file):
|
|
|
|
self.current_media_players[controller.controller_type] = self.vlc_player
|
2018-11-01 20:51:42 +00:00
|
|
|
controller.media_info.media_type = MediaType.Video
|
|
|
|
return True
|
2019-05-26 10:30:37 +00:00
|
|
|
if suffix in AUDIO_EXT:
|
2019-03-24 07:53:19 +00:00
|
|
|
if self.vlc_player.load(display, file):
|
|
|
|
self.current_media_players[controller.controller_type] = self.vlc_player
|
2018-11-01 20:51:42 +00:00
|
|
|
controller.media_info.media_type = MediaType.Audio
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
file = str(file)
|
2019-03-24 07:53:19 +00:00
|
|
|
if self.vlc_player.can_folder:
|
|
|
|
self.resize(display, self.vlc_player)
|
|
|
|
if self.vlc_player.load(display, file):
|
|
|
|
self.current_media_players[controller.controller_type] = self.vlc_player
|
2011-09-22 18:22:35 +00:00
|
|
|
controller.media_info.media_type = MediaType.Video
|
|
|
|
return True
|
2011-06-05 21:10:49 +00:00
|
|
|
return False
|
|
|
|
|
2012-10-26 20:20:23 +00:00
|
|
|
def media_play_msg(self, msg, status=True):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
|
|
|
Responds to the request to play a loaded video
|
2011-12-03 20:35:53 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param msg: First element is the controller which should be used
|
|
|
|
:param status:
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2013-02-02 06:32:29 +00:00
|
|
|
self.media_play(msg[0], status)
|
2012-10-26 20:20:23 +00:00
|
|
|
|
2016-08-08 21:01:09 +00:00
|
|
|
def on_media_play(self):
|
|
|
|
"""
|
|
|
|
Responds to the request to play a loaded video from the web.
|
|
|
|
"""
|
|
|
|
self.media_play(Registry().get('live_controller'), False)
|
|
|
|
|
2016-02-14 17:53:16 +00:00
|
|
|
def media_play(self, controller, first_time=True):
|
2012-10-26 20:20:23 +00:00
|
|
|
"""
|
|
|
|
Responds to the request to play a loaded video
|
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param controller: The controller to be played
|
2016-02-14 17:53:16 +00:00
|
|
|
:param first_time:
|
2012-10-26 20:20:23 +00:00
|
|
|
"""
|
2013-03-23 07:07:06 +00:00
|
|
|
controller.seek_slider.blockSignals(True)
|
|
|
|
controller.volume_slider.blockSignals(True)
|
2012-10-29 17:25:08 +00:00
|
|
|
display = self._define_display(controller)
|
2019-03-24 07:53:19 +00:00
|
|
|
if not self.current_media_players[controller.controller_type].play(controller, display):
|
2013-03-23 07:07:06 +00:00
|
|
|
controller.seek_slider.blockSignals(False)
|
|
|
|
controller.volume_slider.blockSignals(False)
|
2012-10-29 17:25:08 +00:00
|
|
|
return False
|
2012-12-13 18:55:11 +00:00
|
|
|
if controller.media_info.is_background:
|
|
|
|
self.media_volume(controller, 0)
|
|
|
|
else:
|
|
|
|
self.media_volume(controller, controller.media_info.volume)
|
2016-02-14 17:53:16 +00:00
|
|
|
if first_time:
|
2019-03-27 19:21:11 +00:00
|
|
|
# if not controller.media_info.is_background:
|
2019-03-24 07:53:19 +00:00
|
|
|
# display.frame.runJavaScript('show_blank("desktop");')
|
2016-02-16 21:14:38 +00:00
|
|
|
self.current_media_players[controller.controller_type].set_visible(display, True)
|
|
|
|
controller.mediabar.actions['playbackPlay'].setVisible(False)
|
|
|
|
controller.mediabar.actions['playbackPause'].setVisible(True)
|
|
|
|
controller.mediabar.actions['playbackStop'].setDisabled(False)
|
2016-02-14 17:53:16 +00:00
|
|
|
if controller.is_live:
|
|
|
|
if controller.hide_menu.defaultAction().isChecked() and not controller.media_info.is_background:
|
|
|
|
controller.hide_menu.defaultAction().trigger()
|
2016-02-16 21:14:38 +00:00
|
|
|
# Start Timer for ui updates
|
|
|
|
if not self.live_timer.isActive():
|
|
|
|
self.live_timer.start()
|
|
|
|
else:
|
|
|
|
# Start Timer for ui updates
|
|
|
|
if not self.preview_timer.isActive():
|
|
|
|
self.preview_timer.start()
|
2013-03-23 07:07:06 +00:00
|
|
|
controller.seek_slider.blockSignals(False)
|
|
|
|
controller.volume_slider.blockSignals(False)
|
2016-04-13 18:38:49 +00:00
|
|
|
controller.media_info.is_playing = True
|
2016-03-08 17:49:57 +00:00
|
|
|
display = self._define_display(controller)
|
|
|
|
display.setVisible(True)
|
2011-08-29 19:55:58 +00:00
|
|
|
return True
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2015-12-20 17:24:45 +00:00
|
|
|
def tick(self, controller):
|
|
|
|
"""
|
|
|
|
Add a tick while the media is playing but only count if not paused
|
|
|
|
|
|
|
|
:param controller: The Controller to be processed
|
|
|
|
"""
|
2016-02-14 15:43:54 +00:00
|
|
|
start_again = False
|
2016-04-13 18:38:49 +00:00
|
|
|
if controller.media_info.is_playing and controller.media_info.length > 0:
|
2015-12-20 17:24:45 +00:00
|
|
|
if controller.media_info.timer > controller.media_info.length:
|
2016-02-16 21:14:38 +00:00
|
|
|
self.media_stop(controller, True)
|
2016-04-13 18:38:49 +00:00
|
|
|
if controller.media_info.can_loop_playback:
|
2016-02-14 15:43:54 +00:00
|
|
|
start_again = True
|
2015-12-20 21:30:47 +00:00
|
|
|
controller.media_info.timer += TICK_TIME
|
2015-12-20 17:24:45 +00:00
|
|
|
seconds = controller.media_info.timer // 1000
|
|
|
|
minutes = seconds // 60
|
|
|
|
seconds %= 60
|
2016-02-14 08:26:04 +00:00
|
|
|
total_seconds = controller.media_info.length // 1000
|
2015-12-20 17:24:45 +00:00
|
|
|
total_minutes = total_seconds // 60
|
|
|
|
total_seconds %= 60
|
|
|
|
controller.position_label.setText(' %02d:%02d / %02d:%02d' %
|
|
|
|
(minutes, seconds, total_minutes, total_seconds))
|
2016-02-14 15:43:54 +00:00
|
|
|
if start_again:
|
2016-02-16 21:14:38 +00:00
|
|
|
self.media_play(controller, True)
|
|
|
|
|
|
|
|
def media_pause_msg(self, msg):
|
|
|
|
"""
|
|
|
|
Responds to the request to pause a loaded video
|
|
|
|
|
|
|
|
:param msg: First element is the controller which should be used
|
|
|
|
"""
|
|
|
|
self.media_pause(msg[0])
|
2015-12-20 17:24:45 +00:00
|
|
|
|
2016-08-08 21:01:09 +00:00
|
|
|
def on_media_pause(self):
|
|
|
|
"""
|
|
|
|
Responds to the request to pause a loaded video from the web.
|
|
|
|
"""
|
|
|
|
self.media_pause(Registry().get('live_controller'))
|
|
|
|
|
2012-10-26 20:20:23 +00:00
|
|
|
def media_pause(self, controller):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
|
|
|
Responds to the request to pause a loaded video
|
2011-11-24 21:10:37 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param controller: The Controller to be paused
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2012-10-29 17:25:08 +00:00
|
|
|
display = self._define_display(controller)
|
2016-03-08 17:49:57 +00:00
|
|
|
if controller.controller_type in self.current_media_players:
|
|
|
|
self.current_media_players[controller.controller_type].pause(display)
|
|
|
|
controller.mediabar.actions['playbackPlay'].setVisible(True)
|
|
|
|
controller.mediabar.actions['playbackStop'].setDisabled(False)
|
|
|
|
controller.mediabar.actions['playbackPause'].setVisible(False)
|
2016-04-13 18:38:49 +00:00
|
|
|
controller.media_info.is_playing = False
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2016-02-14 15:43:54 +00:00
|
|
|
def media_loop_msg(self, msg):
|
|
|
|
"""
|
|
|
|
Responds to the request to loop a loaded video
|
|
|
|
|
|
|
|
:param msg: First element is the controller which should be used
|
|
|
|
"""
|
|
|
|
self.media_loop(msg[0])
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def media_loop(controller):
|
|
|
|
"""
|
|
|
|
Responds to the request to loop a loaded video
|
|
|
|
|
|
|
|
:param controller: The controller that needs to be stopped
|
|
|
|
"""
|
2016-04-13 18:38:49 +00:00
|
|
|
controller.media_info.can_loop_playback = not controller.media_info.can_loop_playback
|
|
|
|
controller.mediabar.actions['playbackLoop'].setChecked(controller.media_info.can_loop_playback)
|
2016-02-14 15:43:54 +00:00
|
|
|
|
2012-10-26 20:20:23 +00:00
|
|
|
def media_stop_msg(self, msg):
|
|
|
|
"""
|
|
|
|
Responds to the request to stop a loaded video
|
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param msg: First element is the controller which should be used
|
2012-10-26 20:20:23 +00:00
|
|
|
"""
|
2012-10-28 22:00:28 +00:00
|
|
|
self.media_stop(msg[0])
|
2012-10-26 20:20:23 +00:00
|
|
|
|
2016-08-08 21:01:09 +00:00
|
|
|
def on_media_stop(self):
|
|
|
|
"""
|
|
|
|
Responds to the request to stop a loaded video from the web.
|
|
|
|
"""
|
|
|
|
self.media_stop(Registry().get('live_controller'))
|
|
|
|
|
2016-02-16 21:14:38 +00:00
|
|
|
def media_stop(self, controller, looping_background=False):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
|
|
|
Responds to the request to stop a loaded video
|
2011-11-24 21:10:37 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param controller: The controller that needs to be stopped
|
2016-02-16 21:14:38 +00:00
|
|
|
:param looping_background: The background is looping so do not blank.
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2012-10-29 17:25:08 +00:00
|
|
|
display = self._define_display(controller)
|
2013-03-06 17:46:19 +00:00
|
|
|
if controller.controller_type in self.current_media_players:
|
2019-03-27 18:59:03 +00:00
|
|
|
# if not looping_background:
|
2019-03-24 07:53:19 +00:00
|
|
|
# display.frame.runJavaScript('show_blank("black");')
|
2013-03-06 17:46:19 +00:00
|
|
|
self.current_media_players[controller.controller_type].stop(display)
|
|
|
|
self.current_media_players[controller.controller_type].set_visible(display, False)
|
2013-03-23 07:07:06 +00:00
|
|
|
controller.seek_slider.setSliderPosition(0)
|
2017-05-29 16:29:15 +00:00
|
|
|
total_seconds = controller.media_info.length // 1000
|
|
|
|
total_minutes = total_seconds // 60
|
|
|
|
total_seconds %= 60
|
2019-04-12 21:03:23 +00:00
|
|
|
controller.position_label.setText(' %02d:%02d / %02d:%02d' % (0, 0, total_minutes, total_seconds))
|
2013-08-31 18:17:38 +00:00
|
|
|
controller.mediabar.actions['playbackPlay'].setVisible(True)
|
2015-03-16 21:32:56 +00:00
|
|
|
controller.mediabar.actions['playbackStop'].setDisabled(True)
|
2013-08-31 18:17:38 +00:00
|
|
|
controller.mediabar.actions['playbackPause'].setVisible(False)
|
2016-04-13 18:38:49 +00:00
|
|
|
controller.media_info.is_playing = False
|
2015-12-20 17:24:45 +00:00
|
|
|
controller.media_info.timer = 1000
|
2015-12-20 17:58:24 +00:00
|
|
|
controller.media_timer = 0
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2012-12-13 18:55:11 +00:00
|
|
|
def media_volume_msg(self, msg):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
|
|
|
Changes the volume of a running video
|
2011-11-24 21:10:37 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param msg: First element is the controller which should be used
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
|
|
|
controller = msg[0]
|
2011-06-08 14:49:48 +00:00
|
|
|
vol = msg[1][0]
|
2012-12-13 18:55:11 +00:00
|
|
|
self.media_volume(controller, vol)
|
|
|
|
|
|
|
|
def media_volume(self, controller, volume):
|
|
|
|
"""
|
|
|
|
Changes the volume of a running video
|
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param controller: The Controller to use
|
|
|
|
:param volume: The volume to be set
|
2012-12-13 18:55:11 +00:00
|
|
|
"""
|
2019-09-21 04:56:43 +00:00
|
|
|
log.debug('media_volume {vol}'.format(vol=volume))
|
2012-10-29 17:25:08 +00:00
|
|
|
display = self._define_display(controller)
|
2013-03-06 17:46:19 +00:00
|
|
|
self.current_media_players[controller.controller_type].volume(display, volume)
|
2013-03-23 07:07:06 +00:00
|
|
|
controller.volume_slider.setValue(volume)
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2012-12-29 20:54:25 +00:00
|
|
|
def media_seek_msg(self, msg):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2013-03-23 07:07:06 +00:00
|
|
|
Responds to the request to change the seek Slider of a loaded video via a message
|
2011-11-24 21:10:37 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param msg: First element is the controller which should be used
|
2013-03-23 07:07:06 +00:00
|
|
|
Second element is a list with the seek value as first element
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
|
|
|
controller = msg[0]
|
2013-03-23 07:07:06 +00:00
|
|
|
seek_value = msg[1][0]
|
|
|
|
self.media_seek(controller, seek_value)
|
2012-12-29 20:54:25 +00:00
|
|
|
|
2013-03-23 07:07:06 +00:00
|
|
|
def media_seek(self, controller, seek_value):
|
2012-12-29 20:54:25 +00:00
|
|
|
"""
|
|
|
|
Responds to the request to change the seek Slider of a loaded video
|
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param controller: The controller to use.
|
|
|
|
:param seek_value: The value to set.
|
2012-12-29 20:54:25 +00:00
|
|
|
"""
|
2012-11-01 18:45:12 +00:00
|
|
|
display = self._define_display(controller)
|
2013-03-23 07:07:06 +00:00
|
|
|
self.current_media_players[controller.controller_type].seek(display, seek_value)
|
2015-12-20 17:24:45 +00:00
|
|
|
controller.media_info.timer = seek_value
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2012-10-15 18:38:58 +00:00
|
|
|
def media_reset(self, controller):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
|
|
|
Responds to the request to reset a loaded video
|
2015-12-20 17:24:45 +00:00
|
|
|
:param controller: The controller to use.
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2012-01-11 20:51:11 +00:00
|
|
|
self.set_controls_visible(controller, False)
|
2012-10-29 17:25:08 +00:00
|
|
|
display = self._define_display(controller)
|
2013-03-06 17:46:19 +00:00
|
|
|
if controller.controller_type in self.current_media_players:
|
2012-10-29 17:25:08 +00:00
|
|
|
display.override = {}
|
2013-03-06 17:46:19 +00:00
|
|
|
self.current_media_players[controller.controller_type].reset(display)
|
|
|
|
self.current_media_players[controller.controller_type].set_visible(display, False)
|
2019-03-24 07:53:19 +00:00
|
|
|
# display.frame.runJavaScript('show_video("setBackBoard", null, null, "hidden");')
|
2013-03-06 17:46:19 +00:00
|
|
|
del self.current_media_players[controller.controller_type]
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2012-10-15 18:38:58 +00:00
|
|
|
def media_hide(self, msg):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
|
|
|
Hide the related video Widget
|
2011-11-24 21:10:37 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param msg: First element is the boolean for Live indication
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2013-02-20 20:43:20 +00:00
|
|
|
is_live = msg[1]
|
|
|
|
if not is_live:
|
2012-04-28 11:13:16 +00:00
|
|
|
return
|
2013-02-21 17:05:56 +00:00
|
|
|
display = self._define_display(self.live_controller)
|
2013-03-06 17:46:19 +00:00
|
|
|
if self.live_controller.controller_type in self.current_media_players and \
|
2016-02-26 16:00:04 +00:00
|
|
|
self.current_media_players[self.live_controller.controller_type].get_live_state() == MediaState.Playing:
|
2017-05-29 16:31:14 +00:00
|
|
|
self.media_pause(display.controller)
|
2015-06-15 20:29:34 +00:00
|
|
|
self.current_media_players[self.live_controller.controller_type].set_visible(display, False)
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2012-10-15 18:38:58 +00:00
|
|
|
def media_blank(self, msg):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
|
|
|
Blank the related video Widget
|
2011-11-24 21:10:37 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param msg: First element is the boolean for Live indication
|
2011-11-24 21:10:37 +00:00
|
|
|
Second element is the hide mode
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2013-02-20 20:43:20 +00:00
|
|
|
is_live = msg[1]
|
2011-10-24 20:04:29 +00:00
|
|
|
hide_mode = msg[2]
|
2013-02-20 20:43:20 +00:00
|
|
|
if not is_live:
|
2012-04-28 11:13:16 +00:00
|
|
|
return
|
2013-08-31 18:17:38 +00:00
|
|
|
Registry().execute('live_display_hide', hide_mode)
|
2013-02-21 17:05:56 +00:00
|
|
|
display = self._define_display(self.live_controller)
|
2015-06-15 20:29:34 +00:00
|
|
|
if self.live_controller.controller_type in self.current_media_players and \
|
2016-02-26 16:00:04 +00:00
|
|
|
self.current_media_players[self.live_controller.controller_type].get_live_state() == MediaState.Playing:
|
2017-05-29 16:31:14 +00:00
|
|
|
self.media_pause(display.controller)
|
2013-03-06 17:46:19 +00:00
|
|
|
self.current_media_players[self.live_controller.controller_type].set_visible(display, False)
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2012-10-15 18:38:58 +00:00
|
|
|
def media_unblank(self, msg):
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
|
|
|
Unblank the related video Widget
|
2011-11-24 21:10:37 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param msg: First element is not relevant in this context
|
2011-11-24 21:10:37 +00:00
|
|
|
Second element is the boolean for Live indication
|
2011-06-05 21:10:49 +00:00
|
|
|
"""
|
2013-08-31 18:17:38 +00:00
|
|
|
Registry().execute('live_display_show')
|
2013-02-20 20:43:20 +00:00
|
|
|
is_live = msg[1]
|
|
|
|
if not is_live:
|
2012-04-28 11:13:16 +00:00
|
|
|
return
|
2013-02-21 17:05:56 +00:00
|
|
|
display = self._define_display(self.live_controller)
|
2013-03-06 17:46:19 +00:00
|
|
|
if self.live_controller.controller_type in self.current_media_players and \
|
2016-02-26 16:00:04 +00:00
|
|
|
self.current_media_players[self.live_controller.controller_type].get_live_state() != \
|
|
|
|
MediaState.Playing:
|
2017-05-29 16:31:14 +00:00
|
|
|
if self.media_play(display.controller):
|
2013-03-06 17:46:19 +00:00
|
|
|
self.current_media_players[self.live_controller.controller_type].set_visible(display, True)
|
2012-04-28 11:13:16 +00:00
|
|
|
# Start Timer for ui updates
|
2016-02-16 21:14:38 +00:00
|
|
|
if not self.live_timer.isActive():
|
|
|
|
self.live_timer.start()
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2011-07-20 21:16:36 +00:00
|
|
|
def finalise(self):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Reset all the media controllers when OpenLP shuts down
|
|
|
|
"""
|
2016-02-16 21:14:38 +00:00
|
|
|
self.live_timer.stop()
|
|
|
|
self.preview_timer.stop()
|
2019-03-24 07:53:19 +00:00
|
|
|
self.media_reset(self.display_controllers(DisplayControllerType.Live))
|
|
|
|
self.media_reset(self.display_controllers(DisplayControllerType.Preview))
|
2012-10-29 17:25:08 +00:00
|
|
|
|
2016-02-14 15:43:54 +00:00
|
|
|
@staticmethod
|
|
|
|
def _define_display(controller):
|
2012-10-29 17:25:08 +00:00
|
|
|
"""
|
|
|
|
Extract the correct display for a given controller
|
2012-10-31 18:27:24 +00:00
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param controller: Controller to be used
|
2012-10-29 17:25:08 +00:00
|
|
|
"""
|
2013-02-20 20:43:20 +00:00
|
|
|
if controller.is_live:
|
2012-10-29 17:25:08 +00:00
|
|
|
return controller.display
|
2013-02-20 20:43:20 +00:00
|
|
|
return controller.preview_display
|