openlp/openlp/core/ui/media/__init__.py

118 lines
4.3 KiB
Python
Raw Normal View History

2011-07-10 21:43:07 +00:00
# -*- coding: utf-8 -*-
2012-12-11 19:55:47 +00:00
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
2011-07-10 21:43:07 +00:00
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
2013-12-24 08:56:50 +00:00
# Copyright (c) 2008-2014 Raoul Snyman #
# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
# 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, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
2011-07-10 21:43:07 +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 #
###############################################################################
"""
The :mod:`~openlp.core.ui.media` module contains classes and objects for media player integration.
"""
2012-03-16 21:52:15 +00:00
import logging
2013-10-13 20:36:42 +00:00
from openlp.core.common import Settings
2012-05-17 15:13:09 +00:00
2012-03-16 21:52:15 +00:00
from PyQt4 import QtCore
log = logging.getLogger(__name__)
2011-07-10 21:43:07 +00:00
2011-07-10 21:43:07 +00:00
class MediaState(object):
"""
2012-03-16 21:52:15 +00:00
An enumeration for possible States of the Media Player
2011-07-10 21:43:07 +00:00
"""
2012-03-16 21:52:15 +00:00
Off = 0
Loaded = 1
2011-07-10 21:43:07 +00:00
Playing = 2
2012-03-16 21:52:15 +00:00
Paused = 3
Stopped = 4
2011-07-10 21:43:07 +00:00
2011-09-22 18:22:35 +00:00
2011-07-10 21:43:07 +00:00
class MediaType(object):
"""
2012-09-09 06:06:44 +00:00
An enumeration of possible Media Types
2011-07-10 21:43:07 +00:00
"""
2011-08-29 19:55:58 +00:00
Unused = 0
Audio = 1
Video = 2
2011-08-29 21:51:03 +00:00
CD = 3
DVD = 4
2011-08-29 19:55:58 +00:00
Folder = 5
2011-07-10 21:43:07 +00:00
2011-09-22 18:22:35 +00:00
2011-07-10 21:43:07 +00:00
class MediaInfo(object):
"""
2012-09-09 06:06:44 +00:00
This class hold the media related info
2011-07-10 21:43:07 +00:00
"""
file_info = None
volume = 100
2011-08-29 19:55:58 +00:00
is_flash = False
2011-07-10 21:43:07 +00:00
is_background = False
length = 0
start_time = 0
end_time = 0
media_type = MediaType()
2012-03-16 21:52:15 +00:00
def get_media_players():
"""
2012-09-14 16:35:07 +00:00
This method extracts the configured media players and overridden player
from the settings.
2012-03-16 21:52:15 +00:00
"""
2013-08-31 18:17:38 +00:00
log.debug('get_media_players')
saved_players = Settings().value('media/players')
2012-03-16 21:52:15 +00:00
reg_ex = QtCore.QRegExp(".*\[(.*)\].*")
2013-08-31 18:17:38 +00:00
if Settings().value('media/override player') == QtCore.Qt.Checked:
2012-09-14 16:35:07 +00:00
if reg_ex.exactMatch(saved_players):
2013-08-31 18:17:38 +00:00
overridden_player = '%s' % reg_ex.cap(1)
2012-03-16 21:52:15 +00:00
else:
2013-08-31 18:17:38 +00:00
overridden_player = 'auto'
2012-03-16 21:52:15 +00:00
else:
2013-08-31 18:17:38 +00:00
overridden_player = ''
saved_players_list = saved_players.replace('[', '').replace(']', '').split(',')
2012-09-14 16:35:07 +00:00
return saved_players_list, overridden_player
2012-03-16 21:52:15 +00:00
2012-04-28 11:13:16 +00:00
2013-08-31 18:17:38 +00:00
def set_media_players(players_list, overridden_player='auto'):
2012-03-16 21:52:15 +00:00
"""
This method saves the configured media players and overridden player to the
settings
2012-03-19 19:27:02 +00:00
``players_list``
2012-04-28 11:13:16 +00:00
A list with all active media players.
2012-03-19 19:27:02 +00:00
``overridden_player``
2012-04-28 11:13:16 +00:00
Here an special media player is chosen for all media actions.
2012-03-16 21:52:15 +00:00
"""
2013-08-31 18:17:38 +00:00
log.debug('set_media_players')
players = ','.join(players_list)
if Settings().value('media/override player') == QtCore.Qt.Checked and overridden_player != 'auto':
players = players.replace(overridden_player, '[%s]' % overridden_player)
Settings().setValue('media/players', players)
2012-03-16 21:52:15 +00:00
2013-08-31 18:17:38 +00:00
from .mediacontroller import MediaController
from .playertab import PlayerTab
2013-08-31 18:17:38 +00:00
__all__ = ['MediaController', 'PlayerTab']