forked from openlp/openlp
bugfixing
This commit is contained in:
parent
229fe56305
commit
c547db5462
@ -36,6 +36,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
# FIXME: Add html5 doctype. However, do not break theme gradients.
|
||||
HTMLSRC = u"""
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>OpenLP Display</title>
|
||||
@ -276,25 +277,25 @@ def build_html(item, screen, alert, islive, background, plugins=None, \
|
||||
image_src = u'src="data:image/png;base64,%s"' % image
|
||||
else:
|
||||
image_src = u'style="display:none;"'
|
||||
plugin_css = u''
|
||||
plugin_js = u''
|
||||
plugin_html = u''
|
||||
css_additions = u''
|
||||
js_additions = u''
|
||||
html_additions = u''
|
||||
if plugins:
|
||||
for plugin in plugins:
|
||||
plugin_css += plugin.getDisplayCss()
|
||||
plugin_js += plugin.getDisplayJavascript()
|
||||
plugin_html += plugin.getDisplayHtml()
|
||||
css_additions += plugin.getDisplayCss()
|
||||
js_additions += plugin.getDisplayJavascript()
|
||||
html_additions += plugin.getDisplayHtml()
|
||||
html = HTMLSRC % (build_background_css(item, width, height),
|
||||
width, height,
|
||||
plugin_css,
|
||||
css_additions,
|
||||
build_alert_css(alert, width),
|
||||
build_footer_css(item, height),
|
||||
build_lyrics_css(item, webkitvers),
|
||||
u'true' if theme and theme.display_slide_transition and islive \
|
||||
else u'false',
|
||||
plugin_js,
|
||||
js_additions,
|
||||
bgimage_src, image_src,
|
||||
plugin_html,
|
||||
html_additions,
|
||||
build_lyrics_html(item, webkitvers))
|
||||
return html
|
||||
|
||||
|
@ -67,6 +67,7 @@ class Display(QtGui.QGraphicsView):
|
||||
self.width(), self.height())
|
||||
self.webView.settings().setAttribute(
|
||||
QtWebKit.QWebSettings.PluginsEnabled, True)
|
||||
self.webView.settings().setAttribute(7, True)
|
||||
self.page = self.webView.page()
|
||||
self.frame = self.page.mainFrame()
|
||||
self.frame.setScrollBarPolicy(QtCore.Qt.Vertical,
|
||||
@ -129,6 +130,7 @@ class MainDisplay(Display):
|
||||
self.screen[u'size'].width(), self.screen[u'size'].height())
|
||||
self.webView.settings().setAttribute( \
|
||||
QtWebKit.QWebSettings.PluginsEnabled, True)
|
||||
self.webView.settings().setAttribute(7, True)
|
||||
self.page = self.webView.page()
|
||||
self.frame = self.page.mainFrame()
|
||||
QtCore.QObject.connect(self.webView,
|
||||
@ -253,7 +255,7 @@ class MainDisplay(Display):
|
||||
"""
|
||||
log.debug(u'image to display')
|
||||
image = self.imageManager.get_image_bytes(name)
|
||||
self.resetVideo()
|
||||
self.controller.mediaManager.video_reset(self.controller)
|
||||
self.displayImage(image)
|
||||
return self.preview()
|
||||
|
||||
|
@ -39,10 +39,12 @@ class MediaState(object):
|
||||
class MediaType(object):
|
||||
"""
|
||||
"""
|
||||
Audio = 0
|
||||
Video = 1
|
||||
Unused = 0
|
||||
Audio = 1
|
||||
Video = 2
|
||||
Cd = 3
|
||||
Dvd = 4
|
||||
Folder = 5
|
||||
|
||||
class MediaInfo(object):
|
||||
"""
|
||||
@ -50,7 +52,7 @@ class MediaInfo(object):
|
||||
"""
|
||||
file_info = None
|
||||
volume = 100
|
||||
isFlash = False
|
||||
is_flash = False
|
||||
is_background = False
|
||||
length = 0
|
||||
start_time = 0
|
||||
|
@ -49,7 +49,6 @@ class MediaAPI(object):
|
||||
"""
|
||||
return False
|
||||
|
||||
|
||||
def setup(self, display):
|
||||
"""
|
||||
Create the related widgets for the current display
|
||||
@ -118,21 +117,19 @@ class MediaAPI(object):
|
||||
"""
|
||||
pass
|
||||
|
||||
def getDisplayCss(self):
|
||||
def get_media_display_css(self):
|
||||
"""
|
||||
Add css style sheets to htmlbuilder
|
||||
"""
|
||||
return u''
|
||||
|
||||
|
||||
def getDisplayJavascript(self):
|
||||
def get_media_display_javascript(self):
|
||||
"""
|
||||
Add javascript functions to htmlbuilder
|
||||
"""
|
||||
return u''
|
||||
|
||||
|
||||
def getDisplayHtml(self):
|
||||
def get_media_display_html(self):
|
||||
"""
|
||||
Add html code to htmlbuilder
|
||||
"""
|
||||
|
@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui, QtWebKit
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar, Receiver, translate
|
||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
||||
from openlp.core.ui.media import MediaAPI, MediaState, MediaInfo
|
||||
from openlp.core.ui.media import MediaAPI, MediaState, MediaInfo, MediaType
|
||||
from openlp.core.utils import AppLocation
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -61,12 +61,12 @@ class MediaManager(object):
|
||||
self.APIs = {}
|
||||
self.controller = []
|
||||
self.curDisplayMediaAPI = {}
|
||||
#Timer for video state
|
||||
# Timer for video state
|
||||
self.Timer = QtCore.QTimer()
|
||||
self.Timer.setInterval(200)
|
||||
self.withLivePreview = False
|
||||
self.checkPreConditions()
|
||||
#Signals
|
||||
self.check_available_media_apis()
|
||||
# Signals
|
||||
QtCore.QObject.connect(self.Timer,
|
||||
QtCore.SIGNAL("timeout()"), self.video_state)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
@ -86,7 +86,7 @@ class MediaManager(object):
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'media_unblank'), self.video_unblank)
|
||||
|
||||
def registerControllers(self, controller):
|
||||
def register_controllers(self, controller):
|
||||
"""
|
||||
Register each media API controller (Webkit, Phonon, etc) and
|
||||
store for later use
|
||||
@ -94,12 +94,12 @@ class MediaManager(object):
|
||||
if controller.check_available():
|
||||
self.APIs[controller.name] = controller
|
||||
|
||||
def checkPreConditions(self):
|
||||
def check_available_media_apis(self):
|
||||
"""
|
||||
Check to see if we have any media API's available
|
||||
If Not do not install the plugin.
|
||||
"""
|
||||
log.debug(u'checkPreConditions')
|
||||
log.debug(u'check_available_media_apis')
|
||||
controller_dir = os.path.join(
|
||||
AppLocation.get_directory(AppLocation.AppDir),
|
||||
u'core', u'ui', u'media')
|
||||
@ -119,7 +119,7 @@ class MediaManager(object):
|
||||
controller_classes = MediaAPI.__subclasses__()
|
||||
for controller_class in controller_classes:
|
||||
controller = controller_class(self)
|
||||
self.registerControllers(controller)
|
||||
self.register_controllers(controller)
|
||||
if self.APIs:
|
||||
return True
|
||||
else:
|
||||
@ -143,34 +143,34 @@ class MediaManager(object):
|
||||
if not isAnyonePlaying:
|
||||
self.Timer.stop()
|
||||
|
||||
def getDisplayCss(self):
|
||||
def get_media_display_css(self):
|
||||
"""
|
||||
Add css style sheets to htmlbuilder
|
||||
"""
|
||||
css = u'';
|
||||
for api in self.APIs.values():
|
||||
css += api.getDisplayCss()
|
||||
css += api.get_media_display_css()
|
||||
return css
|
||||
|
||||
def getDisplayJavascript(self):
|
||||
def get_media_display_javascript(self):
|
||||
"""
|
||||
Add javascript functions to htmlbuilder
|
||||
"""
|
||||
js = u''
|
||||
for api in self.APIs.values():
|
||||
js += api.getDisplayJavascript()
|
||||
js += api.get_media_display_javascript()
|
||||
return js
|
||||
|
||||
def getDisplayHtml(self):
|
||||
def get_media_display_html(self):
|
||||
"""
|
||||
Add html code to htmlbuilder
|
||||
"""
|
||||
html = u''
|
||||
for api in self.APIs.values():
|
||||
html += api.getDisplayHtml()
|
||||
html += api.get_media_display_html()
|
||||
return html
|
||||
|
||||
def addControllerItems(self, controller, control_panel):
|
||||
def add_controller_items(self, controller, control_panel):
|
||||
self.controller.append(controller)
|
||||
self.setup_generic_controls(controller, control_panel)
|
||||
for api in self.APIs.values():
|
||||
@ -210,7 +210,7 @@ class MediaManager(object):
|
||||
controller.mediabar.addToolbarWidget(u'Audio Volume', controller.volumeSlider)
|
||||
control_panel.addWidget(controller.mediabar)
|
||||
controller.mediabar.setVisible(False)
|
||||
#Signals
|
||||
# Signals
|
||||
QtCore.QObject.connect(controller.seekSlider,
|
||||
QtCore.SIGNAL(u'sliderMoved(int)'), controller.sendToPlugins)
|
||||
QtCore.QObject.connect(controller.volumeSlider,
|
||||
@ -277,20 +277,26 @@ class MediaManager(object):
|
||||
display = controller.previewDisplay
|
||||
isValid = self.check_file_type(controller, display)
|
||||
if not isValid:
|
||||
#Media could not be loaded correctly
|
||||
# Media could not be loaded correctly
|
||||
critical_error_message_box(
|
||||
translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||
unicode(translate('MediaPlugin.MediaItem',
|
||||
'Unsupported File')))
|
||||
return False
|
||||
#now start playing
|
||||
self.video_play([controller])
|
||||
# now start playing
|
||||
if self.video_play([controller]):
|
||||
self.video_pause([controller])
|
||||
self.video_seek([controller, [0]])
|
||||
self.video_play([controller])
|
||||
if self.video_play([controller]):
|
||||
self.set_controls_visible(controller, True)
|
||||
log.debug(u'use %s controller' % self.curDisplayMediaAPI[display])
|
||||
return True
|
||||
else:
|
||||
critical_error_message_box(
|
||||
translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||
unicode(translate('MediaPlugin.MediaItem',
|
||||
'Unsupported File')))
|
||||
return False
|
||||
|
||||
def check_file_type(self, controller, display):
|
||||
"""
|
||||
@ -310,6 +316,12 @@ class MediaManager(object):
|
||||
self.resize(controller, display, api)
|
||||
if api.load(display):
|
||||
self.curDisplayMediaAPI[display] = api
|
||||
controller.media_info.media_type = MediaType.Video
|
||||
return True
|
||||
if suffix in api.audio_extensions_list:
|
||||
if api.load(display):
|
||||
self.curDisplayMediaAPI[display] = api
|
||||
controller.media_info.media_type = MediaType.Audio
|
||||
return True
|
||||
# no valid api found
|
||||
return False
|
||||
@ -325,17 +337,19 @@ class MediaManager(object):
|
||||
if controller.isLive:
|
||||
if controller.hideMenu.defaultAction().isChecked():
|
||||
controller.hideMenu.defaultAction().trigger()
|
||||
#Receiver.send_message(u'maindisplay_show')
|
||||
self.curDisplayMediaAPI[display].play(display)
|
||||
if not self.curDisplayMediaAPI[display].play(display):
|
||||
return False
|
||||
self.curDisplayMediaAPI[display].set_visible(display, True)
|
||||
# Start Timer for ui updates
|
||||
if not self.Timer.isActive():
|
||||
self.Timer.start()
|
||||
return True
|
||||
|
||||
def video_pause(self, msg):
|
||||
"""
|
||||
Responds to the request to pause a loaded video
|
||||
"""
|
||||
log.debug(u'videoPause')
|
||||
log.debug(u'video_pause')
|
||||
controller = msg[0]
|
||||
for display in self.curDisplayMediaAPI.keys():
|
||||
if display.controller == controller:
|
||||
@ -383,6 +397,7 @@ class MediaManager(object):
|
||||
if display.controller == controller:
|
||||
display.override = {}
|
||||
self.curDisplayMediaAPI[display].reset(display)
|
||||
self.curDisplayMediaAPI[display].set_visible(display, False)
|
||||
del self.curDisplayMediaAPI[display]
|
||||
self.set_controls_visible(controller, False)
|
||||
|
||||
@ -428,7 +443,7 @@ class MediaManager(object):
|
||||
if display.controller == controller:
|
||||
if self.curDisplayMediaAPI[display] \
|
||||
.state == MediaState.Paused:
|
||||
self.curDisplayMediaAPI[display].play(display)
|
||||
if self.curDisplayMediaAPI[display].play(display):
|
||||
self.curDisplayMediaAPI[display] \
|
||||
.set_visible(display, True)
|
||||
|
||||
|
@ -76,7 +76,6 @@ class PhononAPI(MediaAPI):
|
||||
ext = u'*%s' % extension
|
||||
if ext not in list:
|
||||
list.append(ext)
|
||||
#self.parent.parent.serviceManagerContents.supportedSuffixes(extension[1:])
|
||||
log.info(u'MediaPlugin: %s extensions: %s' % (mimetype,
|
||||
u' '.join(extensions)))
|
||||
# Add extensions for this mimetype from self.additional_extensions.
|
||||
@ -87,7 +86,6 @@ class PhononAPI(MediaAPI):
|
||||
ext = u'*%s' % extension
|
||||
if ext not in list:
|
||||
list.append(ext)
|
||||
#self.parent.parent.serviceManagerContents.supportedSuffixes(extension[1:])
|
||||
log.info(u'MediaPlugin: %s additional extensions: %s' % (mimetype,
|
||||
u' '.join(self.additional_extensions[mimetype])))
|
||||
|
||||
@ -133,19 +131,21 @@ class PhononAPI(MediaAPI):
|
||||
volume = controller.media_info.volume
|
||||
path = controller.media_info.file_info.absoluteFilePath()
|
||||
display.mediaObject.setCurrentSource(Phonon.MediaSource(path))
|
||||
if not self.mediaStateWait(display, Phonon.StoppedState):
|
||||
if not self.media_state_wait(display, Phonon.StoppedState):
|
||||
return False
|
||||
self.volume(display, volume)
|
||||
return True
|
||||
|
||||
def mediaStateWait(self, display, mediaState):
|
||||
def media_state_wait(self, display, mediaState):
|
||||
"""
|
||||
Wait for the video to change its state
|
||||
Wait no longer than 5 seconds.
|
||||
"""
|
||||
start = datetime.now()
|
||||
while display.mediaObject.state() != mediaState:
|
||||
if display.mediaObject.state() == Phonon.ErrorState:
|
||||
current_state = display.mediaObject.state()
|
||||
while current_state != mediaState:
|
||||
current_state = display.mediaObject.state()
|
||||
if current_state == Phonon.ErrorState:
|
||||
return False
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
if (datetime.now() - start).seconds > 5:
|
||||
@ -162,7 +162,7 @@ class PhononAPI(MediaAPI):
|
||||
controller.media_info.start_time > 0:
|
||||
start_time = controller.media_info.start_time
|
||||
display.mediaObject.play()
|
||||
if self.mediaStateWait(display, Phonon.PlayingState):
|
||||
if self.media_state_wait(display, Phonon.PlayingState):
|
||||
if start_time > 0:
|
||||
self.seek(display, controller.media_info.start_time*1000)
|
||||
self.volume(display, controller.media_info.volume)
|
||||
@ -170,10 +170,14 @@ class PhononAPI(MediaAPI):
|
||||
int(display.mediaObject.totalTime()/1000)
|
||||
controller.seekSlider.setMaximum(controller.media_info.length*1000)
|
||||
self.state = MediaState.Playing
|
||||
self.set_visible(display, True)
|
||||
#self.set_visible(display, True)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def pause(self, display):
|
||||
display.mediaObject.pause()
|
||||
if self.media_state_wait(display, Phonon.PausedState):
|
||||
self.state = MediaState.Paused
|
||||
|
||||
def stop(self, display):
|
||||
|
@ -48,6 +48,11 @@ class VlcAPI(MediaAPI):
|
||||
def __init__(self, parent):
|
||||
MediaAPI.__init__(self, parent, u'Vlc')
|
||||
self.parent = parent
|
||||
self.audio_extensions_list = [
|
||||
u'*.mp3'
|
||||
, u'*.wav'
|
||||
, u'*.ogg'
|
||||
]
|
||||
self.video_extensions_list = [
|
||||
u'*.3gp'
|
||||
, u'*.asf', u'*.wmv'
|
||||
@ -56,10 +61,10 @@ class VlcAPI(MediaAPI):
|
||||
, u'*.flv'
|
||||
, u'*.mov'
|
||||
, u'*.mp4'
|
||||
, u'*.ogm', u'*.ogg'
|
||||
, u'*.ogm'
|
||||
, u'*.mkv', u'*.mka'
|
||||
, u'*.ts', u'*.mpg'
|
||||
, u'*.mpg', u'*.mp3', u'*.mp2'
|
||||
, u'*.mpg', u'*.mp2'
|
||||
, u'*.nsc'
|
||||
, u'*.nsv'
|
||||
, u'*.nut'
|
||||
@ -67,7 +72,7 @@ class VlcAPI(MediaAPI):
|
||||
, u'*.a52', u'*.dts', u'*.aac', u'*.flac' ,u'*.dv', u'*.vid'
|
||||
, u'*.tta', u'*.tac'
|
||||
, u'*.ty'
|
||||
, u'*.wav', u'*.dts'
|
||||
, u'*.dts'
|
||||
, u'*.xa'
|
||||
, u'*.iso'
|
||||
]
|
||||
@ -120,7 +125,7 @@ class VlcAPI(MediaAPI):
|
||||
self.volume(display, volume)
|
||||
return True
|
||||
|
||||
def mediaStateWait(self, display, mediaState):
|
||||
def media_state_wait(self, display, mediaState):
|
||||
"""
|
||||
Wait for the video to change its state
|
||||
Wait no longer than 5 seconds.
|
||||
@ -143,20 +148,23 @@ class VlcAPI(MediaAPI):
|
||||
if controller.media_info.start_time > 0:
|
||||
start_time = controller.media_info.start_time
|
||||
display.vlcMediaPlayer.play()
|
||||
if self.mediaStateWait(display, vlc.State.Playing):
|
||||
if self.media_state_wait(display, vlc.State.Playing):
|
||||
if start_time > 0:
|
||||
self.seek(display, controller.media_info.start_time*1000)
|
||||
controller.media_info.length = \
|
||||
int(display.vlcMediaPlayer.get_media().get_duration()/1000)
|
||||
controller.seekSlider.setMaximum(controller.media_info.length*1000)
|
||||
self.state = MediaState.Playing
|
||||
self.set_visible(display, True)
|
||||
#self.set_visible(display, True)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def pause(self, display):
|
||||
if display.vlcMedia.get_state() != vlc.State.Playing:
|
||||
return
|
||||
display.vlcMediaPlayer.pause()
|
||||
if self.mediaStateWait(display, vlc.State.Paused):
|
||||
if self.media_state_wait(display, vlc.State.Paused):
|
||||
self.state = MediaState.Paused
|
||||
|
||||
def stop(self, display):
|
||||
|
@ -44,6 +44,10 @@ class WebkitAPI(MediaAPI):
|
||||
MediaAPI.__init__(self, parent, u'Webkit')
|
||||
self.parent = parent
|
||||
self.canBackground = True
|
||||
self.audio_extensions_list = [
|
||||
u'*.mp3'
|
||||
, u'*.ogg'
|
||||
]
|
||||
self.video_extensions_list = [
|
||||
u'*.3gp'
|
||||
, u'*.3gpp'
|
||||
@ -62,8 +66,6 @@ class WebkitAPI(MediaAPI):
|
||||
, u'*.m4v'
|
||||
, u'*.mkv'
|
||||
, u'*.mp4'
|
||||
, u'*.mp3'
|
||||
, u'*.ogg'
|
||||
, u'*.ogv'
|
||||
, u'*.webm'
|
||||
, u'*.swf', u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi'
|
||||
@ -73,7 +75,7 @@ class WebkitAPI(MediaAPI):
|
||||
# no special controls
|
||||
pass
|
||||
|
||||
def getDisplayCss(self):
|
||||
def get_media_display_css(self):
|
||||
"""
|
||||
Add css style sheets to htmlbuilder
|
||||
"""
|
||||
@ -91,7 +93,7 @@ class WebkitAPI(MediaAPI):
|
||||
return css
|
||||
|
||||
|
||||
def getDisplayJavascript(self):
|
||||
def get_media_display_javascript(self):
|
||||
"""
|
||||
Add javascript functions to htmlbuilder
|
||||
"""
|
||||
@ -99,7 +101,7 @@ class WebkitAPI(MediaAPI):
|
||||
var video_timer = null;
|
||||
var current_video = '1';
|
||||
|
||||
function show_video(state, path, volume, loop, seekVal){
|
||||
function show_video(state, path, volume, loop, varVal){
|
||||
// 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
|
||||
@ -139,7 +141,7 @@ class WebkitAPI(MediaAPI):
|
||||
break;
|
||||
case 'play':
|
||||
vid.play();
|
||||
vid.style.visibility = 'visible';
|
||||
//vid.style.visibility = 'visible';
|
||||
if(vid.looping){
|
||||
video_timer = setInterval(
|
||||
function() {
|
||||
@ -156,7 +158,6 @@ class WebkitAPI(MediaAPI):
|
||||
break;
|
||||
case 'stop':
|
||||
show_video('pause');
|
||||
vid.style.visibility = 'hidden';
|
||||
break;
|
||||
case 'poll':
|
||||
if(vid.ended||vid.currentTime+0.2>vid.duration)
|
||||
@ -182,7 +183,10 @@ class WebkitAPI(MediaAPI):
|
||||
return vid.currentTime;
|
||||
case 'seek':
|
||||
// doesnt work currently
|
||||
//vid.currentTime = seekVal;
|
||||
//vid.currentTime = varVal;
|
||||
break;
|
||||
case 'setVisible':
|
||||
vid.style.visibility = varVal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -197,8 +201,7 @@ class WebkitAPI(MediaAPI):
|
||||
return document.embeds[movieName];
|
||||
}
|
||||
|
||||
// http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html
|
||||
function show_flash(state, path, volume, seekVal){
|
||||
function show_flash(state, path, volume, varVal){
|
||||
var text = document.getElementById('flash');
|
||||
var flashMovie = getFlashMovieObject("OpenLPFlashMovie");
|
||||
var src = "src = 'file:///" + path + "'";
|
||||
@ -214,27 +217,22 @@ class WebkitAPI(MediaAPI):
|
||||
case 'load':
|
||||
text.innerHTML = "<embed " + src + view_parm + swf_parm + "/>";
|
||||
flashMovie = getFlashMovieObject("OpenLPFlashMovie");
|
||||
text.style.visibility = 'visible';
|
||||
flashMovie.Play();
|
||||
break;
|
||||
case 'play':
|
||||
text.style.visibility = 'visible';
|
||||
flashMovie.Play();
|
||||
break;
|
||||
case 'pause':
|
||||
flashMovie.StopPlay();
|
||||
text.style.visibility = 'hidden';
|
||||
break;
|
||||
case 'stop':
|
||||
flashMovie.StopPlay();
|
||||
text.style.visibility = 'hidden';
|
||||
tempHtml = text.innerHTML;
|
||||
text.innerHTML = '';
|
||||
text.innerHTML = tempHtml;
|
||||
break;
|
||||
case 'close':
|
||||
flashMovie.StopPlay();
|
||||
text.style.visibility = 'hidden';
|
||||
text.innerHTML = '';
|
||||
break;
|
||||
case 'length':
|
||||
@ -242,7 +240,10 @@ class WebkitAPI(MediaAPI):
|
||||
case 'currentTime':
|
||||
return flashMovie.CurrentFrame();
|
||||
case 'seek':
|
||||
// flashMovie.GotoFrame(seekVal);
|
||||
// flashMovie.GotoFrame(varVal);
|
||||
break;
|
||||
case 'setVisible':
|
||||
text.style.visibility = varVal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -250,7 +251,7 @@ class WebkitAPI(MediaAPI):
|
||||
return js
|
||||
|
||||
|
||||
def getDisplayHtml(self):
|
||||
def get_media_display_html(self):
|
||||
"""
|
||||
Add html code to htmlbuilder
|
||||
"""
|
||||
@ -267,7 +268,6 @@ class WebkitAPI(MediaAPI):
|
||||
display.webView.resize(display.size())
|
||||
display.webView.raise_()
|
||||
self.hasOwnWidget = False
|
||||
#display.webView.hide()
|
||||
|
||||
def check_available(self):
|
||||
return True
|
||||
@ -287,7 +287,7 @@ class WebkitAPI(MediaAPI):
|
||||
loop = u'false'
|
||||
display.webView.setVisible(True)
|
||||
if controller.media_info.file_info.suffix() == u'swf':
|
||||
controller.media_info.isFlash = True
|
||||
controller.media_info.is_flash = True
|
||||
js = u'show_flash("load","%s");' % \
|
||||
(path.replace(u'\\', u'\\\\'))
|
||||
else:
|
||||
@ -305,17 +305,18 @@ class WebkitAPI(MediaAPI):
|
||||
display.webLoaded = True
|
||||
length = 0
|
||||
self.set_visible(display, True)
|
||||
if controller.media_info.isFlash:
|
||||
if controller.media_info.is_flash:
|
||||
display.frame.evaluateJavaScript(u'show_flash("play");')
|
||||
else:
|
||||
display.frame.evaluateJavaScript(u'show_video("play");')
|
||||
#TODO add playing check and get the correct media length
|
||||
# TODO add playing check and get the correct media length
|
||||
controller.media_info.length = length
|
||||
self.state = MediaState.Playing
|
||||
return True
|
||||
|
||||
def pause(self, display):
|
||||
controller = display.controller
|
||||
if controller.media_info.isFlash:
|
||||
if controller.media_info.is_flash:
|
||||
display.frame.evaluateJavaScript(u'show_flash("pause");')
|
||||
else:
|
||||
display.frame.evaluateJavaScript(u'show_video("pause");')
|
||||
@ -323,7 +324,7 @@ class WebkitAPI(MediaAPI):
|
||||
|
||||
def stop(self, display):
|
||||
controller = display.controller
|
||||
if controller.media_info.isFlash:
|
||||
if controller.media_info.is_flash:
|
||||
display.frame.evaluateJavaScript(u'show_flash("stop");')
|
||||
else:
|
||||
display.frame.evaluateJavaScript(u'show_video("stop");')
|
||||
@ -334,13 +335,13 @@ class WebkitAPI(MediaAPI):
|
||||
# 1.0 is the highest value
|
||||
if display.hasAudio:
|
||||
vol = float(vol) / float(100)
|
||||
if not controller.media_info.isFlash:
|
||||
if not controller.media_info.is_flash:
|
||||
display.frame.evaluateJavaScript(
|
||||
u'show_video(null, null, %s);' % str(vol))
|
||||
|
||||
def seek(self, display, seekVal):
|
||||
controller = display.controller
|
||||
if controller.media_info.isFlash:
|
||||
if controller.media_info.is_flash:
|
||||
seek = seekVal
|
||||
display.frame.evaluateJavaScript( \
|
||||
u'show_flash("seek", null, null, "%s");' % (seek))
|
||||
@ -351,19 +352,28 @@ class WebkitAPI(MediaAPI):
|
||||
|
||||
def reset(self, display):
|
||||
controller = display.controller
|
||||
if controller.media_info.isFlash:
|
||||
if controller.media_info.is_flash:
|
||||
display.frame.evaluateJavaScript(u'show_flash("close");')
|
||||
else:
|
||||
display.frame.evaluateJavaScript(u'show_video("close");')
|
||||
self.state = MediaState.Off
|
||||
|
||||
def set_visible(self, display, status):
|
||||
if self.hasOwnWidget:
|
||||
display.webView.setVisible(status)
|
||||
controller = display.controller
|
||||
if status:
|
||||
is_visible = "visible"
|
||||
else:
|
||||
is_visible = "hidden"
|
||||
if controller.media_info.is_flash:
|
||||
display.frame.evaluateJavaScript(u'show_flash( \
|
||||
"setVisible", null, null, "%s");' % (is_visible))
|
||||
else:
|
||||
display.frame.evaluateJavaScript(u'show_video( \
|
||||
"setVisible", null, null, null, "%s");' % (is_visible))
|
||||
|
||||
def update_ui(self, display):
|
||||
controller = display.controller
|
||||
if controller.media_info.isFlash:
|
||||
if controller.media_info.is_flash:
|
||||
currentTime = display.frame.evaluateJavaScript( \
|
||||
u'show_flash("currentTime");').toInt()[0]
|
||||
length = display.frame.evaluateJavaScript( \
|
||||
@ -372,12 +382,12 @@ class WebkitAPI(MediaAPI):
|
||||
(currentTime, ok) = display.frame.evaluateJavaScript( \
|
||||
u'show_video("currentTime");').toFloat()
|
||||
# check if conversion was ok and value is not 'NaN'
|
||||
if ok and currentTime == currentTime:
|
||||
if ok and currentTime != float('inf'):
|
||||
currentTime = int(currentTime*1000)
|
||||
(length, ok) = display.frame.evaluateJavaScript( \
|
||||
u'show_video("length");').toFloat()
|
||||
# check if conversion was ok and value is not 'NaN'
|
||||
if ok and length == length:
|
||||
if ok and length != float('inf'):
|
||||
length = int(length*1000)
|
||||
if currentTime > 0:
|
||||
controller.media_info.length = length
|
||||
|
@ -253,7 +253,7 @@ class SlideController(Controller):
|
||||
self.onEditSong)
|
||||
self.controllerLayout.addWidget(self.toolbar)
|
||||
# Build the Media Toolbar
|
||||
self.mediaManager.addControllerItems(self, self.controllerLayout)
|
||||
self.mediaManager.add_controller_items(self, self.controllerLayout)
|
||||
if self.isLive:
|
||||
# Build the Song Toolbar
|
||||
self.songMenu = QtGui.QToolButton(self.toolbar)
|
||||
@ -512,9 +512,13 @@ class SlideController(Controller):
|
||||
self.toolbar.makeWidgetsVisible(self.loopList)
|
||||
if item.is_media():
|
||||
self.mediabar.setVisible(True)
|
||||
self.previousItem.setVisible(False)
|
||||
self.nextItem.setVisible(False)
|
||||
else:
|
||||
# Work-around for OS X, hide and then show the toolbar
|
||||
# See bug #791050
|
||||
self.previousItem.setVisible(True)
|
||||
self.nextItem.setVisible(True)
|
||||
self.toolbar.show()
|
||||
self.toolbar.show()
|
||||
|
||||
|
@ -56,11 +56,15 @@ class MediaMediaItem(MediaManagerItem):
|
||||
self.mediaObject = None
|
||||
self.mediaController = Controller(parent)
|
||||
self.mediaController.controllerLayout = QtGui.QVBoxLayout()
|
||||
self.plugin.mediaManager.addControllerItems(self.mediaController, self.mediaController.controllerLayout)
|
||||
self.plugin.mediaManager.set_controls_visible(self.mediaController, False)
|
||||
self.mediaController.previewDisplay = Display(self.mediaController, False, self.mediaController, self.plugin.pluginManager.plugins)
|
||||
self.plugin.mediaManager.add_controller_items(self.mediaController, \
|
||||
self.mediaController.controllerLayout)
|
||||
self.plugin.mediaManager.set_controls_visible(self.mediaController, \
|
||||
False)
|
||||
self.mediaController.previewDisplay = Display(self.mediaController, \
|
||||
False, self.mediaController, self.plugin.pluginManager.plugins)
|
||||
self.mediaController.previewDisplay.setup()
|
||||
self.plugin.mediaManager.setup_display(self.mediaController.previewDisplay)
|
||||
self.plugin.mediaManager.setup_display( \
|
||||
self.mediaController.previewDisplay)
|
||||
self.mediaController.previewDisplay.hide()
|
||||
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
@ -100,7 +104,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
|
||||
def onResetClick(self):
|
||||
"""
|
||||
Called to reset the Live backgound with the media selected,
|
||||
Called to reset the Live background with the media selected,
|
||||
"""
|
||||
self.plugin.liveController.mediaManager.video_reset( \
|
||||
self.plugin.liveController)
|
||||
@ -114,7 +118,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
|
||||
def onReplaceClick(self):
|
||||
"""
|
||||
Called to replace Live backgound with the media selected.
|
||||
Called to replace Live background with the media selected.
|
||||
"""
|
||||
if check_item_selected(self.listView,
|
||||
translate('MediaPlugin.MediaItem',
|
||||
@ -122,7 +126,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
item = self.listView.currentItem()
|
||||
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||
if os.path.exists(filename):
|
||||
(path, name) = os.path.split(filename)
|
||||
#(path, name) = os.path.split(filename)
|
||||
if self.plugin.liveController.mediaManager.video( \
|
||||
self.plugin.liveController, filename, True, True):
|
||||
self.resetAction.setVisible(True)
|
||||
@ -158,6 +162,8 @@ class MediaMediaItem(MediaManagerItem):
|
||||
if self.mediaLength > 0:
|
||||
service_item.add_capability(
|
||||
ItemCapabilities.AllowsVariableStartTime)
|
||||
else:
|
||||
return False
|
||||
service_item.media_length = self.mediaLength
|
||||
service_item.title = unicode(self.plugin.nameStrings[u'singular'])
|
||||
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
||||
|
@ -53,7 +53,6 @@ class MediaTab(SettingsTab):
|
||||
self.ApiCheckBoxes[api.name] = checkbox
|
||||
self.mediaApiLayout.addWidget(checkbox)
|
||||
self.leftLayout.addWidget(self.mediaAPIGroupBox)
|
||||
|
||||
self.apiOrderGroupBox = QtGui.QGroupBox(self.leftColumn)
|
||||
self.apiOrderGroupBox.setObjectName(u'apiOrderGroupBox')
|
||||
self.apiOrderLayout = QtGui.QVBoxLayout(self.apiOrderGroupBox)
|
||||
@ -67,7 +66,6 @@ class MediaTab(SettingsTab):
|
||||
sizePolicy.setHeightForWidth(self.apiOrderlistWidget. \
|
||||
sizePolicy().hasHeightForWidth())
|
||||
self.apiOrderlistWidget.setSizePolicy(sizePolicy)
|
||||
|
||||
self.apiOrderlistWidget.setVerticalScrollBarPolicy( \
|
||||
QtCore.Qt.ScrollBarAsNeeded)
|
||||
self.apiOrderlistWidget.setHorizontalScrollBarPolicy( \
|
||||
|
@ -99,21 +99,22 @@ class MediaPlugin(Plugin):
|
||||
"""
|
||||
log.info(u'Media Finalising')
|
||||
self.mediaManager.finalise()
|
||||
Plugin.finalise(self)
|
||||
|
||||
def getDisplayCss(self):
|
||||
"""
|
||||
Add css style sheets to htmlbuilder
|
||||
"""
|
||||
return self.mediaManager.getDisplayCss()
|
||||
return self.mediaManager.get_media_display_css()
|
||||
|
||||
def getDisplayJavascript(self):
|
||||
"""
|
||||
Add javascript functions to htmlbuilder
|
||||
"""
|
||||
return self.mediaManager.getDisplayJavascript()
|
||||
return self.mediaManager.get_media_display_javascript()
|
||||
|
||||
def getDisplayHtml(self):
|
||||
"""
|
||||
Add html code to htmlbuilder
|
||||
"""
|
||||
return self.mediaManager.getDisplayHtml()
|
||||
return self.mediaManager.get_media_display_html()
|
||||
|
Loading…
Reference in New Issue
Block a user