← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~mikey74/openlp/dvdplayerfix into lp:openlp

 

Mike has proposed merging lp:~mikey74/openlp/dvdplayerfix into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1514545 in OpenLP: "DVD audio/subtitle track selection is broken"
  https://bugs.launchpad.net/openlp/+bug/1514545

For more details, see:
https://code.launchpad.net/~mikey74/openlp/dvdplayerfix/+merge/320253

Made minor changes to several files to get DVD playback working.  Mostly had to do with how QTime is initiated: old QTime() -> new QTime(0, 0, 0) and then how milliseconds were being handled.

Once DVDs were playable, I noticed that if you paused a track and then hit the play button to resume playing it would start the track over again.  This did not happen with media files which would pause and resume as expected. So I added a check to see if the media_state was paused for both the preview and live controllers, that would bypass the reinitializing of the DVD player.
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~mikey74/openlp/dvdplayerfix into lp:openlp.
=== modified file 'openlp/core/ui/media/mediacontroller.py'
--- openlp/core/ui/media/mediacontroller.py	2016-12-31 11:01:36 +0000
+++ openlp/core/ui/media/mediacontroller.py	2017-03-17 19:22:38 +0000
@@ -498,7 +498,7 @@
         :return: True if setup succeeded else False.
         """
         if controller is None:
-            controller = self.display_controllers[DisplayControllerType.Plugin]
+            controller = self.display_controllers[DisplayControllerType.Preview]
         # stop running videos
         self.media_reset(controller)
         # Setup media info
@@ -508,9 +508,9 @@
             controller.media_info.media_type = MediaType.CD
         else:
             controller.media_info.media_type = MediaType.DVD
-        controller.media_info.start_time = start // 1000
-        controller.media_info.end_time = end // 1000
-        controller.media_info.length = (end - start) // 1000
+        controller.media_info.start_time = start
+        controller.media_info.end_time = end
+        controller.media_info.length = (end - start)
         controller.media_info.title_track = title
         controller.media_info.audio_track = audio_track
         controller.media_info.subtitle_track = subtitle_track

=== modified file 'openlp/core/ui/media/vlcplayer.py'
--- openlp/core/ui/media/vlcplayer.py	2016-12-31 11:01:36 +0000
+++ openlp/core/ui/media/vlcplayer.py	2017-03-17 19:22:38 +0000
@@ -279,7 +279,7 @@
                 start_time = controller.media_info.start_time
         log.debug('mediatype: ' + str(controller.media_info.media_type))
         # Set tracks for the optical device
-        if controller.media_info.media_type == MediaType.DVD:
+        if controller.media_info.media_type == MediaType.DVD and self.get_live_state() != MediaState.Paused and self.get_preview_state() != MediaState.Paused:
             log.debug('vlc play, playing started')
             if controller.media_info.title_track > 0:
                 log.debug('vlc play, title_track set: ' + str(controller.media_info.title_track))
@@ -349,7 +349,7 @@
         """
         if display.controller.media_info.media_type == MediaType.CD \
                 or display.controller.media_info.media_type == MediaType.DVD:
-            seek_value += int(display.controller.media_info.start_time * 1000)
+            seek_value += int(display.controller.media_info.start_time)
         if display.vlc_media_player.is_seekable():
             display.vlc_media_player.set_time(seek_value)
 
@@ -385,7 +385,7 @@
             self.stop(display)
         controller = display.controller
         if controller.media_info.end_time > 0:
-            if display.vlc_media_player.get_time() > controller.media_info.end_time * 1000:
+            if display.vlc_media_player.get_time() > controller.media_info.end_time:
                 self.stop(display)
                 self.set_visible(display, False)
         if not controller.seek_slider.isSliderDown():
@@ -393,7 +393,7 @@
             if display.controller.media_info.media_type == MediaType.CD \
                     or display.controller.media_info.media_type == MediaType.DVD:
                 controller.seek_slider.setSliderPosition(display.vlc_media_player.get_time() -
-                                                         int(display.controller.media_info.start_time * 1000))
+                                                         int(display.controller.media_info.start_time))
             else:
                 controller.seek_slider.setSliderPosition(display.vlc_media_player.get_time())
             controller.seek_slider.blockSignals(False)

=== modified file 'openlp/plugins/media/forms/mediaclipselectorform.py'
--- openlp/plugins/media/forms/mediaclipselectorform.py	2016-12-31 11:01:36 +0000
+++ openlp/plugins/media/forms/mediaclipselectorform.py	2017-03-17 19:22:38 +0000
@@ -107,7 +107,7 @@
         self.subtitle_tracks_combobox.clear()
         self.audio_tracks_combobox.clear()
         self.titles_combo_box.clear()
-        time = QtCore.QTime()
+        time = QtCore.QTime(0, 0, 0)
         self.start_position_edit.setTime(time)
         self.end_timeedit.setTime(time)
         self.position_timeedit.setTime(time)
@@ -292,7 +292,7 @@
         :param clicked: Given from signal, not used.
         """
         vlc_ms_pos = self.vlc_media_player.get_time()
-        time = QtCore.QTime()
+        time = QtCore.QTime(0, 0, 0)
         new_pos_time = time.addMSecs(vlc_ms_pos)
         self.start_position_edit.setTime(new_pos_time)
         # If start time is after end time, update end time.
@@ -308,7 +308,7 @@
         :param clicked: Given from signal, not used.
         """
         vlc_ms_pos = self.vlc_media_player.get_time()
-        time = QtCore.QTime()
+        time = QtCore.QTime(0, 0, 0)
         new_pos_time = time.addMSecs(vlc_ms_pos)
         self.end_timeedit.setTime(new_pos_time)
         # If start time is after end time, update start time.
@@ -445,7 +445,7 @@
         self.position_slider.setMaximum(self.playback_length)
         # setup start and end time
         rounded_vlc_ms_length = int(round(self.playback_length / 100.0) * 100.0)
-        time = QtCore.QTime()
+        time = QtCore.QTime(0, 0, 0)
         playback_length_time = time.addMSecs(rounded_vlc_ms_length)
         self.start_position_edit.setMaximumTime(playback_length_time)
         self.end_timeedit.setMaximumTime(playback_length_time)
@@ -503,7 +503,7 @@
         if self.vlc_media_player:
             vlc_ms_pos = self.vlc_media_player.get_time()
             rounded_vlc_ms_pos = int(round(vlc_ms_pos / 100.0) * 100.0)
-            time = QtCore.QTime()
+            time = QtCore.QTime(0, 0, 0)
             new_pos_time = time.addMSecs(rounded_vlc_ms_pos)
             self.position_timeedit.setTime(new_pos_time)
             self.position_slider.setSliderPosition(vlc_ms_pos)

=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py	2016-12-31 11:01:36 +0000
+++ openlp/plugins/media/lib/mediaitem.py	2017-03-17 19:22:38 +0000
@@ -267,9 +267,9 @@
             service_item.title = clip_name
             # Set the length
             self.media_controller.media_setup_optical(name, title, audio_track, subtitle_track, start, end, None, None)
-            service_item.set_media_length((end - start) / 1000)
-            service_item.start_time = start / 1000
-            service_item.end_time = end / 1000
+            service_item.set_media_length((end - start))
+            service_item.start_time = start
+            service_item.end_time = end
             service_item.add_capability(ItemCapabilities.IsOptical)
         else:
             if not os.path.exists(filename):


Follow ups