openlp/openlp/core/ui/media/mediaplayer.py

205 lines
6.2 KiB
Python
Raw Normal View History

2011-06-14 16:10:20 +00:00
# -*- coding: utf-8 -*-
2019-04-13 13:00:22 +00:00
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
2022-02-01 10:10:57 +00:00
# Copyright (c) 2008-2022 OpenLP Developers #
2019-04-13 13:00:22 +00:00
# ---------------------------------------------------------------------- #
# 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/>. #
##########################################################################
"""
The :mod:`~openlp.core.ui.media.mediaplayer` module contains the MediaPlayer class.
"""
2017-10-23 22:09:57 +00:00
from openlp.core.common.mixins import RegistryProperties
2011-07-10 21:43:07 +00:00
from openlp.core.ui.media import MediaState
2011-06-14 16:10:20 +00:00
2014-03-16 21:25:23 +00:00
class MediaPlayer(RegistryProperties):
2011-06-14 16:10:20 +00:00
"""
2013-12-31 20:29:03 +00:00
This is the base class media Player class to provide OpenLP with a pluggable media display framework.
2011-06-14 16:10:20 +00:00
"""
2011-09-22 18:22:35 +00:00
2013-08-31 18:17:38 +00:00
def __init__(self, parent, name='media_player'):
"""
Constructor
"""
2011-06-14 16:10:20 +00:00
self.parent = parent
self.name = name
self.available = self.check_available()
2013-03-06 22:54:16 +00:00
self.can_background = False
2013-03-06 23:00:57 +00:00
self.can_folder = False
2016-02-26 16:00:04 +00:00
self.state = {0: MediaState.Off, 1: MediaState.Off}
2013-03-06 22:54:16 +00:00
self.has_own_widget = False
2011-06-14 16:10:20 +00:00
def check_available(self):
"""
2011-11-11 16:45:25 +00:00
Player is available on this machine
2011-06-14 16:10:20 +00:00
"""
return False
2021-08-28 07:04:15 +00:00
def setup(self, controller, display):
2011-06-14 16:10:20 +00:00
"""
Create the related widgets for the current display
2016-02-14 16:14:48 +00:00
2021-08-28 07:04:15 +00:00
:param controller: Which Controller is running the show.
2016-02-14 16:14:48 +00:00
:param display: The display to be updated.
2011-06-14 16:10:20 +00:00
"""
pass
def load(self, controller, display, file):
2011-06-14 16:10:20 +00:00
"""
Load a new media file and check if it is valid
:param controller: Which Controller is running the show.
2016-02-14 16:14:48 +00:00
:param display: The display to be updated.
2018-12-13 19:25:20 +00:00
:param file: The file to be loaded
2011-06-14 16:10:20 +00:00
"""
return True
2021-08-28 07:04:15 +00:00
def resize(self, controller):
2011-06-14 16:10:20 +00:00
"""
2012-04-04 07:26:51 +00:00
If the main display size or position is changed, the media widgets
2011-11-02 20:27:53 +00:00
should also resized
2021-08-28 07:04:15 +00:00
:param controller: Which Controller is running the show.
2011-06-14 16:10:20 +00:00
"""
pass
2019-03-24 07:53:19 +00:00
def play(self, controller, display):
2011-06-14 16:10:20 +00:00
"""
2021-04-28 06:19:47 +00:00
Starts playing of current Media File, media player is expected to loop automatically
2016-02-14 16:14:48 +00:00
2019-03-24 07:53:19 +00:00
:param controller: Which Controller is running the show.
2016-02-14 16:14:48 +00:00
:param display: The display to be updated.
2011-06-14 16:10:20 +00:00
"""
pass
2021-08-28 07:04:15 +00:00
def pause(self, controller):
2011-06-14 16:10:20 +00:00
"""
Pause of current Media File
2016-02-14 16:14:48 +00:00
2021-08-28 07:04:15 +00:00
:param controller: Which Controller is running the show.
2011-06-14 16:10:20 +00:00
"""
pass
2021-08-28 07:04:15 +00:00
def stop(self, controller):
2011-06-14 16:10:20 +00:00
"""
Stop playing of current Media File
2016-02-14 16:14:48 +00:00
2021-08-28 07:04:15 +00:00
:param controller: Which Controller is running the show.
2011-06-14 16:10:20 +00:00
"""
pass
2021-08-28 07:04:15 +00:00
def volume(self, controller, volume):
2011-06-14 16:10:20 +00:00
"""
Change volume of current Media File
2016-02-14 16:14:48 +00:00
2021-08-28 07:04:15 +00:00
:param controller: Which Controller is running the show.
2016-02-14 16:14:48 +00:00
:param volume: The volume to set.
2011-06-14 16:10:20 +00:00
"""
pass
2021-08-28 07:04:15 +00:00
def seek(self, controller, seek_value):
2011-06-14 16:10:20 +00:00
"""
Change playing position of current Media File
2016-02-14 16:14:48 +00:00
2021-08-28 07:04:15 +00:00
:param controller: Which Controller is running the show.
2016-02-14 16:14:48 +00:00
:param seek_value: The where to seek to.
2011-06-14 16:10:20 +00:00
"""
pass
2021-08-28 07:04:15 +00:00
def reset(self, controller):
2011-06-14 16:10:20 +00:00
"""
Remove the current loaded video
2016-02-14 16:14:48 +00:00
2021-08-28 07:04:15 +00:00
:param controller: Which Controller is running the show.
2011-06-14 16:10:20 +00:00
"""
pass
2021-08-28 07:04:15 +00:00
def set_visible(self, controller, status):
2011-06-14 16:10:20 +00:00
"""
Show/Hide the media widgets
2016-02-14 16:14:48 +00:00
2021-08-28 07:04:15 +00:00
:param controller: Which Controller is running the show.
2016-02-14 16:14:48 +00:00
:param status: The status to be set.
2011-06-14 16:10:20 +00:00
"""
pass
2019-04-21 08:20:43 +00:00
def update_ui(self, controller, output_display):
2011-06-14 16:10:20 +00:00
"""
2011-11-02 20:27:53 +00:00
Do some ui related stuff (e.g. update the seek slider)
2016-02-14 16:14:48 +00:00
2019-04-21 08:20:43 +00:00
:param controller: Which Controller is running the show.
:param output_display: The display where the media is
2011-06-14 16:10:20 +00:00
"""
pass
2011-08-29 19:55:58 +00:00
def get_media_display_css(self):
2011-06-14 16:10:20 +00:00
"""
Add css style sheets to htmlbuilder
"""
2013-08-31 18:17:38 +00:00
return ''
2011-06-14 16:10:20 +00:00
2011-08-29 19:55:58 +00:00
def get_media_display_javascript(self):
2011-06-14 16:10:20 +00:00
"""
Add javascript functions to htmlbuilder
"""
2013-08-31 18:17:38 +00:00
return ''
2011-06-14 16:10:20 +00:00
2011-08-29 19:55:58 +00:00
def get_media_display_html(self):
2011-06-14 16:10:20 +00:00
"""
Add html code to htmlbuilder
"""
2013-08-31 18:17:38 +00:00
return ''
2012-10-15 17:35:14 +00:00
2016-02-26 16:00:04 +00:00
def get_live_state(self):
2016-04-07 18:14:10 +00:00
"""
Get the state of the live player
:return: Live state
"""
2016-02-26 16:00:04 +00:00
return self.state[0]
def set_live_state(self, state):
2016-04-07 18:14:10 +00:00
"""
Set the State of the Live player
:param state: State to be set
:return: None
"""
2016-02-26 16:00:04 +00:00
self.state[0] = state
def get_preview_state(self):
2016-04-07 18:14:10 +00:00
"""
Get the state of the preview player
:return: Preview State
"""
2016-02-26 16:00:04 +00:00
return self.state[1]
def set_preview_state(self, state):
2016-04-07 18:14:10 +00:00
"""
Set the state of the Preview Player
:param state: State to be set
:return: None
"""
2016-02-26 16:00:04 +00:00
self.state[1] = state
def set_state(self, state, controller):
2016-04-07 18:14:10 +00:00
"""
Set the State based on the display being processed within the controller
2016-04-07 18:14:10 +00:00
:param state: State to be set
:param controller: Identify the Display type
2016-04-07 18:14:10 +00:00
:return: None
"""
if controller.is_live:
2016-02-26 16:00:04 +00:00
self.set_live_state(state)
else:
self.set_preview_state(state)