~raoul-snyman/openlp/pyro-impress

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4

##########################################################################
# 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/>. #
##########################################################################
"""
The :mod:`~openlp.core.ui.media.mediaplayer` module contains the MediaPlayer class.
"""
from openlp.core.common.mixins import RegistryProperties
from openlp.core.ui.media import MediaState


class MediaPlayer(RegistryProperties):
    """
    This is the base class media Player class to provide OpenLP with a pluggable media display framework.
    """

    def __init__(self, parent, name='media_player'):
        """
        Constructor
        """
        self.parent = parent
        self.name = name
        self.available = self.check_available()
        self.can_background = False
        self.can_folder = False
        self.state = {0: MediaState.Off, 1: MediaState.Off}
        self.has_own_widget = False

    def check_available(self):
        """
        Player is available on this machine
        """
        return False

    def setup(self, display, live_display):
        """
        Create the related widgets for the current display

        :param display: The display to be updated.
        :param live_display: Is the display a live one.
        """
        pass

    def load(self, display, file):
        """
        Load a new media file and check if it is valid

        :param display: The display to be updated.
        :param file: The file to be loaded
        """
        return True

    def resize(self, display):
        """
        If the main display size or position is changed, the media widgets
        should also resized

        :param display: The display to be updated.
        """
        pass

    def play(self, controller, display):
        """
        Starts playing of current Media File

        :param controller: Which Controller is running the show.
        :param display: The display to be updated.
        """
        pass

    def pause(self, display):
        """
        Pause of current Media File

        :param display: The display to be updated.
        """
        pass

    def stop(self, display):
        """
        Stop playing of current Media File

        :param display: The display to be updated.
        """
        pass

    def volume(self, display, volume):
        """
        Change volume of current Media File

        :param display: The display to be updated.
        :param volume: The volume to set.
        """
        pass

    def seek(self, display, seek_value):
        """
        Change playing position of current Media File

        :param display: The display to be updated.
        :param seek_value: The where to seek to.
        """
        pass

    def reset(self, display):
        """
        Remove the current loaded video

        :param display: The display to be updated.
        """
        pass

    def set_visible(self, display, status):
        """
        Show/Hide the media widgets

        :param display: The display to be updated.
        :param status: The status to be set.
        """
        pass

    def update_ui(self, controller, output_display):
        """
        Do some ui related stuff (e.g. update the seek slider)

        :param controller: Which Controller is running the show.
        :param output_display: The display where the media is
        """
        pass

    def get_media_display_css(self):
        """
        Add css style sheets to htmlbuilder
        """
        return ''

    def get_media_display_javascript(self):
        """
        Add javascript functions to htmlbuilder
        """
        return ''

    def get_media_display_html(self):
        """
        Add html code to htmlbuilder
        """
        return ''

    def get_live_state(self):
        """
        Get the state of the live player
        :return: Live state
        """
        return self.state[0]

    def set_live_state(self, state):
        """
        Set the State of the Live player
        :param state: State to be set
        :return: None
        """
        self.state[0] = state

    def get_preview_state(self):
        """
        Get the state of the preview player
        :return: Preview State
        """
        return self.state[1]

    def set_preview_state(self, state):
        """
        Set the state of the Preview Player
        :param state: State to be set
        :return: None
        """
        self.state[1] = state

    def set_state(self, state, display):
        """
        Set the State based on the display being processed
        :param state: State to be set
        :param display: Identify the Display type
        :return: None
        """
        if display.is_display:
            self.set_live_state(state)
        else:
            self.set_preview_state(state)