forked from openlp/openlp
first merge
This commit is contained in:
parent
12141d6a7e
commit
8de95e34a0
@ -66,6 +66,8 @@ class MediaInfo(object):
|
||||
start_time = 0
|
||||
end_time = 0
|
||||
title_track = 0
|
||||
playing = False
|
||||
timer = 1000
|
||||
audio_track = 0
|
||||
subtitle_track = 0
|
||||
media_type = MediaType()
|
||||
|
@ -274,6 +274,11 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
icon=':/slides/media_playback_stop.png',
|
||||
tooltip=translate('OpenLP.SlideController', 'Stop playing media.'),
|
||||
triggers=controller.send_to_plugins)
|
||||
controller.position_label = QtGui.QLabel()
|
||||
controller.position_label.setText(' 00:00 / 00:00')
|
||||
controller.position_label.setToolTip(translate('OpenLP.SlideController', 'Video timer.'))
|
||||
controller.position_label.setObjectName('position_label')
|
||||
controller.mediabar.add_toolbar_widget(controller.position_label)
|
||||
# Build the seek_slider.
|
||||
controller.seek_slider = MediaSlider(QtCore.Qt.Horizontal, self, controller)
|
||||
controller.seek_slider.setMaximum(1000)
|
||||
@ -296,6 +301,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
controller.volume_slider.setObjectName('volume_slider')
|
||||
controller.mediabar.add_toolbar_widget(controller.volume_slider)
|
||||
controller.controller_layout.addWidget(controller.mediabar)
|
||||
controller.controller_layout.addWidget(controller.mediabar)
|
||||
controller.mediabar.setVisible(False)
|
||||
# Signals
|
||||
controller.seek_slider.valueChanged.connect(controller.send_to_plugins)
|
||||
@ -605,6 +611,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
self.timer.start()
|
||||
controller.seek_slider.blockSignals(False)
|
||||
controller.volume_slider.blockSignals(False)
|
||||
controller.media_info.playing = True
|
||||
return True
|
||||
|
||||
def media_pause_msg(self, msg):
|
||||
@ -616,6 +623,28 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
log.debug('media_pause_msg')
|
||||
self.media_pause(msg[0])
|
||||
|
||||
def tick(self, controller):
|
||||
"""
|
||||
Add a tick while the media is playing but only count if not paused
|
||||
|
||||
:param controller: The Controller to be processed
|
||||
"""
|
||||
if controller.media_info.playing:
|
||||
print(controller.media_info.timer)
|
||||
if controller.media_info.timer > controller.media_info.length:
|
||||
controller.media_info.timer = controller.media_info.length
|
||||
controller.media_info.timer += 1000
|
||||
seconds = controller.media_info.timer // 1000
|
||||
print(seconds)
|
||||
minutes = seconds // 60
|
||||
seconds %= 60
|
||||
total_seconds = controller.media_info.length // 1000
|
||||
total_minutes = total_seconds // 60
|
||||
total_seconds %= 60
|
||||
controller.position_label.setText(' %02d:%02d / %02d:%02d' %
|
||||
(minutes, seconds, total_minutes, total_seconds))
|
||||
print(minutes, seconds, total_minutes, total_seconds)
|
||||
|
||||
def media_pause(self, controller):
|
||||
"""
|
||||
Responds to the request to pause a loaded video
|
||||
@ -628,6 +657,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
controller.mediabar.actions['playbackPlay'].setVisible(True)
|
||||
controller.mediabar.actions['playbackStop'].setDisabled(False)
|
||||
controller.mediabar.actions['playbackPause'].setVisible(False)
|
||||
controller.media_info.playing = False
|
||||
|
||||
def media_stop_msg(self, msg):
|
||||
"""
|
||||
@ -645,6 +675,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
:param controller: The controller that needs to be stopped
|
||||
"""
|
||||
log.debug('media_stop')
|
||||
print("media_stop")
|
||||
display = self._define_display(controller)
|
||||
if controller.controller_type in self.current_media_players:
|
||||
display.frame.evaluateJavaScript('show_blank("black");')
|
||||
@ -654,6 +685,8 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
controller.mediabar.actions['playbackPlay'].setVisible(True)
|
||||
controller.mediabar.actions['playbackStop'].setDisabled(True)
|
||||
controller.mediabar.actions['playbackPause'].setVisible(False)
|
||||
controller.media_info.playing = False
|
||||
controller.media_info.timer = 1000
|
||||
|
||||
def media_volume_msg(self, msg):
|
||||
"""
|
||||
@ -699,10 +732,13 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
log.debug('media_seek')
|
||||
display = self._define_display(controller)
|
||||
self.current_media_players[controller.controller_type].seek(display, seek_value)
|
||||
print(controller.media_info.timer, controller.media_info.length, seek_value)
|
||||
controller.media_info.timer = seek_value
|
||||
|
||||
def media_reset(self, controller):
|
||||
"""
|
||||
Responds to the request to reset a loaded video
|
||||
:param controller: The controller to use.
|
||||
"""
|
||||
log.debug('media_reset')
|
||||
self.set_controls_visible(controller, False)
|
||||
|
@ -156,6 +156,7 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
self.process_queue_lock = Lock()
|
||||
self.slide_selected_lock = Lock()
|
||||
self.timer_id = 0
|
||||
self.media_timer = 0;
|
||||
self.song_edit = False
|
||||
self.selected_row = 0
|
||||
self.service_item = None
|
||||
@ -1302,6 +1303,8 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
"""
|
||||
if event.timerId() == self.timer_id:
|
||||
self.on_slide_selected_next(self.play_slides_loop.isChecked())
|
||||
elif event.timerId() == self.media_timer:
|
||||
self.media_controller.tick(self)
|
||||
|
||||
def on_edit_song(self, field=None):
|
||||
"""
|
||||
@ -1361,6 +1364,8 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
if not self.is_live:
|
||||
self.preview_display.show()
|
||||
self.slide_preview.hide()
|
||||
# One Second pings
|
||||
self.media_timer = self.startTimer(1000)
|
||||
|
||||
def on_media_close(self):
|
||||
"""
|
||||
@ -1369,6 +1374,7 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
self.media_controller.media_reset(self)
|
||||
self.preview_display.hide()
|
||||
self.slide_preview.show()
|
||||
self.media_timer = 0
|
||||
|
||||
def _reset_blank(self, no_theme):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user