add starttime for python and vlc

This commit is contained in:
rimach crichter@web.de 2011-07-25 22:56:39 +02:00
parent c61f23370c
commit 1c63ef3ea1
6 changed files with 60 additions and 21 deletions

View File

@ -61,7 +61,7 @@ from screen import ScreenList
from maindisplay import MainDisplay, Display from maindisplay import MainDisplay, Display
from servicenoteform import ServiceNoteForm from servicenoteform import ServiceNoteForm
from serviceitemeditform import ServiceItemEditForm from serviceitemeditform import ServiceItemEditForm
from slidecontroller import SlideController from slidecontroller import SlideController, Controller
from splashscreen import SplashScreen from splashscreen import SplashScreen
from generaltab import GeneralTab from generaltab import GeneralTab
from themestab import ThemesTab from themestab import ThemesTab

View File

@ -268,14 +268,16 @@ class MediaManager(object):
controller.media_info.file_info = QtCore.QFileInfo(file) controller.media_info.file_info = QtCore.QFileInfo(file)
controller.media_info.is_background = isBackground controller.media_info.is_background = isBackground
if controller.isLive: if controller.isLive:
if self.withLivePreview: if self.withLivePreview and controller.previewDisplay:
display = controller.previewDisplay display = controller.previewDisplay
isValid = self.check_file_type(controller, display) isValid = self.check_file_type(controller, display)
display = controller.display display = controller.display
isValid = self.check_file_type(controller, display) isValid = self.check_file_type(controller, display)
display.override[u'theme'] = u'' display.override[u'theme'] = u''
display.override[u'video'] = True display.override[u'video'] = True
else: controller.media_info.start_time = display.serviceItem.start_time
controller.media_info.end_time = display.serviceItem.end_time
elif controller.previewDisplay:
display = controller.previewDisplay display = controller.previewDisplay
isValid = self.check_file_type(controller, display) isValid = self.check_file_type(controller, display)
if not isValid: if not isValid:

View File

@ -155,12 +155,22 @@ class PhononAPI(MediaAPI):
display.phononWidget.resize(display.size()) display.phononWidget.resize(display.size())
def play(self, display): def play(self, display):
self.set_visible(display, True)
controller = display.controller controller = display.controller
start_time = 0
vol = float(controller.media_info.volume) / float(10) vol = float(controller.media_info.volume) / float(10)
display.audio.setVolume(vol) if display.mediaObject.state() != Phonon.PausedState and \
controller.media_info.start_time > 0:
start_time = controller.media_info.start_time
display.mediaObject.play() display.mediaObject.play()
if self.mediaStateWait(display, Phonon.PlayingState):
if start_time > 0:
self.seek(display, controller.media_info.start_time*1000)
display.audio.setVolume(vol)
controller.media_info.length = \
int(display.mediaObject.totalTime()/1000)
controller.seekSlider.setMaximum(controller.media_info.length*1000)
self.state = MediaState.Playing self.state = MediaState.Playing
self.set_visible(display, True)
def pause(self, display): def pause(self, display):
display.mediaObject.pause() display.mediaObject.pause()
@ -193,15 +203,9 @@ class PhononAPI(MediaAPI):
def update_ui(self, display): def update_ui(self, display):
controller = display.controller controller = display.controller
controller.media_info.length = display.mediaObject.totalTime()
controller.seekSlider.setMaximum(controller.media_info.length)
if controller.media_info.start_time > 0:
if display.mediaObject.currentTime() < \
controller.media_info.start_time:
self.seek(display, controller.media_info.start_time)
if controller.media_info.end_time > 0: if controller.media_info.end_time > 0:
if display.mediaObject.currentTime() > \ if display.mediaObject.currentTime() > \
controller.media_info.end_time: controller.media_info.end_time*1000:
self.stop(display) self.stop(display)
self.set_visible(display, False) self.set_visible(display, False)
if not controller.seekSlider.isSliderDown(): if not controller.seekSlider.isSliderDown():

View File

@ -138,10 +138,19 @@ class VlcAPI(MediaAPI):
display.vlcWidget.resize(display.size()) display.vlcWidget.resize(display.size())
def play(self, display): def play(self, display):
self.set_visible(display, True) controller = display.controller
start_time = 0
if controller.media_info.start_time > 0:
start_time = controller.media_info.start_time
display.vlcMediaPlayer.play() display.vlcMediaPlayer.play()
if self.mediaStateWait(display, vlc.State.Playing): if self.mediaStateWait(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.state = MediaState.Playing
self.set_visible(display, True)
def pause(self, display): def pause(self, display):
if display.vlcMedia.get_state() != vlc.State.Playing: if display.vlcMedia.get_state() != vlc.State.Playing:
@ -160,7 +169,7 @@ class VlcAPI(MediaAPI):
def seek(self, display, seekVal): def seek(self, display, seekVal):
if display.vlcMediaPlayer.is_seekable(): if display.vlcMediaPlayer.is_seekable():
display.vlcMediaPlayer.set_position(seekVal/1000.0) display.vlcMediaPlayer.set_time(seekVal)
def reset(self, display): def reset(self, display):
display.vlcMediaPlayer.stop() display.vlcMediaPlayer.stop()
@ -173,7 +182,11 @@ class VlcAPI(MediaAPI):
def update_ui(self, display): def update_ui(self, display):
controller = display.controller controller = display.controller
controller.seekSlider.setMaximum(1000) if controller.media_info.end_time > 0:
if display.vlcMediaPlayer.get_time() > \
controller.media_info.end_time*1000:
self.stop(display)
self.set_visible(display, False)
if not controller.seekSlider.isSliderDown(): if not controller.seekSlider.isSliderDown():
currentPos = display.vlcMediaPlayer.get_position() * 1000 controller.seekSlider.setSliderPosition( \
controller.seekSlider.setSliderPosition(currentPos) display.vlcMediaPlayer.get_time())

View File

@ -300,11 +300,14 @@ class WebkitAPI(MediaAPI):
def play(self, display): def play(self, display):
controller = display.controller controller = display.controller
display.webLoaded = True display.webLoaded = True
length = 0
self.set_visible(display, True) self.set_visible(display, True)
if controller.media_info.isFlash: if controller.media_info.isFlash:
display.frame.evaluateJavaScript(u'show_flash("play");') display.frame.evaluateJavaScript(u'show_flash("play");')
else: else:
display.frame.evaluateJavaScript(u'show_video("play");') display.frame.evaluateJavaScript(u'show_video("play");')
#TODO add playing check and get the correct media length
controller.media_info.length = length
self.state = MediaState.Playing self.state = MediaState.Playing
def pause(self, display): def pause(self, display):
@ -374,6 +377,7 @@ class WebkitAPI(MediaAPI):
if ok and length == length: if ok and length == length:
length = int(length*1000) length = int(length*1000)
if currentTime > 0: if currentTime > 0:
controller.media_info.length = length
controller.seekSlider.setMaximum(length) controller.seekSlider.setMaximum(length)
if not controller.seekSlider.isSliderDown(): if not controller.seekSlider.isSliderDown():
controller.seekSlider.setSliderPosition(currentTime) controller.seekSlider.setSliderPosition(currentTime)

View File

@ -34,6 +34,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \ from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
SettingsManager, translate, check_item_selected, Receiver SettingsManager, translate, check_item_selected, Receiver
from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.ui import Controller, Display
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -52,6 +53,15 @@ class MediaMediaItem(MediaManagerItem):
self.singleServiceItem = False self.singleServiceItem = False
self.hasSearch = True self.hasSearch = True
self.mediaObject = None 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.mediaController.previewDisplay.setup()
self.plugin.mediaManager.setup_display(self.mediaController.previewDisplay)
self.mediaController.previewDisplay.hide()
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'video_background_replaced'), QtCore.SIGNAL(u'video_background_replaced'),
self.videobackgroundReplaced) self.videobackgroundReplaced)
@ -137,10 +147,16 @@ class MediaMediaItem(MediaManagerItem):
'The file %s no longer exists.')) % filename) 'The file %s no longer exists.')) % filename)
return False return False
self.mediaLength = 0 self.mediaLength = 0
if self.plugin.mediaManager.video( \
self.mediaController, filename, False, False):
self.mediaLength = self.mediaController.media_info.length
service_item.media_length = self.mediaLength
self.plugin.mediaManager.video_reset(self.mediaController)
if self.mediaLength > 0:
service_item.add_capability(
ItemCapabilities.AllowsVariableStartTime)
print self.mediaLength
service_item.media_length = self.mediaLength service_item.media_length = self.mediaLength
#TODO
#service_item.add_capability(
# ItemCapabilities.AllowsVariableStartTime)
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)
# force a non-existent theme # force a non-existent theme