From 09e7e16b126376b13fde5598e1450de79b25191b Mon Sep 17 00:00:00 2001 From: rimach Date: Tue, 13 Mar 2012 20:54:16 +0100 Subject: [PATCH 1/2] fix issue, that video slider doesnt go back at video end --- openlp/core/ui/media/mediacontroller.py | 10 ++++++++++ openlp/core/ui/media/phononplayer.py | 5 ++++- openlp/core/ui/media/vlcplayer.py | 6 ++++-- openlp/core/ui/media/webkitplayer.py | 12 +++++++++--- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 2fd5528ca..ac210792a 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -57,10 +57,16 @@ class MediaController(object): # Signals QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.video_state) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'playbackPlay'), self.video_play) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_playback_play'), self.video_play) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'playbackPause'), self.video_pause) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_playback_pause'), self.video_pause) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'playbackStop'), self.video_stop) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_playback_stop'), self.video_stop) QtCore.QObject.connect(Receiver.get_receiver(), @@ -160,6 +166,9 @@ class MediaController(object): if self.curDisplayMediaPlayer[display] \ .state == MediaState.Playing: return + # no players are active anymore + for display in self.curDisplayMediaPlayer.keys(): + display.controller.seekSlider.setSliderPosition(0) self.timer.stop() def get_media_display_css(self): @@ -451,6 +460,7 @@ class MediaController(object): display.frame.evaluateJavaScript(u'show_blank("black");') self.curDisplayMediaPlayer[display].stop(display) self.curDisplayMediaPlayer[display].set_visible(display, False) + controller.seekSlider.setSliderPosition(0) def video_volume(self, msg): """ diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index ea4d16260..c366fe339 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -57,7 +57,7 @@ ADDITIONAL_EXT = { class PhononPlayer(MediaPlayer): """ - A specialised version of the MediaPlayer class, which provides a Phonon + A specialised version of the MediaPlayer class, which provides a Phonon display. """ @@ -192,6 +192,9 @@ class PhononPlayer(MediaPlayer): display.phononWidget.setVisible(status) def update_ui(self, display): + if display.mediaObject.state() == Phonon.PausedState and \ + self.state != MediaState.Paused: + self.stop(display) controller = display.controller if controller.media_info.end_time > 0: if display.mediaObject.currentTime() > \ diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 406db33b1..70a5c1cb5 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -83,7 +83,7 @@ VIDEO_EXT = [ class VlcPlayer(MediaPlayer): """ - A specialised version of the MediaPlayer class, which provides a QtWebKit + A specialised version of the MediaPlayer class, which provides a VLC display. """ @@ -122,7 +122,7 @@ class VlcPlayer(MediaPlayer): display.vlcMediaPlayer.set_hwnd(int(display.vlcWidget.winId())) elif sys.platform == "darwin": # for MacOS display.vlcMediaPlayer.set_agl(int(display.vlcWidget.winId())) - else: + else: # for Linux using the X Server display.vlcMediaPlayer.set_xwindow(int(display.vlcWidget.winId())) self.hasOwnWidget = True @@ -210,6 +210,8 @@ class VlcPlayer(MediaPlayer): display.vlcWidget.setVisible(status) def update_ui(self, display): + if display.vlcMedia.get_state() == vlc.State.Ended: + self.stop(display) controller = display.controller if controller.media_info.end_time > 0: if display.vlcMediaPlayer.get_time() > \ diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index da8d52625..e3713d7ae 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -126,7 +126,7 @@ VIDEO_JS = u""" vid.src = ''; vid2.src = ''; break; - case 'length': + case 'length': return vid.duration; case 'currentTime': return vid.currentTime; @@ -134,6 +134,8 @@ VIDEO_JS = u""" // doesnt work currently vid.currentTime = varVal; break; + case 'isEnded': + return vid.ended; case 'setVisible': vid.style.visibility = varVal; break; @@ -211,6 +213,8 @@ FLASH_JS = u""" case 'seek': // flashMovie.GotoFrame(varVal); break; + case 'isEnded': + return false;//TODO check flash end case 'setVisible': text.style.visibility = varVal; break; @@ -254,7 +258,7 @@ AUDIO_EXT = [ class WebkitPlayer(MediaPlayer): """ - A specialised version of the MediaPlayer class, which provides a QtWebKit + A specialised version of the MediaPlayer class, which provides a QtWebKit display. """ @@ -356,7 +360,6 @@ class WebkitPlayer(MediaPlayer): display.frame.evaluateJavaScript(u'show_flash("stop");') else: display.frame.evaluateJavaScript(u'show_video("stop");') - controller.seekSlider.setSliderPosition(0) self.state = MediaState.Stopped def volume(self, display, vol): @@ -408,6 +411,9 @@ class WebkitPlayer(MediaPlayer): length = display.frame.evaluateJavaScript( \ u'show_flash("length");').toInt()[0] else: + if display.frame.evaluateJavaScript( \ + u'show_video("isEnded");').toString() == 'true': + self.stop(display) (currentTime, ok) = display.frame.evaluateJavaScript( \ u'show_video("currentTime");').toFloat() # check if conversion was ok and value is not 'NaN' From 7464d0f9fc00c6f99f9b7399abb1126a56c1495b Mon Sep 17 00:00:00 2001 From: rimach Date: Fri, 16 Mar 2012 22:09:27 +0100 Subject: [PATCH 2/2] correct pause check, correct signal names --- openlp/core/ui/media/mediacontroller.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index ac210792a..228809042 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -59,20 +59,14 @@ class MediaController(object): QtCore.SIGNAL("timeout()"), self.video_state) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackPlay'), self.video_play) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_playback_play'), self.video_play) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackPause'), self.video_pause) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_playback_pause'), self.video_pause) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackStop'), self.video_stop) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_playback_stop'), self.video_stop) + QtCore.SIGNAL(u'seekSlider'), self.video_seek) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'seek_slider'), self.video_seek) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'volume_slider'), self.video_volume) + QtCore.SIGNAL(u'volumeSlider'), self.video_volume) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_hide'), self.video_hide) QtCore.QObject.connect(Receiver.get_receiver(), @@ -168,7 +162,9 @@ class MediaController(object): return # no players are active anymore for display in self.curDisplayMediaPlayer.keys(): - display.controller.seekSlider.setSliderPosition(0) + if self.curDisplayMediaPlayer[display] \ + .state != MediaState.Paused: + display.controller.seekSlider.setSliderPosition(0) self.timer.stop() def get_media_display_css(self):