2008-12-14 16:19:28 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-12-10 06:15:42 +00:00
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
2008-12-14 16:19:28 +00:00
|
|
|
|
2009-09-08 19:58:05 +00:00
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2012-12-29 20:56:56 +00:00
|
|
|
# Copyright (c) 2008-2013 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
|
2012-06-22 14:14:53 +00:00
|
|
|
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
2012-11-11 21:16:14 +00:00
|
|
|
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
2012-10-21 13:16:22 +00:00
|
|
|
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
|
|
|
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
|
|
|
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
2012-12-01 07:57:54 +00:00
|
|
|
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
2009-09-08 19:58:05 +00:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# 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 #
|
|
|
|
###############################################################################
|
2008-12-14 16:19:28 +00:00
|
|
|
|
2009-10-08 05:02:39 +00:00
|
|
|
import logging
|
2010-06-08 15:38:09 +00:00
|
|
|
|
2011-12-15 20:13:45 +00:00
|
|
|
from PyQt4 import QtCore
|
|
|
|
|
2013-01-16 11:28:38 +00:00
|
|
|
from openlp.core.lib import Plugin, StringContent, build_icon, translate, Settings
|
2011-07-10 21:43:07 +00:00
|
|
|
from openlp.plugins.media.lib import MediaMediaItem, MediaTab
|
2009-09-21 19:23:51 +00:00
|
|
|
|
2010-02-27 09:55:44 +00:00
|
|
|
log = logging.getLogger(__name__)
|
2013-01-10 20:50:01 +00:00
|
|
|
|
2013-01-16 19:37:47 +00:00
|
|
|
# Some settings starting with "media" are in core, because they are needed for core functionality.
|
2013-01-10 20:41:16 +00:00
|
|
|
__default_settings__ = {
|
2013-01-16 11:37:22 +00:00
|
|
|
u'media/media auto start': QtCore.Qt.Unchecked
|
2013-01-10 20:09:27 +00:00
|
|
|
}
|
2010-02-27 09:55:44 +00:00
|
|
|
|
2013-01-10 20:50:01 +00:00
|
|
|
|
2009-05-15 05:15:53 +00:00
|
|
|
class MediaPlugin(Plugin):
|
2010-02-27 09:55:44 +00:00
|
|
|
log.info(u'%s MediaPlugin loaded', __name__)
|
2009-03-02 22:12:14 +00:00
|
|
|
|
2009-03-22 07:13:34 +00:00
|
|
|
def __init__(self, plugin_helpers):
|
2013-01-10 20:41:16 +00:00
|
|
|
Plugin.__init__(self, u'media', __default_settings__, plugin_helpers, MediaMediaItem)
|
2008-12-14 19:50:17 +00:00
|
|
|
self.weight = -6
|
2012-04-22 19:37:11 +00:00
|
|
|
self.iconPath = u':/plugins/plugin_media.png'
|
|
|
|
self.icon = build_icon(self.iconPath)
|
2009-06-26 17:51:43 +00:00
|
|
|
# passed with drag and drop messages
|
2009-09-29 02:54:32 +00:00
|
|
|
self.dnd_id = u'Media'
|
2009-02-28 23:19:45 +00:00
|
|
|
|
2011-12-07 20:25:12 +00:00
|
|
|
def createSettingsTab(self, parent):
|
2011-06-08 13:18:05 +00:00
|
|
|
"""
|
|
|
|
Create the settings Tab
|
|
|
|
"""
|
|
|
|
visible_name = self.getString(StringContent.VisibleName)
|
2012-12-10 06:15:42 +00:00
|
|
|
self.settingsTab = MediaTab(parent, self.name, visible_name[u'title'], self.iconPath)
|
2011-06-08 13:18:05 +00:00
|
|
|
|
2009-10-01 16:56:42 +00:00
|
|
|
def about(self):
|
2010-07-23 18:03:19 +00:00
|
|
|
about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>'
|
|
|
|
'<br />The media plugin provides playback of audio and video.')
|
2010-07-27 09:32:52 +00:00
|
|
|
return about_text
|
2010-09-16 21:10:36 +00:00
|
|
|
|
2010-09-27 18:15:55 +00:00
|
|
|
def setPluginTextStrings(self):
|
2010-09-10 19:21:14 +00:00
|
|
|
"""
|
|
|
|
Called to define all translatable texts of the plugin
|
|
|
|
"""
|
2010-09-15 17:55:27 +00:00
|
|
|
## Name PluginList ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.Name] = {
|
2010-12-31 02:17:41 +00:00
|
|
|
u'singular': translate('MediaPlugin', 'Media', 'name singular'),
|
|
|
|
u'plural': translate('MediaPlugin', 'Media', 'name plural')
|
2010-09-15 17:55:27 +00:00
|
|
|
}
|
|
|
|
## Name for MediaDockManager, SettingsManager ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.VisibleName] = {
|
2010-12-31 02:17:41 +00:00
|
|
|
u'title': translate('MediaPlugin', 'Media', 'container title')
|
2010-09-10 19:21:14 +00:00
|
|
|
}
|
|
|
|
# Middle Header Bar
|
2011-02-14 17:25:51 +00:00
|
|
|
tooltips = {
|
2011-06-12 07:51:50 +00:00
|
|
|
u'load': translate('MediaPlugin', 'Load new media.'),
|
2011-02-14 19:08:18 +00:00
|
|
|
u'import': u'',
|
2011-06-12 07:51:50 +00:00
|
|
|
u'new': translate('MediaPlugin', 'Add new media.'),
|
2011-06-11 21:43:08 +00:00
|
|
|
u'edit': translate('MediaPlugin', 'Edit the selected media.'),
|
|
|
|
u'delete': translate('MediaPlugin', 'Delete the selected media.'),
|
|
|
|
u'preview': translate('MediaPlugin', 'Preview the selected media.'),
|
|
|
|
u'live': translate('MediaPlugin', 'Send the selected media live.'),
|
2012-12-10 06:15:42 +00:00
|
|
|
u'service': translate('MediaPlugin', 'Add the selected media to the service.')
|
2011-02-14 17:25:51 +00:00
|
|
|
}
|
|
|
|
self.setPluginUiTextStrings(tooltips)
|
2011-05-10 20:39:17 +00:00
|
|
|
|
|
|
|
def finalise(self):
|
|
|
|
"""
|
|
|
|
Time to tidy up on exit
|
|
|
|
"""
|
|
|
|
log.info(u'Media Finalising')
|
2011-08-30 16:54:45 +00:00
|
|
|
self.mediaController.finalise()
|
2011-08-29 19:55:58 +00:00
|
|
|
Plugin.finalise(self)
|
2011-06-08 13:18:05 +00:00
|
|
|
|
2011-06-14 16:10:20 +00:00
|
|
|
def getDisplayCss(self):
|
2011-06-08 13:18:05 +00:00
|
|
|
"""
|
|
|
|
Add css style sheets to htmlbuilder
|
|
|
|
"""
|
2011-08-30 16:54:45 +00:00
|
|
|
return self.mediaController.get_media_display_css()
|
2011-06-08 13:18:05 +00:00
|
|
|
|
2011-08-29 21:51:03 +00:00
|
|
|
def getDisplayJavaScript(self):
|
2011-06-08 13:18:05 +00:00
|
|
|
"""
|
|
|
|
Add javascript functions to htmlbuilder
|
|
|
|
"""
|
2011-08-30 16:54:45 +00:00
|
|
|
return self.mediaController.get_media_display_javascript()
|
2011-06-08 13:18:05 +00:00
|
|
|
|
2011-06-14 16:10:20 +00:00
|
|
|
def getDisplayHtml(self):
|
2011-06-08 13:18:05 +00:00
|
|
|
"""
|
|
|
|
Add html code to htmlbuilder
|
|
|
|
"""
|
2011-08-30 16:54:45 +00:00
|
|
|
return self.mediaController.get_media_display_html()
|
2011-12-15 20:13:45 +00:00
|
|
|
|
|
|
|
def appStartup(self):
|
|
|
|
"""
|
|
|
|
Do a couple of things when the app starts up. In this particular case
|
|
|
|
we want to check if we have the old "Use Phonon" setting, and convert
|
|
|
|
it to "enable Phonon" and "make it the first one in the list".
|
|
|
|
"""
|
2012-05-17 15:13:09 +00:00
|
|
|
settings = Settings()
|
2011-12-15 20:13:45 +00:00
|
|
|
settings.beginGroup(self.settingsSection)
|
|
|
|
if settings.contains(u'use phonon'):
|
|
|
|
log.info(u'Found old Phonon setting')
|
2011-12-15 21:06:50 +00:00
|
|
|
players = self.mediaController.mediaPlayers.keys()
|
|
|
|
has_phonon = u'phonon' in players
|
2012-05-19 15:10:05 +00:00
|
|
|
if settings.value(u'use phonon') and has_phonon:
|
2011-12-15 20:13:45 +00:00
|
|
|
log.debug(u'Converting old setting to new setting')
|
|
|
|
new_players = []
|
|
|
|
if players:
|
2012-12-10 06:15:42 +00:00
|
|
|
new_players = [player for player in players if player != u'phonon']
|
2011-12-15 20:13:45 +00:00
|
|
|
new_players.insert(0, u'phonon')
|
2011-12-15 21:06:50 +00:00
|
|
|
self.mediaController.mediaPlayers[u'phonon'].isActive = True
|
2012-05-17 15:13:09 +00:00
|
|
|
settings.setValue(u'players', u','.join(new_players))
|
2012-04-21 22:29:08 +00:00
|
|
|
self.settingsTab.load()
|
2011-12-15 20:13:45 +00:00
|
|
|
settings.remove(u'use phonon')
|
2011-12-15 21:06:50 +00:00
|
|
|
settings.endGroup()
|