# -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # # Copyright (c) 2008-2011 Raoul Snyman # # Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # # Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # # Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # # Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund # # --------------------------------------------------------------------------- # # 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 # ############################################################################### import logging from PyQt4 import QtCore, QtGui, QtWebKit from openlp.core.lib import OpenLPToolbar, translate from openlp.core.ui.media import MediaAPI, MediaState log = logging.getLogger(__name__) class WebkitAPI(MediaAPI): """ Specialiced MediaAPI class to reflect Features of the QtWebkit API """ def __init__(self, parent): MediaAPI.__init__(self, parent, u'Webkit') self.parent = parent self.canBackground = True self.video_extensions_list = [ u'*.3gp' , u'*.3gpp' , u'*.3g2' , u'*.3gpp2' , u'*.aac' , u'*.flv' , u'*.f4a' , u'*.f4b' , u'*.f4p' , u'*.f4v' , u'*.mov' , u'*.m4a' , u'*.m4b' , u'*.m4p' , u'*.m4v' , u'*.mkv' , u'*.mp4' , u'*.mp3' , u'*.ogg' , u'*.ogv' , u'*.webm' , u'*.swf', u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi' ] def setup_controls(self, controller, control_panel): # no special controls pass def getDisplayCss(self): """ Add css style sheets to htmlbuilder """ css = u''' #video1 { z-index:3; } #video2 { z-index:3; } #flash { z-index:4; } ''' return css def getDisplayJavascript(self): """ Add javascript functions to htmlbuilder """ js = u''' var video_timer = null; var current_video = '1'; function show_video(state, path, volume, loop, seekVal){ // Note, the preferred method for looping would be to use the // video tag loop attribute. // But QtWebKit doesn't support this. Neither does it support the // onended event, hence the setInterval() // In addition, setting the currentTime attribute to zero to restart // the video raises an INDEX_SIZE_ERROR: DOM Exception 1 // To complicate it further, sometimes vid.currentTime stops // slightly short of vid.duration and vid.ended is intermittent! // // Note, currently the background may go black between loops. Not // desirable. Need to investigate using two