2011-04-18 19:50:12 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2012-10-21 13:16:22 +00:00
|
|
|
# Copyright (c) 2008-2012 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2012 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-11-07 21:37:01 +00:00
|
|
|
# Frode Woldsund, Martin Zibricky #
|
2011-04-18 19:50:12 +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 #
|
|
|
|
###############################################################################
|
|
|
|
|
2011-05-21 08:18:52 +00:00
|
|
|
import logging
|
|
|
|
|
2011-11-12 15:30:41 +00:00
|
|
|
from openlp.core.lib.mediaplayer import MediaPlayer
|
2011-11-11 16:45:25 +00:00
|
|
|
from openlp.core.ui.media import MediaState
|
2011-04-18 19:50:12 +00:00
|
|
|
|
2011-05-21 08:18:52 +00:00
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2011-10-24 20:04:29 +00:00
|
|
|
VIDEO_CSS = u"""
|
2011-11-02 20:27:53 +00:00
|
|
|
#videobackboard {
|
2011-08-30 16:54:45 +00:00
|
|
|
z-index:3;
|
2011-11-02 20:27:53 +00:00
|
|
|
background-color: black;
|
|
|
|
}
|
|
|
|
#video1 {
|
|
|
|
z-index:4;
|
2011-08-30 16:54:45 +00:00
|
|
|
}
|
|
|
|
#video2 {
|
2011-11-02 20:27:53 +00:00
|
|
|
z-index:4;
|
2011-08-30 16:54:45 +00:00
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
2011-10-24 20:04:29 +00:00
|
|
|
VIDEO_JS = u"""
|
2011-08-30 16:54:45 +00:00
|
|
|
var video_timer = null;
|
|
|
|
var current_video = '1';
|
|
|
|
|
|
|
|
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
|
|
|
|
// onended event, hence the setInterval()
|
|
|
|
// In addition, setting the currentTime attribute to zero to restart
|
|
|
|
// the video raises an INDEX_SIZE_ERROR: DOM Exception 1
|
|
|
|
// To complicate it further, sometimes vid.currentTime stops
|
|
|
|
// slightly short of vid.duration and vid.ended is intermittent!
|
|
|
|
//
|
|
|
|
// Note, currently the background may go black between loops. Not
|
|
|
|
// desirable. Need to investigate using two <video>'s, and hiding/
|
|
|
|
// preloading one, and toggle between the two when looping.
|
|
|
|
|
|
|
|
if(current_video=='1'){
|
|
|
|
var vid = document.getElementById('video1');
|
|
|
|
var vid2 = document.getElementById('video2');
|
|
|
|
} else {
|
|
|
|
var vid = document.getElementById('video2');
|
|
|
|
var vid2 = document.getElementById('video1');
|
|
|
|
}
|
|
|
|
if(volume != null){
|
|
|
|
vid.volume = volume;
|
|
|
|
vid2.volume = volume;
|
|
|
|
}
|
|
|
|
switch(state){
|
|
|
|
case 'init':
|
2011-11-30 17:06:57 +00:00
|
|
|
vid.src = 'file:///' + path;
|
|
|
|
vid2.src = 'file:///' + path;
|
2011-08-30 16:54:45 +00:00
|
|
|
if(loop == null) loop = false;
|
|
|
|
vid.looping = loop;
|
|
|
|
vid2.looping = loop;
|
|
|
|
vid.load();
|
|
|
|
break;
|
|
|
|
case 'load':
|
|
|
|
vid2.style.visibility = 'hidden';
|
|
|
|
vid2.load();
|
|
|
|
break;
|
|
|
|
case 'play':
|
|
|
|
vid.play();
|
|
|
|
if(vid.looping){
|
|
|
|
video_timer = setInterval(
|
|
|
|
function() {
|
|
|
|
show_video('poll');
|
|
|
|
}, 200);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'pause':
|
|
|
|
if(video_timer!=null){
|
|
|
|
clearInterval(video_timer);
|
|
|
|
video_timer = null;
|
|
|
|
}
|
|
|
|
vid.pause();
|
|
|
|
break;
|
|
|
|
case 'stop':
|
|
|
|
show_video('pause');
|
2011-11-30 17:06:57 +00:00
|
|
|
vid.currentTime = 0;
|
2011-08-30 16:54:45 +00:00
|
|
|
break;
|
|
|
|
case 'poll':
|
|
|
|
if(vid.ended||vid.currentTime+0.2>vid.duration)
|
|
|
|
show_video('swap');
|
|
|
|
break;
|
|
|
|
case 'swap':
|
|
|
|
show_video('pause');
|
|
|
|
if(current_video=='1')
|
|
|
|
current_video = '2';
|
|
|
|
else
|
|
|
|
current_video = '1';
|
|
|
|
show_video('load');
|
2011-09-28 20:54:43 +00:00
|
|
|
show_video('play');
|
|
|
|
show_video('setVisible',null,null,null,'visible');
|
2011-08-30 16:54:45 +00:00
|
|
|
break;
|
|
|
|
case 'close':
|
|
|
|
show_video('stop');
|
|
|
|
vid.src = '';
|
|
|
|
vid2.src = '';
|
|
|
|
break;
|
2012-03-13 19:54:16 +00:00
|
|
|
case 'length':
|
2011-08-30 16:54:45 +00:00
|
|
|
return vid.duration;
|
|
|
|
case 'currentTime':
|
|
|
|
return vid.currentTime;
|
|
|
|
case 'seek':
|
|
|
|
// doesnt work currently
|
2011-11-24 21:10:37 +00:00
|
|
|
vid.currentTime = varVal;
|
2011-08-30 16:54:45 +00:00
|
|
|
break;
|
2012-03-13 19:54:16 +00:00
|
|
|
case 'isEnded':
|
|
|
|
return vid.ended;
|
2011-08-30 16:54:45 +00:00
|
|
|
case 'setVisible':
|
|
|
|
vid.style.visibility = varVal;
|
|
|
|
break;
|
2011-11-02 20:27:53 +00:00
|
|
|
case 'setBackBoard':
|
|
|
|
var back = document.getElementById('videobackboard');
|
|
|
|
back.style.visibility = varVal;
|
|
|
|
break;
|
2011-08-30 16:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
2011-10-24 20:04:29 +00:00
|
|
|
VIDEO_HTML = u"""
|
2011-11-02 20:27:53 +00:00
|
|
|
<div id="videobackboard" class="size" style="visibility:hidden"></div>
|
2011-08-30 16:54:45 +00:00
|
|
|
<video id="video1" class="size" style="visibility:hidden" autobuffer preload>
|
|
|
|
</video>
|
|
|
|
<video id="video2" class="size" style="visibility:hidden" autobuffer preload>
|
|
|
|
</video>
|
|
|
|
"""
|
|
|
|
|
2011-10-24 20:04:29 +00:00
|
|
|
FLASH_CSS = u"""
|
2011-08-30 16:54:45 +00:00
|
|
|
#flash {
|
2011-11-02 20:27:53 +00:00
|
|
|
z-index:5;
|
2011-08-30 16:54:45 +00:00
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
2011-10-24 20:04:29 +00:00
|
|
|
FLASH_JS = u"""
|
2011-08-30 16:54:45 +00:00
|
|
|
function getFlashMovieObject(movieName)
|
|
|
|
{
|
|
|
|
if (window.document[movieName])
|
|
|
|
{
|
|
|
|
return window.document[movieName];
|
|
|
|
}
|
|
|
|
if (document.embeds && document.embeds[movieName])
|
|
|
|
return document.embeds[movieName];
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_flash(state, path, volume, varVal){
|
|
|
|
var text = document.getElementById('flash');
|
|
|
|
var flashMovie = getFlashMovieObject("OpenLPFlashMovie");
|
|
|
|
var src = "src = 'file:///" + path + "'";
|
|
|
|
var view_parm = " wmode='opaque'" +
|
|
|
|
" width='100%%'" +
|
|
|
|
" height='100%%'";
|
|
|
|
var swf_parm = " name='OpenLPFlashMovie'" +
|
|
|
|
" autostart='true' loop='false' play='true'" +
|
|
|
|
" hidden='false' swliveconnect='true' allowscriptaccess='always'" +
|
|
|
|
" volume='" + volume + "'";
|
|
|
|
|
|
|
|
switch(state){
|
|
|
|
case 'load':
|
|
|
|
text.innerHTML = "<embed " + src + view_parm + swf_parm + "/>";
|
|
|
|
flashMovie = getFlashMovieObject("OpenLPFlashMovie");
|
|
|
|
flashMovie.Play();
|
|
|
|
break;
|
|
|
|
case 'play':
|
|
|
|
flashMovie.Play();
|
|
|
|
break;
|
|
|
|
case 'pause':
|
|
|
|
flashMovie.StopPlay();
|
|
|
|
break;
|
|
|
|
case 'stop':
|
|
|
|
flashMovie.StopPlay();
|
|
|
|
tempHtml = text.innerHTML;
|
|
|
|
text.innerHTML = '';
|
|
|
|
text.innerHTML = tempHtml;
|
|
|
|
break;
|
|
|
|
case 'close':
|
|
|
|
flashMovie.StopPlay();
|
|
|
|
text.innerHTML = '';
|
|
|
|
break;
|
|
|
|
case 'length':
|
|
|
|
return flashMovie.TotalFrames();
|
|
|
|
case 'currentTime':
|
|
|
|
return flashMovie.CurrentFrame();
|
|
|
|
case 'seek':
|
|
|
|
// flashMovie.GotoFrame(varVal);
|
|
|
|
break;
|
2012-03-13 19:54:16 +00:00
|
|
|
case 'isEnded':
|
|
|
|
return false;//TODO check flash end
|
2011-08-30 16:54:45 +00:00
|
|
|
case 'setVisible':
|
|
|
|
text.style.visibility = varVal;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
2011-10-24 20:04:29 +00:00
|
|
|
FLASH_HTML = u"""
|
2011-08-30 16:54:45 +00:00
|
|
|
<div id="flash" class="size" style="visibility:hidden"></div>
|
|
|
|
"""
|
|
|
|
|
2011-11-02 20:27:53 +00:00
|
|
|
VIDEO_EXT = [
|
2012-06-09 15:46:01 +00:00
|
|
|
u'*.3gp'
|
|
|
|
, u'*.3gpp'
|
|
|
|
, u'*.3g2'
|
|
|
|
, u'*.3gpp2'
|
|
|
|
, u'*.aac'
|
|
|
|
, u'*.flv'
|
|
|
|
, u'*.f4a'
|
|
|
|
, u'*.f4b'
|
|
|
|
, u'*.f4p'
|
|
|
|
, u'*.f4v'
|
|
|
|
, u'*.mov'
|
|
|
|
, u'*.m4a'
|
|
|
|
, u'*.m4b'
|
|
|
|
, u'*.m4p'
|
|
|
|
, u'*.m4v'
|
|
|
|
, u'*.mkv'
|
|
|
|
, u'*.mp4'
|
|
|
|
, u'*.ogv'
|
|
|
|
, u'*.webm'
|
|
|
|
, u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi'
|
|
|
|
, u'*.swf'
|
|
|
|
]
|
2011-04-18 19:50:12 +00:00
|
|
|
|
2012-03-04 14:52:09 +00:00
|
|
|
AUDIO_EXT = [
|
2012-06-09 15:46:01 +00:00
|
|
|
u'*.mp3'
|
|
|
|
, u'*.ogg'
|
|
|
|
]
|
2011-11-02 20:27:53 +00:00
|
|
|
|
|
|
|
|
2011-11-11 16:45:25 +00:00
|
|
|
class WebkitPlayer(MediaPlayer):
|
2011-11-02 20:27:53 +00:00
|
|
|
"""
|
2012-03-13 19:54:16 +00:00
|
|
|
A specialised version of the MediaPlayer class, which provides a QtWebKit
|
2011-11-02 20:27:53 +00:00
|
|
|
display.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, parent):
|
2011-11-11 16:45:25 +00:00
|
|
|
MediaPlayer.__init__(self, parent, u'webkit')
|
2012-03-09 06:09:19 +00:00
|
|
|
self.original_name = u'WebKit'
|
|
|
|
self.display_name = u'&WebKit'
|
2011-11-02 20:27:53 +00:00
|
|
|
self.parent = parent
|
|
|
|
self.canBackground = True
|
|
|
|
self.audio_extensions_list = AUDIO_EXT
|
|
|
|
self.video_extensions_list = VIDEO_EXT
|
2011-06-05 21:10:49 +00:00
|
|
|
|
2011-08-29 19:55:58 +00:00
|
|
|
def get_media_display_css(self):
|
2011-06-08 13:18:05 +00:00
|
|
|
"""
|
|
|
|
Add css style sheets to htmlbuilder
|
|
|
|
"""
|
2011-10-24 20:04:29 +00:00
|
|
|
return VIDEO_CSS + FLASH_CSS
|
2011-06-08 13:18:05 +00:00
|
|
|
|
2011-08-29 19:55:58 +00:00
|
|
|
def get_media_display_javascript(self):
|
2011-06-08 13:18:05 +00:00
|
|
|
"""
|
|
|
|
Add javascript functions to htmlbuilder
|
|
|
|
"""
|
2011-10-24 20:04:29 +00:00
|
|
|
return VIDEO_JS + FLASH_JS
|
2011-06-08 13:18:05 +00:00
|
|
|
|
2011-08-29 19:55:58 +00:00
|
|
|
def get_media_display_html(self):
|
2011-06-08 13:18:05 +00:00
|
|
|
"""
|
|
|
|
Add html code to htmlbuilder
|
|
|
|
"""
|
2011-10-24 20:04:29 +00:00
|
|
|
return VIDEO_HTML + FLASH_HTML
|
2011-06-08 13:18:05 +00:00
|
|
|
|
2011-06-05 21:10:49 +00:00
|
|
|
def setup(self, display):
|
2011-06-08 13:18:05 +00:00
|
|
|
display.webView.resize(display.size())
|
2011-05-17 19:50:00 +00:00
|
|
|
display.webView.raise_()
|
|
|
|
self.hasOwnWidget = False
|
|
|
|
|
2011-06-08 13:18:05 +00:00
|
|
|
def check_available(self):
|
2011-05-17 19:50:00 +00:00
|
|
|
return True
|
|
|
|
|
2011-06-05 21:10:49 +00:00
|
|
|
def load(self, display):
|
2011-05-21 08:18:52 +00:00
|
|
|
log.debug(u'load vid in Webkit Controller')
|
2011-06-06 19:12:14 +00:00
|
|
|
controller = display.controller
|
2011-12-02 23:45:05 +00:00
|
|
|
if display.hasAudio and not controller.media_info.is_background:
|
2011-08-23 20:19:45 +00:00
|
|
|
volume = controller.media_info.volume
|
|
|
|
vol = float(volume) / float(100)
|
|
|
|
else:
|
|
|
|
vol = 0
|
2011-06-05 21:10:49 +00:00
|
|
|
path = controller.media_info.file_info.absoluteFilePath()
|
|
|
|
if controller.media_info.is_background:
|
2011-05-24 20:03:57 +00:00
|
|
|
loop = u'true'
|
|
|
|
else:
|
|
|
|
loop = u'false'
|
2011-04-18 19:50:12 +00:00
|
|
|
display.webView.setVisible(True)
|
2011-06-05 21:10:49 +00:00
|
|
|
if controller.media_info.file_info.suffix() == u'swf':
|
2011-08-29 19:55:58 +00:00
|
|
|
controller.media_info.is_flash = True
|
2011-04-18 19:50:12 +00:00
|
|
|
js = u'show_flash("load","%s");' % \
|
|
|
|
(path.replace(u'\\', u'\\\\'))
|
|
|
|
else:
|
2011-11-30 17:06:57 +00:00
|
|
|
js = u'show_video("init", "%s", %s, %s);' % \
|
2011-05-24 20:03:57 +00:00
|
|
|
(path.replace(u'\\', u'\\\\'), str(vol), loop)
|
2011-04-18 19:50:12 +00:00
|
|
|
display.frame.evaluateJavaScript(js)
|
2011-05-21 08:18:52 +00:00
|
|
|
return True
|
2011-05-10 20:39:17 +00:00
|
|
|
|
2011-06-05 21:10:49 +00:00
|
|
|
def resize(self, display):
|
2011-06-06 19:12:14 +00:00
|
|
|
controller = display.controller
|
|
|
|
display.webView.resize(display.size())
|
2011-04-18 19:50:12 +00:00
|
|
|
|
|
|
|
def play(self, display):
|
2011-06-06 19:12:14 +00:00
|
|
|
controller = display.controller
|
2011-05-24 20:03:57 +00:00
|
|
|
display.webLoaded = True
|
2011-07-25 20:56:39 +00:00
|
|
|
length = 0
|
2011-12-01 18:07:15 +00:00
|
|
|
start_time = 0
|
|
|
|
if self.state != MediaState.Paused and \
|
|
|
|
controller.media_info.start_time > 0:
|
|
|
|
start_time = controller.media_info.start_time
|
2011-05-17 19:50:00 +00:00
|
|
|
self.set_visible(display, True)
|
2011-08-29 19:55:58 +00:00
|
|
|
if controller.media_info.is_flash:
|
2011-06-05 21:10:49 +00:00
|
|
|
display.frame.evaluateJavaScript(u'show_flash("play");')
|
2011-04-18 19:50:12 +00:00
|
|
|
else:
|
|
|
|
display.frame.evaluateJavaScript(u'show_video("play");')
|
2011-12-01 18:07:15 +00:00
|
|
|
if start_time > 0:
|
2012-06-09 15:46:01 +00:00
|
|
|
self.seek(display, controller.media_info.start_time * 1000)
|
2011-08-29 19:55:58 +00:00
|
|
|
# TODO add playing check and get the correct media length
|
2011-07-25 20:56:39 +00:00
|
|
|
controller.media_info.length = length
|
2011-05-10 20:39:17 +00:00
|
|
|
self.state = MediaState.Playing
|
2011-11-24 21:10:37 +00:00
|
|
|
display.webView.raise_()
|
2011-08-29 19:55:58 +00:00
|
|
|
return True
|
2011-04-18 19:50:12 +00:00
|
|
|
|
|
|
|
def pause(self, display):
|
2011-06-06 19:12:14 +00:00
|
|
|
controller = display.controller
|
2011-08-29 19:55:58 +00:00
|
|
|
if controller.media_info.is_flash:
|
2011-06-05 21:10:49 +00:00
|
|
|
display.frame.evaluateJavaScript(u'show_flash("pause");')
|
2011-04-18 19:50:12 +00:00
|
|
|
else:
|
|
|
|
display.frame.evaluateJavaScript(u'show_video("pause");')
|
2011-05-10 20:39:17 +00:00
|
|
|
self.state = MediaState.Paused
|
2011-04-18 19:50:12 +00:00
|
|
|
|
|
|
|
def stop(self, display):
|
2011-06-06 19:12:14 +00:00
|
|
|
controller = display.controller
|
2011-08-29 19:55:58 +00:00
|
|
|
if controller.media_info.is_flash:
|
2011-06-05 21:10:49 +00:00
|
|
|
display.frame.evaluateJavaScript(u'show_flash("stop");')
|
2011-04-18 19:50:12 +00:00
|
|
|
else:
|
|
|
|
display.frame.evaluateJavaScript(u'show_video("stop");')
|
2011-05-10 20:39:17 +00:00
|
|
|
self.state = MediaState.Stopped
|
|
|
|
|
|
|
|
def volume(self, display, vol):
|
2011-06-06 19:12:14 +00:00
|
|
|
controller = display.controller
|
2011-06-05 21:10:49 +00:00
|
|
|
# 1.0 is the highest value
|
2011-08-23 20:19:45 +00:00
|
|
|
if display.hasAudio:
|
2011-06-14 16:10:20 +00:00
|
|
|
vol = float(vol) / float(100)
|
2011-08-29 19:55:58 +00:00
|
|
|
if not controller.media_info.is_flash:
|
2011-06-14 16:10:20 +00:00
|
|
|
display.frame.evaluateJavaScript(
|
|
|
|
u'show_video(null, null, %s);' % str(vol))
|
2011-04-18 19:50:12 +00:00
|
|
|
|
2011-04-19 12:03:36 +00:00
|
|
|
def seek(self, display, seekVal):
|
2011-06-06 19:12:14 +00:00
|
|
|
controller = display.controller
|
2011-08-29 19:55:58 +00:00
|
|
|
if controller.media_info.is_flash:
|
2011-06-05 21:10:49 +00:00
|
|
|
seek = seekVal
|
2012-06-09 15:46:01 +00:00
|
|
|
display.frame.evaluateJavaScript(
|
2011-06-05 21:10:49 +00:00
|
|
|
u'show_flash("seek", null, null, "%s");' % (seek))
|
|
|
|
else:
|
2012-06-09 15:46:01 +00:00
|
|
|
seek = float(seekVal) / 1000
|
|
|
|
display.frame.evaluateJavaScript(
|
2011-05-21 08:18:52 +00:00
|
|
|
u'show_video("seek", null, null, null, "%f");' % (seek))
|
2011-04-18 19:50:12 +00:00
|
|
|
|
|
|
|
def reset(self, display):
|
2011-06-06 19:12:14 +00:00
|
|
|
controller = display.controller
|
2011-08-29 19:55:58 +00:00
|
|
|
if controller.media_info.is_flash:
|
2011-06-05 21:10:49 +00:00
|
|
|
display.frame.evaluateJavaScript(u'show_flash("close");')
|
2011-05-10 20:39:17 +00:00
|
|
|
else:
|
|
|
|
display.frame.evaluateJavaScript(u'show_video("close");')
|
2011-05-17 19:50:00 +00:00
|
|
|
self.state = MediaState.Off
|
|
|
|
|
|
|
|
def set_visible(self, display, status):
|
2011-08-29 19:55:58 +00:00
|
|
|
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))
|
2011-04-19 12:03:36 +00:00
|
|
|
|
2011-06-05 21:10:49 +00:00
|
|
|
def update_ui(self, display):
|
2011-06-06 19:12:14 +00:00
|
|
|
controller = display.controller
|
2011-08-29 19:55:58 +00:00
|
|
|
if controller.media_info.is_flash:
|
2012-06-09 15:46:01 +00:00
|
|
|
currentTime = display.frame.evaluateJavaScript(
|
2011-06-05 21:10:49 +00:00
|
|
|
u'show_flash("currentTime");').toInt()[0]
|
2012-06-09 15:46:01 +00:00
|
|
|
length = display.frame.evaluateJavaScript(
|
2011-06-05 21:10:49 +00:00
|
|
|
u'show_flash("length");').toInt()[0]
|
|
|
|
else:
|
2012-06-09 15:46:01 +00:00
|
|
|
if display.frame.evaluateJavaScript(
|
2012-03-13 19:54:16 +00:00
|
|
|
u'show_video("isEnded");').toString() == 'true':
|
|
|
|
self.stop(display)
|
2012-06-09 15:46:01 +00:00
|
|
|
(currentTime, ok) = display.frame.evaluateJavaScript(
|
2011-06-05 21:10:49 +00:00
|
|
|
u'show_video("currentTime");').toFloat()
|
2011-06-06 19:12:14 +00:00
|
|
|
# check if conversion was ok and value is not 'NaN'
|
2011-08-29 19:55:58 +00:00
|
|
|
if ok and currentTime != float('inf'):
|
2012-06-09 15:46:01 +00:00
|
|
|
currentTime = int(currentTime * 1000)
|
|
|
|
(length, ok) = display.frame.evaluateJavaScript(
|
2011-06-05 21:10:49 +00:00
|
|
|
u'show_video("length");').toFloat()
|
2011-06-06 19:12:14 +00:00
|
|
|
# check if conversion was ok and value is not 'NaN'
|
2011-08-29 19:55:58 +00:00
|
|
|
if ok and length != float('inf'):
|
2012-06-09 15:46:01 +00:00
|
|
|
length = int(length * 1000)
|
2011-06-05 21:10:49 +00:00
|
|
|
if currentTime > 0:
|
2011-07-25 20:56:39 +00:00
|
|
|
controller.media_info.length = length
|
2011-06-05 21:10:49 +00:00
|
|
|
controller.seekSlider.setMaximum(length)
|
|
|
|
if not controller.seekSlider.isSliderDown():
|
|
|
|
controller.seekSlider.setSliderPosition(currentTime)
|