diff --git a/openlp/core/display/html/display.js b/openlp/core/display/html/display.js index 33d323ca2..4c85c5b70 100644 --- a/openlp/core/display/html/display.js +++ b/openlp/core/display/html/display.js @@ -133,6 +133,9 @@ AudioPlayer.prototype.createAudioElement = function () { this._audioElement.addEventListener("volumechange", this._callListener); this._audioElement.addEventListener("durationchange", this._callListener); this._audioElement.addEventListener("loadeddata", this._callListener); + document.addEventListener("complete", function(event) { + document.body.appendChild(this._audioElement); + }); }; AudioPlayer.prototype.addEventListener = function (eventType, listener) { this._eventListeners[eventType] = this._eventListeners[eventType] || []; @@ -599,6 +602,26 @@ var Display = { footer.style.setProperty(key, footerStyle[key]); } } + }, + /** + * Return the video types supported by the video tag + */ + getVideoTypes: function () { + var videoElement = document.createElement('video'); + var videoTypes = []; + if (videoElement.canPlayType('video/mp4; codecs="mp4v.20.8"') == "probably" || + videoElement.canPlayType('video/mp4; codecs="avc1.42E01E"') == "pobably" || + videoElement.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"') == "probably") { + videoTypes.push(['video/mp4', '*.mp4']); + } + if (videoElement.canPlayType('video/ogg; codecs="theora"') == "probably") { + videoTypes.push(['video/ogg', '*.ogv']); + } + if (videoElement.canPlayType('video/webm; codecs="vp8, vorbis"') == "probably") { + videoTypes.push(['video/webm', '*.webm']); + } + return videoTypes; + } } }; new QWebChannel(qt.webChannelTransport, function (channel) { diff --git a/openlp/core/display/window.py b/openlp/core/display/window.py index 1b97077fd..7057794e7 100644 --- a/openlp/core/display/window.py +++ b/openlp/core/display/window.py @@ -1,10 +1,36 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2017 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; version 2 of the License. # +# # +# 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, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +The :mod:`~openlp.core.display.window` module contains the display window +""" import logging import os import json +from pathlib import Path from PyQt5 import QtCore, QtWidgets, QtWebChannel log = logging.getLogger(__name__) +DISPLAY_PATH = Path(__file__) / 'html' / 'display.html' class MediaWatcher(QtCore.QObject): @@ -140,14 +166,14 @@ class DisplayWindow(QtWidgets.QWidget): QtWidgets.QApplication.instance().processEvents() return self.__script_result - def set_verses(self, verses): + def load_verses(self, verses): """ Set verses in the display """ json_verses = json.dumps(verses) self.run_javascript('Display.setTextSlides({verses});'.format(verses=json_verses)) - def set_images(self, images): + def load_images(self, images): """ Set images in the display """ @@ -157,9 +183,9 @@ class DisplayWindow(QtWidgets.QWidget): json_images = json.dumps(images) self.run_javascript('Display.setImageSlides({images});'.format(images=json_images)) - def set_video(self, video): + def load_video(self, video): """ - Set video in the display + Load video in the display """ if not video['file'].startswith('file://'): video['file'] = 'file://' + video['file'] @@ -231,3 +257,9 @@ class DisplayWindow(QtWidgets.QWidget): """ print(theme.export_theme()) self.run_javascript('Display.setTheme({theme});'.format(theme=theme.export_theme())) + + def get_video_types(self): + """ + Get the types of videos playable by the embedded media player + """ + return self.run_javascript('Display.getVideoTypes();', is_sync=True)