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

Proposed by Tim Bentley
Status: Merged
Approved by: Raoul Snyman
Approved revision: 2694
Merged at revision: 2659
Proposed branch: lp:~trb143/openlp/background_videos
Merge into: lp:openlp
Diff against target: 484 lines (+185/-33)
10 files modified
openlp/core/common/uistrings.py (+1/-0)
openlp/core/lib/theme.py (+24/-1)
openlp/core/ui/maindisplay.py (+22/-9)
openlp/core/ui/media/webkitplayer.py (+2/-9)
openlp/core/ui/servicemanager.py (+1/-1)
openlp/core/ui/themeform.py (+41/-3)
openlp/core/ui/thememanager.py (+2/-2)
openlp/core/ui/themewizard.py (+30/-5)
scripts/translation_utils.py (+2/-2)
tests/functional/openlp_core_ui/test_maindisplay.py (+60/-1)
To merge this branch: bzr merge lp:~trb143/openlp/background_videos
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Review via email: mp+294184@code.launchpad.net

This proposal supersedes a proposal from 2016-05-02.

Commit message

Allow themes to have video files so allow for background videos behind text.

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

Only problem is that Transifex has deprecated the .net and now uses .com.

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

Also, mediainfo spews out a lot of junk on the console, any way to suppress this?

Revision history for this message
Raoul Snyman (raoul-snyman) :
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/uistrings.py'
2--- openlp/core/common/uistrings.py 2016-04-16 19:51:35 +0000
3+++ openlp/core/common/uistrings.py 2016-05-10 04:42:35 +0000
4@@ -152,3 +152,4 @@
5 self.Version = translate('OpenLP.Ui', 'Version')
6 self.View = translate('OpenLP.Ui', 'View')
7 self.ViewMode = translate('OpenLP.Ui', 'View Mode')
8+ self.Video = translate('OpenLP.Ui', 'Video')
9
10=== modified file 'openlp/core/lib/theme.py'
11--- openlp/core/lib/theme.py 2015-12-31 22:46:06 +0000
12+++ openlp/core/lib/theme.py 2016-05-10 04:42:35 +0000
13@@ -44,6 +44,7 @@
14 Gradient = 1
15 Image = 2
16 Transparent = 3
17+ Video = 4
18
19 @staticmethod
20 def to_string(background_type):
21@@ -58,6 +59,8 @@
22 return 'image'
23 elif background_type == BackgroundType.Transparent:
24 return 'transparent'
25+ elif background_type == BackgroundType.Video:
26+ return 'video'
27
28 @staticmethod
29 def from_string(type_string):
30@@ -72,6 +75,8 @@
31 return BackgroundType.Image
32 elif type_string == 'transparent':
33 return BackgroundType.Transparent
34+ elif type_string == 'video':
35+ return BackgroundType.Video
36
37
38 class BackgroundGradientType(object):
39@@ -184,7 +189,7 @@
40
41 :param path: The path name to be added.
42 """
43- if self.background_type == 'image':
44+ if self.background_type == 'image' or self.background_type == 'video':
45 if self.background_filename and path:
46 self.theme_name = self.theme_name.strip()
47 self.background_filename = self.background_filename.strip()
48@@ -255,6 +260,21 @@
49 # Create endColor element
50 self.child_element(background, 'borderColor', str(border_color))
51
52+ def add_background_video(self, filename, border_color):
53+ """
54+ Add a video background.
55+
56+ :param filename: The file name of the video.
57+ :param border_color:
58+ """
59+ background = self.theme_xml.createElement('background')
60+ background.setAttribute('type', 'video')
61+ self.theme.appendChild(background)
62+ # Create Filename element
63+ self.child_element(background, 'filename', filename)
64+ # Create endColor element
65+ self.child_element(background, 'borderColor', str(border_color))
66+
67 def add_font(self, name, color, size, override, fonttype='main', bold='False', italics='False',
68 line_adjustment=0, xpos=0, ypos=0, width=0, height=0, outline='False', outline_color='#ffffff',
69 outline_pixel=2, shadow='False', shadow_color='#ffffff', shadow_pixel=5):
70@@ -512,6 +532,9 @@
71 elif self.background_type == BackgroundType.to_string(BackgroundType.Image):
72 filename = os.path.split(self.background_filename)[1]
73 self.add_background_image(filename, self.background_border_color)
74+ elif self.background_type == BackgroundType.to_string(BackgroundType.Video):
75+ filename = os.path.split(self.background_filename)[1]
76+ self.add_background_video(filename, self.background_border_color)
77 elif self.background_type == BackgroundType.to_string(BackgroundType.Transparent):
78 self.add_background_transparent()
79 self.add_font(
80
81=== modified file 'openlp/core/ui/maindisplay.py'
82--- openlp/core/ui/maindisplay.py 2016-04-29 20:25:12 +0000
83+++ openlp/core/ui/maindisplay.py 2016-05-10 04:42:35 +0000
84@@ -31,13 +31,15 @@
85
86 import html
87 import logging
88+import os
89
90 from PyQt5 import QtCore, QtWidgets, QtWebKit, QtWebKitWidgets, QtOpenGL, QtGui, QtMultimedia
91
92-from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, Settings, translate, is_macosx, is_win
93+from openlp.core.common import AppLocation, Registry, RegistryProperties, OpenLPMixin, Settings, translate,\
94+ is_macosx, is_win
95 from openlp.core.lib import ServiceItem, ImageSource, ScreenList, build_html, expand_tags, image_to_byte
96 from openlp.core.lib.theme import BackgroundType
97-from openlp.core.ui import HideMode, AlertLocation
98+from openlp.core.ui import HideMode, AlertLocation, DisplayControllerType
99
100 if is_macosx():
101 from ctypes import pythonapi, c_void_p, c_char_p, py_object
102@@ -459,13 +461,13 @@
103 background = self.image_manager.get_image_bytes(self.override['image'], ImageSource.ImagePlugin)
104 self.set_transparency(self.service_item.theme_data.background_type ==
105 BackgroundType.to_string(BackgroundType.Transparent))
106- if self.service_item.theme_data.background_filename:
107- self.service_item.bg_image_bytes = self.image_manager.get_image_bytes(
108- self.service_item.theme_data.background_filename, ImageSource.Theme)
109- if image_path:
110- image_bytes = self.image_manager.get_image_bytes(image_path, ImageSource.ImagePlugin)
111- else:
112- image_bytes = None
113+ image_bytes = None
114+ if self.service_item.theme_data.background_type == 'image':
115+ if self.service_item.theme_data.background_filename:
116+ self.service_item.bg_image_bytes = self.image_manager.get_image_bytes(
117+ self.service_item.theme_data.background_filename, ImageSource.Theme)
118+ if image_path:
119+ image_bytes = self.image_manager.get_image_bytes(image_path, ImageSource.ImagePlugin)
120 html = build_html(self.service_item, self.screen, self.is_live, background, image_bytes,
121 plugins=self.plugin_manager.plugins)
122 self.web_view.setHtml(html)
123@@ -477,6 +479,17 @@
124 Registry().execute('slidecontroller_live_unblank')
125 else:
126 self.hide_display(self.hide_mode)
127+ if self.service_item.theme_data.background_type == 'video' and self.is_live:
128+ if self.service_item.theme_data.background_filename:
129+ service_item = ServiceItem()
130+ service_item.title = 'webkit'
131+ service_item.processor = 'webkit'
132+ path = os.path.join(AppLocation.get_section_data_path('themes'),
133+ self.service_item.theme_data.theme_name)
134+ service_item.add_from_command(path,
135+ self.service_item.theme_data.background_filename,
136+ ':/media/slidecontroller_multimedia.png')
137+ self.media_controller.video(DisplayControllerType.Live, service_item, video_behind_text=True)
138 self._hide_mouse()
139
140 def footer(self, text):
141
142=== modified file 'openlp/core/ui/media/webkitplayer.py'
143--- openlp/core/ui/media/webkitplayer.py 2016-02-26 16:00:04 +0000
144+++ openlp/core/ui/media/webkitplayer.py 2016-05-10 04:42:35 +0000
145@@ -45,7 +45,7 @@
146 """
147
148 VIDEO_JS = """
149- function show_video(state, path, volume, loop, variable_value){
150+ function show_video(state, path, volume, variable_value){
151 // Sometimes video.currentTime stops slightly short of video.duration and video.ended is intermittent!
152
153 var video = document.getElementById('video');
154@@ -55,9 +55,6 @@
155 switch(state){
156 case 'load':
157 video.src = 'file:///' + path;
158- if(loop == true) {
159- video.loop = true;
160- }
161 video.load();
162 break;
163 case 'play':
164@@ -180,12 +177,8 @@
165 else:
166 vol = 0
167 path = controller.media_info.file_info.absoluteFilePath()
168- if controller.media_info.is_background:
169- loop = 'true'
170- else:
171- loop = 'false'
172 display.web_view.setVisible(True)
173- js = 'show_video("load", "%s", %s, %s);' % (path.replace('\\', '\\\\'), str(vol), loop)
174+ js = 'show_video("load", "{path}", {vol});'.format(path=path.replace('\\', '\\\\'), vol=str(vol))
175 display.frame.evaluateJavaScript(js)
176 return True
177
178
179=== modified file 'openlp/core/ui/servicemanager.py'
180--- openlp/core/ui/servicemanager.py 2016-04-17 19:32:15 +0000
181+++ openlp/core/ui/servicemanager.py 2016-05-10 04:42:35 +0000
182@@ -1323,7 +1323,7 @@
183 """
184 The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state.
185 """
186- visible = self.renderer.theme_level == ThemeLevel.Global
187+ visible = not self.renderer.theme_level == ThemeLevel.Global
188 self.theme_label.setVisible(visible)
189 self.theme_combo_box.setVisible(visible)
190
191
192=== modified file 'openlp/core/ui/themeform.py'
193--- openlp/core/ui/themeform.py 2016-04-17 18:57:03 +0000
194+++ openlp/core/ui/themeform.py 2016-05-10 04:42:35 +0000
195@@ -31,7 +31,7 @@
196 from openlp.core.lib.theme import BackgroundType, BackgroundGradientType
197 from openlp.core.lib.ui import critical_error_message_box
198 from openlp.core.ui import ThemeLayoutForm
199-from openlp.core.ui.lib.colorbutton import ColorButton
200+from openlp.core.ui.media.webkitplayer import VIDEO_EXT
201 from .themewizard import Ui_ThemeWizard
202
203 log = logging.getLogger(__name__)
204@@ -66,10 +66,13 @@
205 self.gradient_combo_box.currentIndexChanged.connect(self.on_gradient_combo_box_current_index_changed)
206 self.color_button.colorChanged.connect(self.on_color_changed)
207 self.image_color_button.colorChanged.connect(self.on_image_color_changed)
208+ self.video_color_button.colorChanged.connect(self.on_video_color_changed)
209 self.gradient_start_button.colorChanged.connect(self.on_gradient_start_color_changed)
210 self.gradient_end_button.colorChanged.connect(self.on_gradient_end_color_changed)
211 self.image_browse_button.clicked.connect(self.on_image_browse_button_clicked)
212 self.image_file_edit.editingFinished.connect(self.on_image_file_edit_editing_finished)
213+ self.video_browse_button.clicked.connect(self.on_video_browse_button_clicked)
214+ self.video_file_edit.editingFinished.connect(self.on_video_file_edit_editing_finished)
215 self.main_color_button.colorChanged.connect(self.on_main_color_changed)
216 self.outline_color_button.colorChanged.connect(self.on_outline_color_changed)
217 self.shadow_color_button.colorChanged.connect(self.on_shadow_color_changed)
218@@ -307,6 +310,10 @@
219 self.image_color_button.color = self.theme.background_border_color
220 self.image_file_edit.setText(self.theme.background_filename)
221 self.setField('background_type', 2)
222+ elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Video):
223+ self.video_color_button.color = self.theme.background_border_color
224+ self.video_file_edit.setText(self.theme.background_filename)
225+ self.setField('background_type', 4)
226 elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Transparent):
227 self.setField('background_type', 3)
228 if self.theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal):
229@@ -384,10 +391,12 @@
230 if self.update_theme_allowed:
231 self.theme.background_type = BackgroundType.to_string(index)
232 if self.theme.background_type != BackgroundType.to_string(BackgroundType.Image) and \
233+ self.theme.background_type != BackgroundType.to_string(BackgroundType.Video) and \
234 self.temp_background_filename == '':
235 self.temp_background_filename = self.theme.background_filename
236 self.theme.background_filename = ''
237- if self.theme.background_type == BackgroundType.to_string(BackgroundType.Image) and \
238+ if (self.theme.background_type == BackgroundType.to_string(BackgroundType.Image) or
239+ self.theme.background_type != BackgroundType.to_string(BackgroundType.Video)) and \
240 self.temp_background_filename != '':
241 self.theme.background_filename = self.temp_background_filename
242 self.temp_background_filename = ''
243@@ -413,6 +422,12 @@
244 """
245 self.theme.background_border_color = color
246
247+ def on_video_color_changed(self, color):
248+ """
249+ Background / Gradient 1 _color button pushed.
250+ """
251+ self.theme.background_border_color = color
252+
253 def on_gradient_start_color_changed(self, color):
254 """
255 Gradient 2 _color button pushed.
256@@ -444,6 +459,28 @@
257 """
258 self.theme.background_filename = str(self.image_file_edit.text())
259
260+ def on_video_browse_button_clicked(self):
261+ """
262+ Background video button pushed.
263+ """
264+ visible_formats = '(%s)' % '; '.join(VIDEO_EXT)
265+ actual_formats = '(%s)' % ' '.join(VIDEO_EXT)
266+ video_filter = '{trans} {visible} {actual}'.format(trans=translate('OpenLP', 'Video Files'),
267+ visible=visible_formats, actual=actual_formats)
268+ video_filter = '{video};;{ui} (*.*)'.format(video=video_filter, ui=UiStrings().AllFiles)
269+ filename, filter_used = QtWidgets.QFileDialog.getOpenFileName(
270+ self, translate('OpenLP.ThemeWizard', 'Select Video'),
271+ self.video_file_edit.text(), video_filter)
272+ if filename:
273+ self.theme.background_filename = filename
274+ self.set_background_page_values()
275+
276+ def on_video_file_edit_editing_finished(self):
277+ """
278+ Background video path edited
279+ """
280+ self.theme.background_filename = str(self.image_file_edit.text())
281+
282 def on_main_color_changed(self, color):
283 """
284 Set the main colour value
285@@ -519,7 +556,8 @@
286 return
287 save_from = None
288 save_to = None
289- if self.theme.background_type == BackgroundType.to_string(BackgroundType.Image):
290+ if self.theme.background_type == BackgroundType.to_string(BackgroundType.Image) or \
291+ self.theme.background_type == BackgroundType.to_string(BackgroundType.Video):
292 filename = os.path.split(str(self.theme.background_filename))[1]
293 save_to = os.path.join(self.path, self.theme.theme_name, filename)
294 save_from = self.theme.background_filename
295
296=== modified file 'openlp/core/ui/thememanager.py'
297--- openlp/core/ui/thememanager.py 2016-04-17 19:32:15 +0000
298+++ openlp/core/ui/thememanager.py 2016-05-10 04:42:35 +0000
299@@ -300,7 +300,7 @@
300 """
301 save_to = None
302 save_from = None
303- if theme_data.background_type == 'image':
304+ if theme_data.background_type == 'image' or theme_data.background_type == 'video':
305 save_to = os.path.join(self.path, new_theme_name, os.path.split(str(theme_data.background_filename))[1])
306 save_from = theme_data.background_filename
307 theme_data.theme_name = new_theme_name
308@@ -318,7 +318,7 @@
309 translate('OpenLP.ThemeManager', 'You must select a theme to edit.')):
310 item = self.theme_list_widget.currentItem()
311 theme = self.get_theme_data(item.data(QtCore.Qt.UserRole))
312- if theme.background_type == 'image':
313+ if theme.background_type == 'image' or theme.background_type == 'video':
314 self.old_background_image = theme.background_filename
315 self.theme_form.theme = theme
316 self.theme_form.exec(True)
317
318=== modified file 'openlp/core/ui/themewizard.py'
319--- openlp/core/ui/themewizard.py 2016-04-17 18:57:03 +0000
320+++ openlp/core/ui/themewizard.py 2016-05-10 04:42:35 +0000
321@@ -62,7 +62,7 @@
322 self.background_label = QtWidgets.QLabel(self.background_page)
323 self.background_label.setObjectName('background_label')
324 self.background_combo_box = QtWidgets.QComboBox(self.background_page)
325- self.background_combo_box.addItems(['', '', '', ''])
326+ self.background_combo_box.addItems(['', '', '', '', ''])
327 self.background_combo_box.setObjectName('background_combo_box')
328 self.background_type_layout.addRow(self.background_label, self.background_combo_box)
329 self.background_type_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer)
330@@ -135,6 +135,30 @@
331 self.transparent_layout.setObjectName('Transparent_layout')
332 self.background_stack.addWidget(self.transparent_widget)
333 self.background_layout.addLayout(self.background_stack)
334+ self.video_widget = QtWidgets.QWidget(self.background_page)
335+ self.video_widget.setObjectName('video_widget')
336+ self.video_layout = QtWidgets.QFormLayout(self.video_widget)
337+ self.video_layout.setContentsMargins(0, 0, 0, 0)
338+ self.video_layout.setObjectName('video_layout')
339+ self.video_color_label = QtWidgets.QLabel(self.color_widget)
340+ self.video_color_label.setObjectName('video_color_label')
341+ self.video_color_button = ColorButton(self.color_widget)
342+ self.video_color_button.setObjectName('video_color_button')
343+ self.video_layout.addRow(self.video_color_label, self.video_color_button)
344+ self.video_label = QtWidgets.QLabel(self.video_widget)
345+ self.video_label.setObjectName('video_label')
346+ self.video_file_layout = QtWidgets.QHBoxLayout()
347+ self.video_file_layout.setObjectName('video_file_layout')
348+ self.video_file_edit = QtWidgets.QLineEdit(self.video_widget)
349+ self.video_file_edit.setObjectName('video_file_edit')
350+ self.video_file_layout.addWidget(self.video_file_edit)
351+ self.video_browse_button = QtWidgets.QToolButton(self.video_widget)
352+ self.video_browse_button.setObjectName('video_browse_button')
353+ self.video_browse_button.setIcon(build_icon(':/general/general_open.png'))
354+ self.video_file_layout.addWidget(self.video_browse_button)
355+ self.video_layout.addRow(self.video_label, self.video_file_layout)
356+ self.video_layout.setItem(2, QtWidgets.QFormLayout.LabelRole, self.spacer)
357+ self.background_stack.addWidget(self.video_widget)
358 theme_wizard.addPage(self.background_page)
359 # Main Area Page
360 self.main_area_page = QtWidgets.QWizardPage()
361@@ -390,11 +414,10 @@
362 self.background_page.setSubTitle(translate('OpenLP.ThemeWizard', 'Set up your theme\'s background '
363 'according to the parameters below.'))
364 self.background_label.setText(translate('OpenLP.ThemeWizard', 'Background type:'))
365- self.background_combo_box.setItemText(BackgroundType.Solid,
366- translate('OpenLP.ThemeWizard', 'Solid color'))
367- self.background_combo_box.setItemText(BackgroundType.Gradient,
368- translate('OpenLP.ThemeWizard', 'Gradient'))
369+ self.background_combo_box.setItemText(BackgroundType.Solid, translate('OpenLP.ThemeWizard', 'Solid color'))
370+ self.background_combo_box.setItemText(BackgroundType.Gradient, translate('OpenLP.ThemeWizard', 'Gradient'))
371 self.background_combo_box.setItemText(BackgroundType.Image, UiStrings().Image)
372+ self.background_combo_box.setItemText(BackgroundType.Video, UiStrings().Video)
373 self.background_combo_box.setItemText(BackgroundType.Transparent,
374 translate('OpenLP.ThemeWizard', 'Transparent'))
375 self.color_label.setText(translate('OpenLP.ThemeWizard', 'color:'))
376@@ -413,6 +436,8 @@
377 translate('OpenLP.ThemeWizard', 'Bottom Left - Top Right'))
378 self.image_color_label.setText(translate('OpenLP.ThemeWizard', 'Background color:'))
379 self.image_label.setText('%s:' % UiStrings().Image)
380+ self.video_color_label.setText(translate('OpenLP.ThemeWizard', 'Background color:'))
381+ self.video_label.setText('%s:' % UiStrings().Video)
382 self.main_area_page.setTitle(translate('OpenLP.ThemeWizard', 'Main Area Font Details'))
383 self.main_area_page.setSubTitle(translate('OpenLP.ThemeWizard', 'Define the font and display '
384 'characteristics for the Display text'))
385
386=== modified file 'openlp/plugins/media/mediaplugin.py'
387=== modified file 'scripts/translation_utils.py'
388--- scripts/translation_utils.py 2015-12-31 22:46:06 +0000
389+++ scripts/translation_utils.py 2016-05-10 04:42:35 +0000
390@@ -60,7 +60,7 @@
391 from PyQt5 import QtCore
392 from lxml import etree, objectify
393
394-SERVER_URL = 'http://www.transifex.net/api/2/project/openlp/resource/openlp-24x/'
395+SERVER_URL = 'http://www.transifex.com/api/2/project/openlp/resource/openlp-26x/'
396 IGNORED_PATHS = ['scripts']
397 IGNORED_FILES = ['setup.py']
398
399@@ -270,7 +270,7 @@
400 return
401 else:
402 os.chdir(os.path.abspath('..'))
403- run('pylupdate4 -verbose -noobsolete openlp.pro')
404+ run('pylupdate5 -verbose -noobsolete openlp.pro')
405 os.chdir(os.path.abspath('scripts'))
406
407
408
409=== modified file 'tests/functional/openlp_core_ui/test_maindisplay.py'
410--- tests/functional/openlp_core_ui/test_maindisplay.py 2016-03-31 20:35:04 +0000
411+++ tests/functional/openlp_core_ui/test_maindisplay.py 2016-05-10 04:42:35 +0000
412@@ -27,8 +27,9 @@
413 from PyQt5 import QtCore
414
415 from openlp.core.common import Registry, is_macosx, Settings
416-from openlp.core.lib import ScreenList
417+from openlp.core.lib import ScreenList, PluginManager
418 from openlp.core.ui import MainDisplay
419+from openlp.core.ui.media import MediaController
420 from openlp.core.ui.maindisplay import TRANSPARENT_STYLESHEET, OPAQUE_STYLESHEET
421
422 from tests.helpers.testmixin import TestMixin
423@@ -223,3 +224,61 @@
424
425 # THEN: setVisible should had not been called
426 main_display.setVisible.assert_not_called()
427+
428+ @patch(u'openlp.core.ui.maindisplay.Settings')
429+ @patch(u'openlp.core.ui.maindisplay.build_html')
430+ def build_html_no_video_test(self, MockedSettings, Mocked_build_html):
431+ # GIVEN: Mocked display
432+ display = MagicMock()
433+ mocked_media_controller = MagicMock()
434+ Registry.create()
435+ Registry().register('media_controller', mocked_media_controller)
436+ main_display = MainDisplay(display)
437+ main_display.frame = MagicMock()
438+ mocked_settings = MagicMock()
439+ mocked_settings.value.return_value = False
440+ MockedSettings.return_value = mocked_settings
441+ main_display.shake_web_view = MagicMock()
442+ service_item = MagicMock()
443+ mocked_plugin = MagicMock()
444+ display.plugin_manager = PluginManager()
445+ display.plugin_manager.plugins = [mocked_plugin]
446+ main_display.web_view = MagicMock()
447+
448+ # WHEN: build_html is called with a normal service item and a non video theme.
449+ main_display.build_html(service_item)
450+
451+ # THEN: the following should had not been called
452+ self.assertEquals(main_display.web_view.setHtml.call_count, 1, 'setHTML should be called once')
453+ self.assertEquals(main_display.media_controller.video.call_count, 0,
454+ 'Media Controller video should not have been called')
455+
456+ @patch(u'openlp.core.ui.maindisplay.Settings')
457+ @patch(u'openlp.core.ui.maindisplay.build_html')
458+ def build_html_video_test(self, MockedSettings, Mocked_build_html):
459+ # GIVEN: Mocked display
460+ display = MagicMock()
461+ mocked_media_controller = MagicMock()
462+ Registry.create()
463+ Registry().register('media_controller', mocked_media_controller)
464+ main_display = MainDisplay(display)
465+ main_display.frame = MagicMock()
466+ mocked_settings = MagicMock()
467+ mocked_settings.value.return_value = False
468+ MockedSettings.return_value = mocked_settings
469+ main_display.shake_web_view = MagicMock()
470+ service_item = MagicMock()
471+ service_item.theme_data = MagicMock()
472+ service_item.theme_data.background_type = 'video'
473+ mocked_plugin = MagicMock()
474+ display.plugin_manager = PluginManager()
475+ display.plugin_manager.plugins = [mocked_plugin]
476+ main_display.web_view = MagicMock()
477+
478+ # WHEN: build_html is called with a normal service item and a video theme.
479+ main_display.build_html(service_item)
480+
481+ # THEN: the following should had not been called
482+ self.assertEquals(main_display.web_view.setHtml.call_count, 1, 'setHTML should be called once')
483+ self.assertEquals(main_display.media_controller.video.call_count, 1,
484+ 'Media Controller video should have been called once')