Merge lp:~trb143/openlp/more_media into lp:openlp

Proposed by Tim Bentley on 2019-06-14
Status: Merged
Merged at revision: 2880
Proposed branch: lp:~trb143/openlp/more_media
Merge into: lp:openlp
Diff against target: 453 lines (+137/-53)
11 files modified
openlp/core/common/settings.py (+2/-0)
openlp/core/lib/__init__.py (+1/-0)
openlp/core/ui/media/__init__.py (+13/-0)
openlp/core/ui/media/mediacontroller.py (+23/-6)
openlp/core/ui/media/mediatab.py (+28/-15)
openlp/core/ui/media/vlcplayer.py (+7/-20)
openlp/core/ui/servicemanager.py (+1/-1)
openlp/core/ui/themeform.py (+1/-1)
openlp/core/widgets/widgets.py (+2/-2)
openlp/plugins/media/lib/mediaitem.py (+16/-6)
tests/functional/openlp_core/ui/media/test_mediacontroller.py (+43/-2)
To merge this branch: bzr merge lp:~trb143/openlp/more_media
Reviewer Review Type Date Requested Status
Phill 2019-06-14 Approve on 2019-06-14
Review via email: mp+368843@code.launchpad.net

This proposal supersedes a proposal from 2019-06-14.

Commit message

Adds basic streaming service item
UI to set up streaming
Fix issues with suffix refactor

To post a comment you must log in.
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linux tests passed!

Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linting failed, please see https://ci.openlp.io/job/MP-03-Linting/119/ for more details

Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linux tests passed!

Phill (phill-ridout) wrote : Posted in a previous version of this proposal

Just one inconsistency with text labels (see inline) and the failed linting, but other than that looks ok!

review: Needs Fixing
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linting passed!

Phill (phill-ridout) : Posted in a previous version of this proposal
review: Approve
Raoul Snyman (raoul-snyman) wrote :

Linux tests passed!

Raoul Snyman (raoul-snyman) wrote :

Linting passed!

Raoul Snyman (raoul-snyman) wrote :

macOS tests passed!

Phill (phill-ridout) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/common/settings.py'
2--- openlp/core/common/settings.py 2019-06-10 20:22:22 +0000
3+++ openlp/core/common/settings.py 2019-06-14 19:28:31 +0000
4@@ -210,6 +210,8 @@
5 'media/media auto start': QtCore.Qt.Unchecked,
6 'media/stream command': '',
7 'media/vlc arguments': '',
8+ 'media/video': '',
9+ 'media/audio': '',
10 'remotes/download version': '0.0',
11 'players/background color': '#000000',
12 'servicemanager/last directory': None,
13
14=== modified file 'openlp/core/lib/__init__.py'
15--- openlp/core/lib/__init__.py 2019-05-22 06:47:00 +0000
16+++ openlp/core/lib/__init__.py 2019-06-14 19:28:31 +0000
17@@ -173,6 +173,7 @@
18 HasNotes = 20
19 HasThumbnails = 21
20 HasMetaData = 22
21+ CanStream = 23
22
23
24 def get_text_file_string(text_file_path):
25
26=== modified file 'openlp/core/ui/media/__init__.py'
27--- openlp/core/ui/media/__init__.py 2019-04-13 13:00:22 +0000
28+++ openlp/core/ui/media/__init__.py 2019-06-14 19:28:31 +0000
29@@ -26,6 +26,19 @@
30
31 log = logging.getLogger(__name__ + '.__init__')
32
33+# Audio and video extensions copied from 'include/vlc_interface.h' from vlc 2.2.0 source
34+AUDIO_EXT = ['*.3ga', '*.669', '*.a52', '*.aac', '*.ac3', '*.adt', '*.adts', '*.aif', '*.aifc', '*.aiff', '*.amr',
35+ '*.aob', '*.ape', '*.awb', '*.caf', '*.dts', '*.flac', '*.it', '*.kar', '*.m4a', '*.m4b', '*.m4p', '*.m5p',
36+ '*.mid', '*.mka', '*.mlp', '*.mod', '*.mpa', '*.mp1', '*.mp2', '*.mp3', '*.mpc', '*.mpga', '*.mus',
37+ '*.oga', '*.ogg', '*.oma', '*.opus', '*.qcp', '*.ra', '*.rmi', '*.s3m', '*.sid', '*.spx', '*.thd', '*.tta',
38+ '*.voc', '*.vqf', '*.w64', '*.wav', '*.wma', '*.wv', '*.xa', '*.xm']
39+VIDEO_EXT = ['*.3g2', '*.3gp', '*.3gp2', '*.3gpp', '*.amv', '*.asf', '*.avi', '*.bik', '*.divx', '*.drc', '*.dv',
40+ '*.f4v', '*.flv', '*.gvi', '*.gxf', '*.iso', '*.m1v', '*.m2v', '*.m2t', '*.m2ts', '*.m4v', '*.mkv',
41+ '*.mov', '*.mp2', '*.mp2v', '*.mp4', '*.mp4v', '*.mpe', '*.mpeg', '*.mpeg1', '*.mpeg2', '*.mpeg4', '*.mpg',
42+ '*.mpv2', '*.mts', '*.mtv', '*.mxf', '*.mxg', '*.nsv', '*.nuv', '*.ogg', '*.ogm', '*.ogv', '*.ogx', '*.ps',
43+ '*.rec', '*.rm', '*.rmvb', '*.rpl', '*.thp', '*.tod', '*.ts', '*.tts', '*.txd', '*.vob', '*.vro', '*.webm',
44+ '*.wm', '*.wmv', '*.wtv', '*.xesc', '*.nut', '*.rv', '*.xvid']
45+
46
47 class MediaState(object):
48 """
49
50=== modified file 'openlp/core/ui/media/mediacontroller.py'
51--- openlp/core/ui/media/mediacontroller.py 2019-06-05 04:53:18 +0000
52+++ openlp/core/ui/media/mediacontroller.py 2019-06-14 19:28:31 +0000
53@@ -42,9 +42,9 @@
54 from openlp.core.lib.serviceitem import ItemCapabilities
55 from openlp.core.lib.ui import critical_error_message_box
56 from openlp.core.ui import DisplayControllerType
57-from openlp.core.ui.media import MediaState, ItemMediaInfo, MediaType, parse_optical_path
58+from openlp.core.ui.media import MediaState, ItemMediaInfo, MediaType, parse_optical_path, VIDEO_EXT, AUDIO_EXT
59 from openlp.core.ui.media.endpoint import media_endpoint
60-from openlp.core.ui.media.vlcplayer import AUDIO_EXT, VIDEO_EXT, VlcPlayer, get_vlc
61+from openlp.core.ui.media.vlcplayer import VlcPlayer, get_vlc
62
63
64 log = logging.getLogger(__name__)
65@@ -184,7 +184,8 @@
66 display.has_audio = False
67 self.vlc_player.setup(display, preview)
68
69- def set_controls_visible(self, controller, value):
70+ @staticmethod
71+ def set_controls_visible(controller, value):
72 """
73 After a new display is configured, all media related widget will be created too
74
75@@ -229,7 +230,10 @@
76 display = self._define_display(controller)
77 if controller.is_live:
78 # if this is an optical device use special handling
79- if service_item.is_capable(ItemCapabilities.IsOptical):
80+ if service_item.is_capable(ItemCapabilities.CanStream):
81+ is_valid = self._check_file_type(controller, display, True)
82+ controller.media_info.media_type = MediaType.Stream
83+ elif service_item.is_capable(ItemCapabilities.IsOptical):
84 log.debug('video is optical and live')
85 path = service_item.get_frame_path()
86 (name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(path)
87@@ -249,7 +253,10 @@
88 controller.media_info.start_time = service_item.start_time
89 controller.media_info.end_time = service_item.end_time
90 elif controller.preview_display:
91- if service_item.is_capable(ItemCapabilities.IsOptical):
92+ if service_item.is_capable(ItemCapabilities.CanStream):
93+ controller.media_info.media_type = MediaType.Stream
94+ is_valid = self._check_file_type(controller, display, True)
95+ elif service_item.is_capable(ItemCapabilities.IsOptical):
96 log.debug('video is optical and preview')
97 path = service_item.get_frame_path()
98 (name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(path)
99@@ -270,6 +277,8 @@
100 # display.frame.runJavaScript('show_video("setBackBoard", null, null,"visible");')
101 # now start playing - Preview is autoplay!
102 autoplay = False
103+ if service_item.is_capable(ItemCapabilities.CanStream):
104+ autoplay = True
105 # Preview requested
106 if not controller.is_live:
107 autoplay = True
108@@ -346,13 +355,21 @@
109 controller.media_info.media_type = MediaType.DVD
110 return True
111
112- def _check_file_type(self, controller, display):
113+ def _check_file_type(self, controller, display, stream=False):
114 """
115 Select the correct media Player type from the prioritized Player list
116
117 :param controller: First element is the controller which should be used
118 :param display: Which display to use
119+ :param stream: Are we streaming or not
120 """
121+ if stream:
122+ self.resize(display, self.vlc_player)
123+ display.media_info.media_type = MediaType.Stream
124+ if self.vlc_player.load(display, None):
125+ self.current_media_players[controller.controller_type] = self.vlc_player
126+ return True
127+ return True
128 for file in controller.media_info.file_info:
129 if file.is_file:
130 suffix = '*%s' % file.suffix.lower()
131
132=== modified file 'openlp/core/ui/media/mediatab.py'
133--- openlp/core/ui/media/mediatab.py 2019-05-04 19:47:06 +0000
134+++ openlp/core/ui/media/mediatab.py 2019-06-14 19:28:31 +0000
135@@ -33,9 +33,9 @@
136 from openlp.core.lib.settingstab import SettingsTab
137 from openlp.core.ui.icons import UiIcons
138
139-LINUX_STREAM = 'v4l2://{video} :v4l2-standard= :input-slave={audio} :live-caching=300'
140+LINUX_STREAM = 'v4l2://{video}:v4l2-standard= :input-slave=alsa://{audio} :live-caching=300'
141 WIN_STREAM = 'dshow://:dshow-vdev={video} :dshow-adev={audio} :live-caching=300'
142-OSX_STREAM = 'avcapture://{video} :qtsound://{audio} :live-caching=300'
143+OSX_STREAM = 'avcapture://{video}:qtsound://{audio} :live-caching=300'
144
145 log = logging.getLogger(__name__)
146
147@@ -68,11 +68,15 @@
148 self.left_layout.addWidget(self.live_media_group_box)
149 self.stream_media_group_box = QtWidgets.QGroupBox(self.left_column)
150 self.stream_media_group_box.setObjectName('stream_media_group_box')
151- self.stream_media_layout = QtWidgets.QHBoxLayout(self.stream_media_group_box)
152+ self.stream_media_layout = QtWidgets.QFormLayout(self.stream_media_group_box)
153 self.stream_media_layout.setObjectName('stream_media_layout')
154 self.stream_media_layout.setContentsMargins(0, 0, 0, 0)
155- self.stream_edit = QtWidgets.QLabel(self)
156- self.stream_media_layout.addWidget(self.stream_edit)
157+ self.video_edit = QtWidgets.QLineEdit(self)
158+ self.stream_media_layout.addRow(translate('MediaPlugin.MediaTab', 'Video:'), self.video_edit)
159+ self.audio_edit = QtWidgets.QLineEdit(self)
160+ self.stream_media_layout.addRow(translate('MediaPlugin.MediaTab', 'Audio:'), self.audio_edit)
161+ self.stream_cmd = QtWidgets.QLabel(self)
162+ self.stream_media_layout.addWidget(self.stream_cmd)
163 self.left_layout.addWidget(self.stream_media_group_box)
164 self.vlc_arguments_group_box = QtWidgets.QGroupBox(self.left_column)
165 self.vlc_arguments_group_box.setObjectName('vlc_arguments_group_box')
166@@ -84,7 +88,6 @@
167 self.left_layout.addWidget(self.vlc_arguments_group_box)
168 self.left_layout.addStretch()
169 self.right_layout.addStretch()
170- # # Signals and slots
171
172 def retranslate_ui(self):
173 """
174@@ -100,22 +103,28 @@
175 Load the settings
176 """
177 self.auto_start_check_box.setChecked(Settings().value(self.settings_section + '/media auto start'))
178- self.stream_edit.setText(Settings().value(self.settings_section + '/stream command'))
179- if not self.stream_edit.text():
180- if is_linux:
181- self.stream_edit.setText(LINUX_STREAM)
182- elif is_win:
183- self.stream_edit.setText(WIN_STREAM)
184- else:
185- self.stream_edit.setText(OSX_STREAM)
186+ self.stream_cmd.setText(Settings().value(self.settings_section + '/stream command'))
187+ self.audio_edit.setText(Settings().value(self.settings_section + '/audio'))
188+ self.video_edit.setText(Settings().value(self.settings_section + '/video'))
189+ if not self.stream_cmd.text():
190+ self.set_base_stream()
191 self.vlc_arguments_edit.setPlainText(Settings().value(self.settings_section + '/vlc arguments'))
192 if Settings().value('advanced/experimental'):
193+ # vlc.MediaPlayer().audio_output_device_enum()
194 for cam in QCameraInfo.availableCameras():
195 log.debug(cam.deviceName())
196 log.debug(cam.description())
197 for au in QAudioDeviceInfo.availableDevices(QAudio.AudioInput):
198 log.debug(au.deviceName())
199
200+ def set_base_stream(self):
201+ if is_linux:
202+ self.stream_cmd.setText(LINUX_STREAM)
203+ elif is_win:
204+ self.stream_cmd.setText(WIN_STREAM)
205+ else:
206+ self.stream_cmd.setText(OSX_STREAM)
207+
208 def save(self):
209 """
210 Save the settings
211@@ -123,8 +132,12 @@
212 setting_key = self.settings_section + '/media auto start'
213 if Settings().value(setting_key) != self.auto_start_check_box.checkState():
214 Settings().setValue(setting_key, self.auto_start_check_box.checkState())
215- Settings().setValue(self.settings_section + '/stream command', self.stream_edit.text())
216+ Settings().setValue(self.settings_section + '/stream command', self.stream_cmd.text())
217 Settings().setValue(self.settings_section + '/vlc arguments', self.vlc_arguments_edit.toPlainText())
218+ Settings().setValue(self.settings_section + '/video', self.video_edit.text())
219+ Settings().setValue(self.settings_section + '/audio', self.audio_edit.text())
220+ self.stream_cmd.setText(self.stream_cmd.text().format(video=self.video_edit.text(),
221+ audio=self.audio_edit.text()))
222
223 def post_set_up(self, post_update=False):
224 """
225
226=== modified file 'openlp/core/ui/media/vlcplayer.py'
227--- openlp/core/ui/media/vlcplayer.py 2019-06-11 19:13:35 +0000
228+++ openlp/core/ui/media/vlcplayer.py 2019-06-14 19:28:31 +0000
229@@ -40,18 +40,6 @@
230 log = logging.getLogger(__name__)
231
232 # Audio and video extensions copied from 'include/vlc_interface.h' from vlc 2.2.0 source
233-AUDIO_EXT = ('3ga', '669', 'a52', 'aac', 'ac3', 'adt', 'adts', 'aif', 'aifc', 'aiff', 'amr', 'aob', 'ape', 'awb', 'caf',
234- 'dts', 'flac', 'it', 'kar', 'm4a', 'm4b', 'm4p', 'm5p', 'mid', 'mka', 'mlp', 'mod', 'mpa', 'mp1', 'mp2',
235- 'mp3', 'mpc', 'mpga', 'mus', 'oga', 'ogg', 'oma', 'opus', 'qcp', 'ra', 'rmi', 's3m', 'sid', 'spx', 'thd',
236- 'tta', 'voc', 'vqf', 'w64', 'wav', 'wma', 'wv', 'xa', 'xm')
237-
238-VIDEO_EXT = ('3g2', '3gp', '3gp2', '3gpp', 'amv', 'asf', 'avi', 'bik', 'divx', 'drc', 'dv', 'f4v', 'flv', 'gvi', 'gxf',
239- 'iso', 'm1v', 'm2v', 'm2t', 'm2ts', 'm4v', 'mkv', 'mov', 'mp2', 'mp2v', 'mp4', 'mp4v', 'mpe', 'mpeg',
240- 'mpeg1', 'mpeg2', 'mpeg4', 'mpg', 'mpv2', 'mts', 'mtv', 'mxf', 'mxg', 'nsv', 'nuv', 'ogg', 'ogm', 'ogv',
241- 'ogx', 'ps', 'rec', 'rm', 'rmvb', 'rpl', 'thp', 'tod', 'ts', 'tts', 'txd', 'vob', 'vro', 'webm', 'wm',
242- 'wmv', 'wtv', 'xesc',
243- # These extensions was not in the official list, added manually.
244- 'nut', 'rv', 'xvid')
245
246
247 def get_vlc():
248@@ -159,16 +147,15 @@
249 Load a video into VLC
250
251 :param output_display: The display where the media is
252- :param file: file to be played
253+ :param file: file to be played or None for live streaming
254 :return:
255 """
256 vlc = get_vlc()
257 log.debug('load vid in Vlc Controller')
258- controller = output_display
259- volume = controller.media_info.volume
260- path = os.path.normcase(file)
261+ if file:
262+ path = os.path.normcase(file)
263 # create the media
264- if controller.media_info.media_type == MediaType.CD:
265+ if output_display.media_info.media_type == MediaType.CD:
266 if is_win():
267 path = '/' + path
268 output_display.vlc_media = output_display.vlc_instance.media_new_location('cdda://' + path)
269@@ -180,8 +167,8 @@
270 audio_cd_tracks = output_display.vlc_media.subitems()
271 if not audio_cd_tracks or audio_cd_tracks.count() < 1:
272 return False
273- output_display.vlc_media = audio_cd_tracks.item_at_index(controller.media_info.title_track)
274- elif controller.media_info.media_type == MediaType.Stream:
275+ output_display.vlc_media = audio_cd_tracks.item_at_index(output_display.media_info.title_track)
276+ elif output_display.media_info.media_type == MediaType.Stream:
277 stream_cmd = Settings().value('media/stream command')
278 output_display.vlc_media = output_display.vlc_instance.media_new_location(stream_cmd)
279 else:
280@@ -190,7 +177,7 @@
281 output_display.vlc_media_player.set_media(output_display.vlc_media)
282 # parse the metadata of the file
283 output_display.vlc_media.parse()
284- self.volume(output_display, volume)
285+ self.volume(output_display, output_display.media_info.volume)
286 return True
287
288 def media_state_wait(self, output_display, media_state):
289
290=== modified file 'openlp/core/ui/servicemanager.py'
291--- openlp/core/ui/servicemanager.py 2019-06-04 20:03:54 +0000
292+++ openlp/core/ui/servicemanager.py 2019-06-14 19:28:31 +0000
293@@ -48,7 +48,7 @@
294 from openlp.core.lib.serviceitem import ItemCapabilities, ServiceItem
295 from openlp.core.lib.ui import create_widget_action, critical_error_message_box, find_and_set_in_combo_box
296 from openlp.core.ui.icons import UiIcons
297-from openlp.core.ui.media.vlcplayer import AUDIO_EXT, VIDEO_EXT
298+from openlp.core.ui.media import AUDIO_EXT, VIDEO_EXT
299 from openlp.core.ui.serviceitemeditform import ServiceItemEditForm
300 from openlp.core.ui.servicenoteform import ServiceNoteForm
301 from openlp.core.ui.starttimeform import StartTimeForm
302
303=== modified file 'openlp/core/ui/themeform.py'
304--- openlp/core/ui/themeform.py 2019-06-07 20:25:30 +0000
305+++ openlp/core/ui/themeform.py 2019-06-14 19:28:31 +0000
306@@ -32,7 +32,7 @@
307 from openlp.core.common.registry import Registry
308 from openlp.core.lib.theme import BackgroundGradientType, BackgroundType
309 from openlp.core.lib.ui import critical_error_message_box
310-from openlp.core.ui.media.vlcplayer import VIDEO_EXT
311+from openlp.core.ui.media import VIDEO_EXT
312 from openlp.core.ui.themelayoutform import ThemeLayoutForm
313 from openlp.core.ui.themewizard import Ui_ThemeWizard
314
315
316=== modified file 'openlp/core/widgets/widgets.py'
317--- openlp/core/widgets/widgets.py 2019-04-13 13:00:22 +0000
318+++ openlp/core/widgets/widgets.py 2019-06-14 19:28:31 +0000
319@@ -103,8 +103,8 @@
320 :param QtWidgets.QRadioButton button: The button that has toggled
321 :param bool checked: The buttons new state
322 """
323- id = self.radio_group.id(button) # The work around (see above comment)
324- enable_manual_edits = id == ProxyMode.MANUAL_PROXY and checked
325+ group_id = self.radio_group.id(button) # The work around (see above comment)
326+ enable_manual_edits = group_id == ProxyMode.MANUAL_PROXY and checked
327 self.http_edit.setEnabled(enable_manual_edits)
328 self.https_edit.setEnabled(enable_manual_edits)
329 self.username_edit.setEnabled(enable_manual_edits)
330
331=== modified file 'openlp/plugins/media/lib/mediaitem.py'
332--- openlp/plugins/media/lib/mediaitem.py 2019-06-11 05:01:02 +0000
333+++ openlp/plugins/media/lib/mediaitem.py 2019-06-14 19:28:31 +0000
334@@ -37,8 +37,8 @@
335 from openlp.core.lib.serviceitem import ItemCapabilities
336 from openlp.core.lib.ui import critical_error_message_box
337 from openlp.core.ui.icons import UiIcons
338-from openlp.core.ui.media import parse_optical_path, format_milliseconds
339-from openlp.core.ui.media.vlcplayer import AUDIO_EXT, VIDEO_EXT, get_vlc
340+from openlp.core.ui.media import parse_optical_path, format_milliseconds, AUDIO_EXT, VIDEO_EXT
341+from openlp.core.ui.media.vlcplayer import get_vlc
342
343
344 if get_vlc() is not None:
345@@ -175,7 +175,11 @@
346 return False
347 filename = str(item.data(QtCore.Qt.UserRole))
348 # Special handling if the filename is a optical clip
349- if filename.startswith('optical:'):
350+ if filename == 'live':
351+ service_item.processor = 'vlc'
352+ service_item.title = filename
353+ service_item.add_capability(ItemCapabilities.CanStream)
354+ elif filename.startswith('optical:'):
355 (name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(filename)
356 if not os.path.exists(name):
357 if not remote:
358@@ -232,9 +236,9 @@
359 """
360 # self.populate_display_types()
361 self.on_new_file_masks = translate('MediaPlugin.MediaItem',
362- 'Videos (*.{video});;Audio (*.{audio});;{files} '
363- '(*)').format(video=' *.'.join(VIDEO_EXT),
364- audio=' *.'.join(AUDIO_EXT),
365+ 'Videos ({video});;Audio ({audio});;{files} '
366+ '(*)').format(video=' '.join(VIDEO_EXT),
367+ audio=' '.join(AUDIO_EXT),
368 files=UiStrings().AllFiles)
369
370 def on_delete_click(self):
371@@ -258,6 +262,12 @@
372 """
373 # TODO needs to be fixed as no idea why this fails
374 # media.sort(key=lambda file_path: get_natural_key(file_path.name))
375+ file_name = translate('MediaPlugin.MediaItem', 'Live Stream')
376+ item_name = QtWidgets.QListWidgetItem(file_name)
377+ item_name.setIcon(UiIcons().video)
378+ item_name.setData(QtCore.Qt.UserRole, 'live')
379+ item_name.setToolTip(translate('MediaPlugin.MediaItem', 'Show Live Stream'))
380+ self.list_view.addItem(item_name)
381 for track in media:
382 track_str = str(track)
383 track_info = QtCore.QFileInfo(track_str)
384
385=== modified file 'tests/functional/openlp_core/ui/media/test_mediacontroller.py'
386--- tests/functional/openlp_core/ui/media/test_mediacontroller.py 2019-05-31 20:19:15 +0000
387+++ tests/functional/openlp_core/ui/media/test_mediacontroller.py 2019-06-14 19:28:31 +0000
388@@ -27,6 +27,7 @@
389
390 from openlp.core.common.registry import Registry
391 from openlp.core.ui.media.mediacontroller import MediaController
392+from openlp.core.ui.media import ItemMediaInfo
393 from tests.helpers.testmixin import TestMixin
394
395 from tests.utils.constants import RESOURCE_PATH
396@@ -57,7 +58,7 @@
397 # THEN: The player's resize method should be called correctly
398 mocked_player.resize.assert_called_with(mocked_display)
399
400- def test_check_file_type(self):
401+ def test_check_file_type_null(self):
402 """
403 Test that we don't try to play media when no players available
404 """
405@@ -71,7 +72,47 @@
406 ret = media_controller._check_file_type(mocked_controller, mocked_display)
407
408 # THEN: it should return False
409- assert ret is False, '_check_file_type should return False when no mediaplayers are available.'
410+ assert ret is False, '_check_file_type should return False when no media file matches.'
411+
412+ def test_check_file_video(self):
413+ """
414+ Test that we process a file that is valid
415+ """
416+ # GIVEN: A mocked UiStrings, get_used_players, controller, display and service_item
417+ media_controller = MediaController()
418+ mocked_controller = MagicMock()
419+ mocked_display = MagicMock()
420+ media_controller.media_players = MagicMock()
421+ mocked_controller.media_info = ItemMediaInfo()
422+ mocked_controller.media_info.file_info = [TEST_PATH / 'mp3_file.mp3']
423+ media_controller.current_media_players = {}
424+ media_controller.vlc_player = MagicMock()
425+
426+ # WHEN: calling _check_file_type when no players exists
427+ ret = media_controller._check_file_type(mocked_controller, mocked_display)
428+
429+ # THEN: it should return False
430+ assert ret is True, '_check_file_type should return True when audio file is present and matches.'
431+
432+ def test_check_file_audio(self):
433+ """
434+ Test that we process a file that is valid
435+ """
436+ # GIVEN: A mocked UiStrings, get_used_players, controller, display and service_item
437+ media_controller = MediaController()
438+ mocked_controller = MagicMock()
439+ mocked_display = MagicMock()
440+ media_controller.media_players = MagicMock()
441+ mocked_controller.media_info = ItemMediaInfo()
442+ mocked_controller.media_info.file_info = [TEST_PATH / 'mp4_file.mp4']
443+ media_controller.current_media_players = {}
444+ media_controller.vlc_player = MagicMock()
445+
446+ # WHEN: calling _check_file_type when no players exists
447+ ret = media_controller._check_file_type(mocked_controller, mocked_display)
448+
449+ # THEN: it should return False
450+ assert ret is True, '_check_file_type should return True when media file is present and matches.'
451
452 def test_media_play_msg(self):
453 """