2008-12-14 16:19:28 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
2009-09-08 19:58:05 +00:00
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2009-12-31 12:52:01 +00:00
|
|
|
# Copyright (c) 2008-2010 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
2010-03-21 23:58:01 +00:00
|
|
|
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
|
|
|
|
# Thompson, Jon Tibble, Carsten Tinggaard #
|
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
|
|
|
from PyQt4.phonon import Phonon
|
|
|
|
|
2010-05-31 22:06:16 +00:00
|
|
|
from openlp.core.lib import Plugin, build_icon, PluginStatus, translate
|
2009-12-05 09:44:44 +00:00
|
|
|
from openlp.plugins.media.lib import MediaMediaItem
|
2009-09-21 19:23:51 +00:00
|
|
|
|
2010-02-27 09:55:44 +00:00
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
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):
|
2010-06-23 17:37:01 +00:00
|
|
|
Plugin.__init__(self, u'Media', u'1.9.2', plugin_helpers)
|
2008-12-14 19:50:17 +00:00
|
|
|
self.weight = -6
|
2010-07-10 01:01:14 +00:00
|
|
|
self.icon_path = u':/plugins/plugin_media.png'
|
|
|
|
self.icon = build_icon(self.icon_path)
|
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'
|
2010-02-06 10:33:33 +00:00
|
|
|
self.status = PluginStatus.Active
|
2010-02-27 14:57:33 +00:00
|
|
|
self.audio_list = u''
|
|
|
|
self.video_list = u''
|
|
|
|
for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
|
|
|
|
mimetype = unicode(mimetype)
|
|
|
|
type = mimetype.split(u'audio/x-')
|
2010-07-05 16:33:45 +00:00
|
|
|
self.audio_list, mimetype = self._addToList(self.audio_list,
|
2010-06-08 15:38:09 +00:00
|
|
|
type, mimetype)
|
2010-02-27 14:57:33 +00:00
|
|
|
type = mimetype.split(u'audio/')
|
2010-07-05 16:33:45 +00:00
|
|
|
self.audio_list, mimetype = self._addToList(self.audio_list,
|
2010-06-08 15:38:09 +00:00
|
|
|
type, mimetype)
|
2010-02-27 14:57:33 +00:00
|
|
|
type = mimetype.split(u'video/x-')
|
2010-07-05 16:33:45 +00:00
|
|
|
self.video_list, mimetype = self._addToList(self.video_list,
|
2010-06-08 15:38:09 +00:00
|
|
|
type, mimetype)
|
2010-02-27 14:57:33 +00:00
|
|
|
type = mimetype.split(u'video/')
|
2010-07-05 16:33:45 +00:00
|
|
|
self.video_list, mimetype = self._addToList(self.video_list,
|
2010-06-08 15:38:09 +00:00
|
|
|
type, mimetype)
|
2010-02-27 14:57:33 +00:00
|
|
|
|
2010-07-05 16:33:45 +00:00
|
|
|
def _addToList(self, list, value, type):
|
2010-02-27 14:57:33 +00:00
|
|
|
if len(value) == 2:
|
|
|
|
if list.find(value[1]) == -1:
|
|
|
|
list += u'*.%s ' % value[1]
|
2010-07-02 18:21:45 +00:00
|
|
|
self.serviceManager.supportedSuffixes(value[1])
|
2010-02-27 14:57:33 +00:00
|
|
|
type = u''
|
|
|
|
return list, type
|
2009-02-28 23:19:45 +00:00
|
|
|
|
2010-07-05 16:00:48 +00:00
|
|
|
def getMediaManagerItem(self):
|
2008-12-14 16:19:28 +00:00
|
|
|
# Create the MediaManagerItem object
|
2009-10-30 17:44:16 +00:00
|
|
|
return MediaMediaItem(self, self.icon, self.name)
|
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-05 16:33:45 +00:00
|
|
|
return about_text
|