This commit is contained in:
Tim Bentley 2016-01-01 20:39:26 +00:00
parent fe0cdc70fb
commit 9c2b472ee8
4 changed files with 47 additions and 2 deletions

View File

@ -542,6 +542,8 @@ class ServiceItem(RegistryProperties):
:param length: The length of the media item
"""
print("set_media_length " + str(length) + " " + self.processor)
print("set_media_length " + str(self.start_time) + " " + str(self.end_time))
self.media_length = length
if length > 0:
self.add_capability(ItemCapabilities.HasVariableStartTime)
@ -611,6 +613,7 @@ class ServiceItem(RegistryProperties):
if self.media_length != 0:
end = translate('OpenLP.ServiceItem', '<strong>Length</strong>: %s') % \
str(datetime.timedelta(seconds=self.media_length))
print("get_media_time " + str(self.media_length))
if not start and not end:
return ''
elif start and not end:

View File

@ -435,6 +435,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
:param service_item: The ServiceItem containing the details to be played.
"""
print('### media_length')
controller = self.display_controllers[DisplayControllerType.Plugin]
# stop running videos
self.media_reset(controller)
@ -451,8 +452,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'),
translate('MediaPlugin.MediaItem', 'Unsupported File'))
return False
print("####")
print(controller.media_info.length)
print("media_length " + str(controller.media_info.length))
service_item.set_media_length(controller.media_info.length)
self.media_stop(controller)
log.debug('use %s controller' % self.current_media_players[controller.controller_type])
@ -589,6 +589,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
:param controller: The controller to be played
:param status:
"""
print('### media_play')
controller.seek_slider.blockSignals(True)
controller.volume_slider.blockSignals(True)
display = self._define_display(controller)
@ -637,6 +638,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
:param controller: The Controller to be processed
"""
print('### tick')
if controller.media_info.playing:
if controller.media_info.timer > controller.media_info.length:
controller.media_info.timer = controller.media_info.length
@ -658,6 +660,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
:param controller: The Controller to be paused
"""
print('### media_pause')
display = self._define_display(controller)
self.current_media_players[controller.controller_type].pause(display)
controller.mediabar.actions['playbackPlay'].setVisible(True)
@ -679,6 +682,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
:param controller: The controller that needs to be stopped
"""
print('### media_stop')
display = self._define_display(controller)
if controller.controller_type in self.current_media_players:
display.frame.evaluateJavaScript('show_blank("black");')

View File

@ -134,6 +134,9 @@ class VlcPlayer(MediaPlayer):
def setup(self, display):
"""
Set up the media player
:param display: The display where the media is
:return:
"""
vlc = get_vlc()
display.vlc_widget = QtWidgets.QFrame(display)
@ -176,6 +179,9 @@ class VlcPlayer(MediaPlayer):
def load(self, display):
"""
Load a video into VLC
:param display: The display where the media is
:return:
"""
vlc = get_vlc()
log.debug('load vid in Vlc Controller')
@ -216,6 +222,10 @@ class VlcPlayer(MediaPlayer):
"""
Wait for the video to change its state
Wait no longer than 60 seconds. (loading an iso file needs a long time)
:param media_state: The state of the playing media
:param display: The display where the media is
:return:
"""
vlc = get_vlc()
start = datetime.now()
@ -230,12 +240,18 @@ class VlcPlayer(MediaPlayer):
def resize(self, display):
"""
Resize the player
:param display: The display where the media is
:return:
"""
display.vlc_widget.resize(display.size())
def play(self, display):
"""
Play the current item
:param display: The display where the media is
:return:
"""
vlc = get_vlc()
controller = display.controller
@ -275,6 +291,7 @@ class VlcPlayer(MediaPlayer):
if start_time > 0 and display.vlc_media_player.is_seekable():
display.vlc_media_player.set_time(int(start_time * 1000))
controller.seek_slider.setMaximum(controller.media_info.length * 1000)
print("VLC play " + str(controller.media_info.length))
self.state = MediaState.Playing
display.vlc_widget.raise_()
return True
@ -282,6 +299,9 @@ class VlcPlayer(MediaPlayer):
def pause(self, display):
"""
Pause the current item
:param display: The display where the media is
:return:
"""
vlc = get_vlc()
if display.vlc_media.get_state() != vlc.State.Playing:
@ -293,6 +313,9 @@ class VlcPlayer(MediaPlayer):
def stop(self, display):
"""
Stop the current item
:param display: The display where the media is
:return:
"""
threading.Thread(target=display.vlc_media_player.stop).start()
self.state = MediaState.Stopped
@ -300,6 +323,10 @@ class VlcPlayer(MediaPlayer):
def volume(self, display, vol):
"""
Set the volume
:param vol: The volume to be sets
:param display: The display where the media is
:return:
"""
if display.has_audio:
display.vlc_media_player.audio_set_volume(vol)
@ -307,6 +334,9 @@ class VlcPlayer(MediaPlayer):
def seek(self, display, seek_value):
"""
Go to a particular position
:param seek_value: The position of where a seek goes to
:param display: The display where the media is
"""
if display.controller.media_info.media_type == MediaType.CD \
or display.controller.media_info.media_type == MediaType.DVD:
@ -317,6 +347,8 @@ class VlcPlayer(MediaPlayer):
def reset(self, display):
"""
Reset the player
:param display: The display where the media is
"""
display.vlc_media_player.stop()
display.vlc_widget.setVisible(False)
@ -325,6 +357,9 @@ class VlcPlayer(MediaPlayer):
def set_visible(self, display, status):
"""
Set the visibility
:param display: The display where the media is
:param status: The visibility status
"""
if self.has_own_widget:
display.vlc_widget.setVisible(status)
@ -332,6 +367,8 @@ class VlcPlayer(MediaPlayer):
def update_ui(self, display):
"""
Update the UI
:param display: The display where the media is
"""
vlc = get_vlc()
# Stop video if playback is finished.

View File

@ -281,6 +281,7 @@ class WebkitPlayer(MediaPlayer):
if start_time > 0:
self.seek(display, controller.media_info.start_time * 1000)
# TODO add playing check and get the correct media length
print("Webkit play " + str(length))
controller.media_info.length = length
self.state = MediaState.Playing
display.web_view.raise_()