Remove flash

This commit is contained in:
Tim Bentley 2016-02-14 08:38:21 +00:00
parent 7a72fe84df
commit 360d1155f1
3 changed files with 27 additions and 57 deletions

View File

@ -60,8 +60,8 @@ class MediaInfo(object):
""" """
file_info = None file_info = None
volume = 100 volume = 100
is_flash = False
is_background = False is_background = False
loop_playback = False
length = 0 length = 0
start_time = 0 start_time = 0
end_time = 0 end_time = 0

View File

@ -107,6 +107,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
Registry().register_function('playbackPlay', self.media_play_msg) Registry().register_function('playbackPlay', self.media_play_msg)
Registry().register_function('playbackPause', self.media_pause_msg) Registry().register_function('playbackPause', self.media_pause_msg)
Registry().register_function('playbackStop', self.media_stop_msg) Registry().register_function('playbackStop', self.media_stop_msg)
Registry().register_function('playbackLoop', self.media_loop_msg)
Registry().register_function('seek_slider', self.media_seek_msg) Registry().register_function('seek_slider', self.media_seek_msg)
Registry().register_function('volume_slider', self.media_volume_msg) Registry().register_function('volume_slider', self.media_volume_msg)
Registry().register_function('media_hide', self.media_hide) Registry().register_function('media_hide', self.media_hide)
@ -279,6 +280,10 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
icon=':/slides/media_playback_stop.png', icon=':/slides/media_playback_stop.png',
tooltip=translate('OpenLP.SlideController', 'Stop playing media.'), tooltip=translate('OpenLP.SlideController', 'Stop playing media.'),
triggers=controller.send_to_plugins) triggers=controller.send_to_plugins)
controller.mediabar.add_toolbar_action('playbackLoop', text='media_playback_loop',
icon=':/slides/media_playback_stop.png',
tooltip=translate('OpenLP.SlideController', 'Loop playing media.'),
triggers=controller.send_to_plugins)
controller.position_label = QtWidgets.QLabel() controller.position_label = QtWidgets.QLabel()
controller.position_label.setText(' 00:00 / 00:00') controller.position_label.setText(' 00:00 / 00:00')
controller.position_label.setToolTip(translate('OpenLP.SlideController', 'Video timer.')) controller.position_label.setToolTip(translate('OpenLP.SlideController', 'Video timer.'))
@ -623,13 +628,8 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
if not controller.media_info.is_background: if not controller.media_info.is_background:
display.frame.evaluateJavaScript('show_blank("desktop");') display.frame.evaluateJavaScript('show_blank("desktop");')
self.current_media_players[controller.controller_type].set_visible(display, True) self.current_media_players[controller.controller_type].set_visible(display, True)
# Flash needs to be played and will not AutoPlay controller.mediabar.actions['playbackPlay'].setVisible(False)
if controller.media_info.is_flash: controller.mediabar.actions['playbackPause'].setVisible(True)
controller.mediabar.actions['playbackPlay'].setVisible(True)
controller.mediabar.actions['playbackPause'].setVisible(False)
else:
controller.mediabar.actions['playbackPlay'].setVisible(False)
controller.mediabar.actions['playbackPause'].setVisible(True)
controller.mediabar.actions['playbackStop'].setDisabled(False) controller.mediabar.actions['playbackStop'].setDisabled(False)
if controller.is_live: if controller.is_live:
if controller.hide_menu.defaultAction().isChecked() and not controller.media_info.is_background: if controller.hide_menu.defaultAction().isChecked() and not controller.media_info.is_background:

View File

@ -249,11 +249,7 @@ class WebkitPlayer(MediaPlayer):
else: else:
loop = 'false' loop = 'false'
display.web_view.setVisible(True) display.web_view.setVisible(True)
if controller.media_info.file_info.suffix() == 'swf': js = 'show_video("load", "%s", %s, %s);' % (path.replace('\\', '\\\\'), str(vol), loop)
controller.media_info.is_flash = True
js = 'show_flash("load","%s");' % (path.replace('\\', '\\\\'))
else:
js = 'show_video("load", "%s", %s, %s);' % (path.replace('\\', '\\\\'), str(vol), loop)
display.frame.evaluateJavaScript(js) display.frame.evaluateJavaScript(js)
return True return True
@ -274,10 +270,7 @@ class WebkitPlayer(MediaPlayer):
if self.state != MediaState.Paused and controller.media_info.start_time > 0: if self.state != MediaState.Paused and controller.media_info.start_time > 0:
start_time = controller.media_info.start_time start_time = controller.media_info.start_time
self.set_visible(display, True) self.set_visible(display, True)
if controller.media_info.is_flash: display.frame.evaluateJavaScript('show_video("play");')
display.frame.evaluateJavaScript('show_flash("play");')
else:
display.frame.evaluateJavaScript('show_video("play");')
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)
# TODO add playing check and get the correct media length # TODO add playing check and get the correct media length
@ -291,10 +284,7 @@ class WebkitPlayer(MediaPlayer):
Pause a video Pause a video
""" """
controller = display.controller controller = display.controller
if controller.media_info.is_flash: display.frame.evaluateJavaScript('show_video("pause");')
display.frame.evaluateJavaScript('show_flash("pause");')
else:
display.frame.evaluateJavaScript('show_video("pause");')
self.state = MediaState.Paused self.state = MediaState.Paused
def stop(self, display): def stop(self, display):
@ -302,10 +292,7 @@ class WebkitPlayer(MediaPlayer):
Stop a video Stop a video
""" """
controller = display.controller controller = display.controller
if controller.media_info.is_flash: display.frame.evaluateJavaScript('show_video("stop");')
display.frame.evaluateJavaScript('show_flash("stop");')
else:
display.frame.evaluateJavaScript('show_video("stop");')
self.state = MediaState.Stopped self.state = MediaState.Stopped
def volume(self, display, volume): def volume(self, display, volume):
@ -316,30 +303,20 @@ class WebkitPlayer(MediaPlayer):
# 1.0 is the highest value # 1.0 is the highest value
if display.has_audio: if display.has_audio:
vol = float(volume) / float(100) vol = float(volume) / float(100)
if not controller.media_info.is_flash: display.frame.evaluateJavaScript('show_video(null, null, %s);' % str(vol))
display.frame.evaluateJavaScript('show_video(null, null, %s);' % str(vol))
def seek(self, display, seek_value): def seek(self, display, seek_value):
""" """
Go to a position in the video Go to a position in the video
""" """
controller = display.controller seek = float(seek_value) / 1000
if controller.media_info.is_flash: display.frame.evaluateJavaScript('show_video("seek", null, null, null, "%f");' % seek)
seek = seek_value
display.frame.evaluateJavaScript('show_flash("seek", null, null, "%s");' % seek)
else:
seek = float(seek_value) / 1000
display.frame.evaluateJavaScript('show_video("seek", null, null, null, "%f");' % seek)
def reset(self, display): def reset(self, display):
""" """
Reset the player Reset the player
""" """
controller = display.controller display.frame.evaluateJavaScript('show_video("close");')
if controller.media_info.is_flash:
display.frame.evaluateJavaScript('show_flash("close");')
else:
display.frame.evaluateJavaScript('show_video("close");')
self.state = MediaState.Off self.state = MediaState.Off
def set_visible(self, display, status): def set_visible(self, display, status):
@ -351,30 +328,23 @@ class WebkitPlayer(MediaPlayer):
is_visible = "visible" is_visible = "visible"
else: else:
is_visible = "hidden" is_visible = "hidden"
if controller.media_info.is_flash: display.frame.evaluateJavaScript('show_video("setVisible", null, null, null, "%s");' % is_visible)
display.frame.evaluateJavaScript('show_flash("setVisible", null, null, "%s");' % is_visible)
else:
display.frame.evaluateJavaScript('show_video("setVisible", null, null, null, "%s");' % is_visible)
def update_ui(self, display): def update_ui(self, display):
""" """
Update the UI Update the UI
""" """
controller = display.controller controller = display.controller
if controller.media_info.is_flash: if display.frame.evaluateJavaScript('show_video("isEnded");'):
current_time = display.frame.evaluateJavaScript('show_flash("current_time");') self.stop(display)
length = display.frame.evaluateJavaScript('show_flash("length");') current_time = display.frame.evaluateJavaScript('show_video("current_time");')
else: # check if conversion was ok and value is not 'NaN'
if display.frame.evaluateJavaScript('show_video("isEnded");'): if current_time and current_time != float('inf'):
self.stop(display) current_time = int(current_time * 1000)
current_time = display.frame.evaluateJavaScript('show_video("current_time");') length = display.frame.evaluateJavaScript('show_video("length");')
# check if conversion was ok and value is not 'NaN' # check if conversion was ok and value is not 'NaN'
if current_time and current_time != float('inf'): if length and length != float('inf'):
current_time = int(current_time * 1000) length = int(length * 1000)
length = display.frame.evaluateJavaScript('show_video("length");')
# check if conversion was ok and value is not 'NaN'
if length and length != float('inf'):
length = int(length * 1000)
if current_time and length: if current_time and length:
print("webkit update_ui", controller.media_info.length) print("webkit update_ui", controller.media_info.length)
controller.media_info.length = length controller.media_info.length = length