forked from openlp/openlp
add vlc support
This commit is contained in:
parent
392b5ecb47
commit
e730dc366f
@ -178,7 +178,14 @@ sup {
|
||||
vid.src = '';
|
||||
vid2.src = '';
|
||||
break;
|
||||
}
|
||||
case 'length':
|
||||
return vid.duration;
|
||||
case 'currentTime':
|
||||
return vid.currentTime;
|
||||
case 'seek':
|
||||
vid.currentTime = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function show_image(src){
|
||||
|
@ -38,6 +38,7 @@ from openlp.core.lib import Receiver
|
||||
from openlp.plugins.media.lib import MediaBackends, MediaStates
|
||||
from webkitcontroller import WebkitController
|
||||
from phononcontroller import PhononController
|
||||
from vlccontroller import VlcController
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -93,7 +94,7 @@ class MediaManager(object):
|
||||
self.curDisplayMediaController = {}
|
||||
self.displayWebkitController = WebkitController(self)
|
||||
self.displayPhononController = PhononController(self)
|
||||
#self.displayVlcController = VlcController(self)
|
||||
self.displayVlcController = VlcController(self)
|
||||
|
||||
self.Timer = QtCore.QTimer()
|
||||
self.Timer.setInterval(200)
|
||||
@ -134,13 +135,12 @@ class MediaManager(object):
|
||||
self.Timer.stop()
|
||||
|
||||
def setDisplay(self, display):
|
||||
#self.setupVlcController(display)
|
||||
self.setupVlcController(display)
|
||||
self.setupPhononController(display)
|
||||
self.setupWebkitController(display)
|
||||
|
||||
|
||||
def setupWebkitController(self, display):
|
||||
#self.displayWebkitController[display] = display.webView
|
||||
display.webView.raise_()
|
||||
|
||||
def setupPhononController(self, display):
|
||||
@ -155,22 +155,11 @@ class MediaManager(object):
|
||||
display.phononWidget.raise_()
|
||||
|
||||
def setupVlcController(self, display):
|
||||
display.vlcWidget = QtGui.QWidget(display)
|
||||
instance=vlc.Instance()
|
||||
self.movieName = None
|
||||
player=instance.media_player_new(self.movieName)
|
||||
# the media player has to be 'connected' to the QFrame
|
||||
# (otherwise a video would be displayed in it's own window)
|
||||
# this is platform specific!
|
||||
# you have to give the id of the QFrame (or similar object) to
|
||||
# vlc, different platforms have different functions for this
|
||||
if sys.platform == "linux2": # for Linux using the X Server
|
||||
player.set_xwindow(self.hwnd)
|
||||
elif sys.platform == "win32": # for Windows
|
||||
player.set_hwnd(self.hwnd)
|
||||
elif sys.platform == "darwin": # for MacOS
|
||||
player.set_agl(self.hwnd)
|
||||
|
||||
display.vlcWidget = QtGui.QFrame(display)
|
||||
# creating a basic vlc instance
|
||||
display.vlcInstance = vlc.Instance()
|
||||
# creating an empty vlc media player
|
||||
display.vlcMediaPlayer = display.vlcInstance.media_player_new()
|
||||
display.vlcWidget.setGeometry(QtCore.QRect(0, 0,
|
||||
display.screen[u'size'].width(), display.screen[u'size'].height()))
|
||||
display.vlcWidget.raise_()
|
||||
@ -203,14 +192,29 @@ class MediaManager(object):
|
||||
"""
|
||||
usePhonon = QtCore.QSettings().value(
|
||||
u'media/use phonon', QtCore.QVariant(True)).toBool()
|
||||
if usePhonon and not isBackground:
|
||||
useVlc = True
|
||||
if videoPath.endswith(u'.swf'):
|
||||
useVlc = False
|
||||
usePhonon = False
|
||||
elif videoPath.endswith(u'.wmv'):
|
||||
useVlc = False
|
||||
usePhonon = True
|
||||
|
||||
if useVlc:
|
||||
self.curDisplayMediaController[display] = self.displayVlcController
|
||||
display.phononWidget.setVisible(False)
|
||||
display.webView.setVisible(False)
|
||||
display.vlcWidget.setVisible(True)
|
||||
elif usePhonon and not isBackground:
|
||||
self.curDisplayMediaController[display] = self.displayPhononController
|
||||
display.phononWidget.setVisible(True)
|
||||
display.webView.setVisible(False)
|
||||
display.vlcWidget.setVisible(False)
|
||||
else:
|
||||
self.curDisplayMediaController[display] = self.displayWebkitController
|
||||
display.phononWidget.setVisible(False)
|
||||
display.webView.setVisible(True)
|
||||
display.vlcWidget.setVisible(False)
|
||||
if len(self.curDisplayMediaController) > 0:
|
||||
if not self.Timer.isActive():
|
||||
self.Timer.start()
|
||||
|
@ -39,6 +39,7 @@ class PhononController(MediaController):
|
||||
MediaController.__init__(self, parent)
|
||||
|
||||
def load(self, display, path, volume):
|
||||
print "load vid in Phonon Controller"
|
||||
display.phononActive = True
|
||||
display.mediaObject.stop()
|
||||
display.mediaObject.clearQueue()
|
||||
|
@ -25,33 +25,70 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
from openlp.plugins.media.lib import MediaController
|
||||
import sys
|
||||
|
||||
from openlp.plugins.media.lib import MediaController, MediaStates
|
||||
|
||||
class VlcController(MediaController):
|
||||
"""
|
||||
Specialiced MediaController class
|
||||
to reflect Features of the Vlc backend
|
||||
"""
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
MediaController.__init__(self, parent)
|
||||
|
||||
def load(self, display, path, volume):
|
||||
pass
|
||||
print "load vid in Vlc Controller"
|
||||
vol = float(volume) / float(10)
|
||||
|
||||
# create the media
|
||||
display.vlcMedia = display.vlcInstance.media_new(unicode(path))
|
||||
# put the media in the media player
|
||||
display.vlcMediaPlayer.set_media(display.vlcMedia)
|
||||
|
||||
# parse the metadata of the file
|
||||
display.vlcMedia.parse()
|
||||
|
||||
# the media player has to be 'connected' to the QFrame
|
||||
# (otherwise a video would be displayed in it's own window)
|
||||
# this is platform specific!
|
||||
# you have to give the id of the QFrame (or similar object) to
|
||||
# vlc, different platforms have different functions for this
|
||||
if sys.platform == "linux2": # for Linux using the X Server
|
||||
display.vlcMediaPlayer.set_xwindow(int(display.vlcWidget.winId()))
|
||||
elif sys.platform == "win32": # for Windows
|
||||
display.vlcMediaPlayer.set_hwnd(int(display.vlcWidget.winId()))
|
||||
elif sys.platform == "darwin": # for MacOS
|
||||
display.vlcMediaPlayer.set_agl(int(display.vlcWidget.winId()))
|
||||
# start playing
|
||||
self.play(display)
|
||||
self.state = MediaStates.PlayingState
|
||||
|
||||
def play(self, display):
|
||||
self.display[u'live']
|
||||
display.vlcMediaPlayer.play()
|
||||
self.state = MediaStates.PlayingState
|
||||
|
||||
def pause(self):
|
||||
pass
|
||||
def pause(self, display):
|
||||
display.vlcMediaPlayer.pause()
|
||||
self.state = MediaStates.PausedState
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
def stop(self, display):
|
||||
display.vlcMediaPlayer.stop()
|
||||
self.state = MediaStates.StoppedState
|
||||
|
||||
def seek(self, display, seekVal):
|
||||
if display.vlcMediaPlayer.is_seekable():
|
||||
display.vlcMediaPlayer.set_position(seekVal/1000.0)
|
||||
|
||||
def reset(self, display):
|
||||
pass
|
||||
|
||||
def updateUI(self):
|
||||
pass
|
||||
def updateUI(self, display):
|
||||
display.parent.seekSlider.setMaximum(1000)
|
||||
if not display.parent.seekSlider.isSliderDown():
|
||||
currentPos = display.vlcMediaPlayer.get_position() * 1000
|
||||
display.parent.seekSlider.setSliderPosition(currentPos)
|
||||
|
||||
def getSupportedFileTypes(self):
|
||||
pass
|
||||
|
@ -25,7 +25,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
from openlp.plugins.media.lib import MediaController
|
||||
from openlp.plugins.media.lib import MediaController, MediaStates
|
||||
|
||||
class WebkitController(MediaController):
|
||||
"""
|
||||
@ -38,9 +38,11 @@ class WebkitController(MediaController):
|
||||
self.isFlash = False
|
||||
|
||||
def load(self, display, path, volume):
|
||||
print "load vid in Webkit Controller"
|
||||
vol = float(volume) / float(10)
|
||||
display.webView.setVisible(True)
|
||||
display.phononWidget.setVisible(False)
|
||||
display.vlcWidget.setVisible(False)
|
||||
if path.endswith(u'.swf'):
|
||||
js = u'show_flash("load","%s");' % \
|
||||
(path.replace(u'\\', u'\\\\'))
|
||||
@ -50,34 +52,44 @@ class WebkitController(MediaController):
|
||||
(path.replace(u'\\', u'\\\\'), str(vol))
|
||||
self.isFlash = False
|
||||
display.frame.evaluateJavaScript(js)
|
||||
self.state = MediaStates.PlayingState
|
||||
|
||||
def play(self, display):
|
||||
if self.isFlash:
|
||||
display.frame.evaluateJavaScript(u'show_flash("play","");')
|
||||
else:
|
||||
display.frame.evaluateJavaScript(u'show_video("play");')
|
||||
|
||||
self.state = MediaStates.PlayingState
|
||||
|
||||
def pause(self, display):
|
||||
if self.isFlash:
|
||||
display.frame.evaluateJavaScript(u'show_flash("pause","");')
|
||||
else:
|
||||
display.frame.evaluateJavaScript(u'show_video("pause");')
|
||||
self.state = MediaStates.PausedState
|
||||
|
||||
def stop(self, display):
|
||||
if self.isFlash:
|
||||
display.frame.evaluateJavaScript(u'show_flash("stop","");')
|
||||
else:
|
||||
display.frame.evaluateJavaScript(u'show_video("stop");')
|
||||
self.state = MediaStates.StoppedState
|
||||
|
||||
def seek(self, display, seekVal):
|
||||
pass
|
||||
if not self.isFlash:
|
||||
print seekVal, float(seekVal)/1000
|
||||
display.frame.evaluateJavaScript(u'show_video("seek", "%f");' % (float(seekVal)/1000))
|
||||
|
||||
def reset(self, display):
|
||||
display.frame.evaluateJavaScript(u'show_video("close");')
|
||||
|
||||
def updateUI(self, display):
|
||||
pass
|
||||
if not self.isFlash:
|
||||
length = display.frame.evaluateJavaScript(u'show_video("length");')
|
||||
display.parent.seekSlider.setMaximum(length.toFloat()[0]*1000)
|
||||
if not display.parent.seekSlider.isSliderDown():
|
||||
currentTime = display.frame.evaluateJavaScript(u'show_video("currentTime");')
|
||||
display.parent.seekSlider.setSliderPosition(currentTime.toFloat()[0]*1000)
|
||||
|
||||
def getSupportedFileTypes(self):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user