fix media loading in Service bug, sync with trunk

This commit is contained in:
rimach crichter@web.de 2011-07-28 22:36:19 +02:00
commit 9af26bac34
4 changed files with 30 additions and 24 deletions

View File

@ -125,7 +125,6 @@ class MediaManager(object):
else: else:
return False return False
def video_state(self): def video_state(self):
""" """
Check if there is an assigned media API and do some Check if there is an assigned media API and do some

View File

@ -155,7 +155,6 @@ class MediaMediaItem(MediaManagerItem):
if self.mediaLength > 0: if self.mediaLength > 0:
service_item.add_capability( service_item.add_capability(
ItemCapabilities.AllowsVariableStartTime) ItemCapabilities.AllowsVariableStartTime)
print self.mediaLength
service_item.media_length = self.mediaLength service_item.media_length = self.mediaLength
service_item.title = unicode(self.plugin.nameStrings[u'singular']) service_item.title = unicode(self.plugin.nameStrings[u'singular'])
service_item.add_capability(ItemCapabilities.RequiresMedia) service_item.add_capability(ItemCapabilities.RequiresMedia)

View File

@ -46,8 +46,12 @@ class MediaPlugin(Plugin):
self.dnd_id = u'Media' self.dnd_id = u'Media'
self.audio_extensions_list = \ self.audio_extensions_list = \
self.mediaManager.get_audio_extensions_list() self.mediaManager.get_audio_extensions_list()
for ext in self.audio_extensions_list:
self.serviceManager.supportedSuffixes(ext[2:])
self.video_extensions_list = \ self.video_extensions_list = \
self.mediaManager.get_video_extensions_list() self.mediaManager.get_video_extensions_list()
for ext in self.video_extensions_list:
self.serviceManager.supportedSuffixes(ext[2:])
def getSettingsTab(self, parent): def getSettingsTab(self, parent):
""" """

View File

@ -150,13 +150,11 @@ class HttpResponse(object):
class HttpServer(object): class HttpServer(object):
""" """
Ability to control OpenLP via a webbrowser Ability to control OpenLP via a web browser.
e.g. http://localhost:4316/send/slidecontroller_live_next
http://localhost:4316/send/alerts_text?q=your%20alert%20text
""" """
def __init__(self, plugin): def __init__(self, plugin):
""" """
Initialise the httpserver, and start the server Initialise the httpserver, and start the server.
""" """
log.debug(u'Initialise httpserver') log.debug(u'Initialise httpserver')
self.plugin = plugin self.plugin = plugin
@ -170,9 +168,9 @@ class HttpServer(object):
def start_tcp(self): def start_tcp(self):
""" """
Start the http server, use the port in the settings default to 4316 Start the http server, use the port in the settings default to 4316.
Listen out for slide and song changes so they can be broadcast to Listen out for slide and song changes so they can be broadcast to
clients. Listen out for socket connections clients. Listen out for socket connections.
""" """
log.debug(u'Start TCP server') log.debug(u'Start TCP server')
port = QtCore.QSettings().value( port = QtCore.QSettings().value(
@ -195,20 +193,20 @@ class HttpServer(object):
def slide_change(self, row): def slide_change(self, row):
""" """
Slide change listener. Store the item and tell the clients Slide change listener. Store the item and tell the clients.
""" """
self.current_slide = row self.current_slide = row
def item_change(self, items): def item_change(self, items):
""" """
Item (song) change listener. Store the slide and tell the clients Item (song) change listener. Store the slide and tell the clients.
""" """
self.current_item = items[0] self.current_item = items[0]
def new_connection(self): def new_connection(self):
""" """
A new http connection has been made. Create a client object to handle A new http connection has been made. Create a client object to handle
communication communication.
""" """
log.debug(u'new http connection') log.debug(u'new http connection')
socket = self.server.nextPendingConnection() socket = self.server.nextPendingConnection()
@ -225,15 +223,16 @@ class HttpServer(object):
def close(self): def close(self):
""" """
Close down the http server Close down the http server.
""" """
log.debug(u'close http server') log.debug(u'close http server')
self.server.close() self.server.close()
class HttpConnection(object): class HttpConnection(object):
""" """
A single connection, this handles communication between the server A single connection, this handles communication between the server
and the client and the client.
""" """
def __init__(self, parent, socket): def __init__(self, parent, socket):
""" """
@ -287,9 +286,12 @@ class HttpConnection(object):
""" """
self.template_vars = { self.template_vars = {
'app_title': translate('RemotePlugin.Mobile', 'OpenLP 2.0 Remote'), 'app_title': translate('RemotePlugin.Mobile', 'OpenLP 2.0 Remote'),
'stage_title': translate('RemotePlugin.Mobile', 'OpenLP 2.0 Stage View'), 'stage_title': translate('RemotePlugin.Mobile',
'service_manager': translate('RemotePlugin.Mobile', 'Service Manager'), 'OpenLP 2.0 Stage View'),
'slide_controller': translate('RemotePlugin.Mobile', 'Slide Controller'), 'service_manager': translate('RemotePlugin.Mobile',
'Service Manager'),
'slide_controller': translate('RemotePlugin.Mobile',
'Slide Controller'),
'alerts': translate('RemotePlugin.Mobile', 'Alerts'), 'alerts': translate('RemotePlugin.Mobile', 'Alerts'),
'search': translate('RemotePlugin.Mobile', 'Search'), 'search': translate('RemotePlugin.Mobile', 'Search'),
'back': translate('RemotePlugin.Mobile', 'Back'), 'back': translate('RemotePlugin.Mobile', 'Back'),
@ -301,7 +303,8 @@ class HttpConnection(object):
'text': translate('RemotePlugin.Mobile', 'Text'), 'text': translate('RemotePlugin.Mobile', 'Text'),
'show_alert': translate('RemotePlugin.Mobile', 'Show Alert'), 'show_alert': translate('RemotePlugin.Mobile', 'Show Alert'),
'go_live': translate('RemotePlugin.Mobile', 'Go Live'), 'go_live': translate('RemotePlugin.Mobile', 'Go Live'),
'add_to_service': translate('RemotePlugin.Mobile', 'Add To Service'), 'add_to_service': translate('RemotePlugin.Mobile',
'Add to Service'),
'no_results': translate('RemotePlugin.Mobile', 'No Results'), 'no_results': translate('RemotePlugin.Mobile', 'No Results'),
'options': translate('RemotePlugin.Mobile', 'Options') 'options': translate('RemotePlugin.Mobile', 'Options')
} }
@ -397,7 +400,7 @@ class HttpConnection(object):
if self.parent.current_item else u'' if self.parent.current_item else u''
} }
return HttpResponse(json.dumps({u'results': result}), return HttpResponse(json.dumps({u'results': result}),
{u'Content-Type': u'application/json'}) {u'Content-Type': u'application/json'})
def display(self, action): def display(self, action):
""" """
@ -483,10 +486,11 @@ class HttpConnection(object):
def pluginInfo(self, action): def pluginInfo(self, action):
""" """
Return plugin related information, based on the action Return plugin related information, based on the action.
``action`` - The action to perform ``action``
if 'search' return a list of plugin names which support search The action to perform. If *search* return a list of plugin names
which support search.
""" """
if action == u'search': if action == u'search':
searches = [] searches = []
@ -501,10 +505,10 @@ class HttpConnection(object):
def search(self, type): def search(self, type):
""" """
Return a list of items that match the search text Return a list of items that match the search text.
``type`` ``type``
The plugin name to search in. The plugin name to search in.
""" """
text = json.loads(self.url_params[u'data'][0])[u'request'][u'text'] text = json.loads(self.url_params[u'data'][0])[u'request'][u'text']
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type) plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
@ -528,7 +532,7 @@ class HttpConnection(object):
def add_to_service(self, type): def add_to_service(self, type):
""" """
Add item of type ``type`` to the end of the service Add item of type ``type`` to the end of the service.
""" """
id = json.loads(self.url_params[u'data'][0])[u'request'][u'id'] id = json.loads(self.url_params[u'data'][0])[u'request'][u'id']
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type) plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)