forked from openlp/openlp
bugfixing
This commit is contained in:
parent
11acf005e2
commit
2c225c19a0
@ -30,9 +30,8 @@ import sys, os
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
try:
|
try:
|
||||||
import vlc
|
import vlc
|
||||||
if vlc.get_default_instance():
|
vlc_available = bool(vlc.get_default_instance())
|
||||||
vlc_available = True
|
except ImportError:
|
||||||
except:
|
|
||||||
vlc_available = False
|
vlc_available = False
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
@ -90,10 +89,14 @@ class VlcPlayer(MediaPlayer):
|
|||||||
def setup(self, display):
|
def setup(self, display):
|
||||||
display.vlcWidget = QtGui.QFrame(display)
|
display.vlcWidget = QtGui.QFrame(display)
|
||||||
# creating a basic vlc instance
|
# creating a basic vlc instance
|
||||||
if display.hasAudio:
|
command_line_options = u'--no-video-title-show'
|
||||||
display.vlcInstance = vlc.Instance()
|
if not display.hasAudio:
|
||||||
else:
|
command_line_options += u' --no-audio --no-video-title-show'
|
||||||
display.vlcInstance = vlc.Instance('--no-audio')
|
if QtCore.QSettings().value(u'advanced/hide mouse',
|
||||||
|
QtCore.QVariant(False)).toBool() and \
|
||||||
|
display.controller.isLive:
|
||||||
|
command_line_options += u' --mouse-hide-timeout=0'
|
||||||
|
display.vlcInstance = vlc.Instance(command_line_options)
|
||||||
display.vlcInstance.set_log_verbosity(2)
|
display.vlcInstance.set_log_verbosity(2)
|
||||||
# creating an empty vlc media player
|
# creating an empty vlc media player
|
||||||
display.vlcMediaPlayer = display.vlcInstance.media_player_new()
|
display.vlcMediaPlayer = display.vlcInstance.media_player_new()
|
||||||
@ -135,14 +138,14 @@ class VlcPlayer(MediaPlayer):
|
|||||||
def media_state_wait(self, display, mediaState):
|
def media_state_wait(self, display, mediaState):
|
||||||
"""
|
"""
|
||||||
Wait for the video to change its state
|
Wait for the video to change its state
|
||||||
Wait no longer than 5 seconds.
|
Wait no longer than 60 seconds. (loading an iso file needs a long time)
|
||||||
"""
|
"""
|
||||||
start = datetime.now()
|
start = datetime.now()
|
||||||
while not mediaState == display.vlcMedia.get_state():
|
while not mediaState == display.vlcMedia.get_state():
|
||||||
if display.vlcMedia.get_state() == vlc.State.Error:
|
if display.vlcMedia.get_state() == vlc.State.Error:
|
||||||
return False
|
return False
|
||||||
Receiver.send_message(u'openlp_process_events')
|
Receiver.send_message(u'openlp_process_events')
|
||||||
if (datetime.now() - start).seconds > 50:
|
if (datetime.now() - start).seconds > 60:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -157,10 +160,10 @@ class VlcPlayer(MediaPlayer):
|
|||||||
display.vlcMediaPlayer.play()
|
display.vlcMediaPlayer.play()
|
||||||
if self.media_state_wait(display, vlc.State.Playing):
|
if self.media_state_wait(display, vlc.State.Playing):
|
||||||
if start_time > 0:
|
if start_time > 0:
|
||||||
self.seek(display, controller.media_info.start_time*1000)
|
self.seek(display, controller.media_info.start_time * 1000)
|
||||||
controller.media_info.length = \
|
controller.media_info.length = \
|
||||||
int(display.vlcMediaPlayer.get_media().get_duration()/1000)
|
int(display.vlcMediaPlayer.get_media().get_duration() / 1000)
|
||||||
controller.seekSlider.setMaximum(controller.media_info.length*1000)
|
controller.seekSlider.setMaximum(controller.media_info.length * 1000)
|
||||||
self.state = MediaState.Playing
|
self.state = MediaState.Playing
|
||||||
display.vlcWidget.raise_()
|
display.vlcWidget.raise_()
|
||||||
return True
|
return True
|
||||||
@ -199,7 +202,7 @@ class VlcPlayer(MediaPlayer):
|
|||||||
controller = display.controller
|
controller = display.controller
|
||||||
if controller.media_info.end_time > 0:
|
if controller.media_info.end_time > 0:
|
||||||
if display.vlcMediaPlayer.get_time() > \
|
if display.vlcMediaPlayer.get_time() > \
|
||||||
controller.media_info.end_time*1000:
|
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():
|
||||||
|
Loading…
Reference in New Issue
Block a user