Merge lp:~meths/openlp/trivialfixes into lp:openlp

Proposed by Jon Tibble
Status: Merged
Merged at revision: not available
Proposed branch: lp:~meths/openlp/trivialfixes
Merge into: lp:openlp
Diff against target: None lines
To merge this branch: bzr merge lp:~meths/openlp/trivialfixes
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tim Bentley Approve
Review via email: mp+11830@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote :

Approved

review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve
lp:~meths/openlp/trivialfixes updated
544. By Jon Tibble

Merged in lp:~meths/openlp/trivialfixes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py 2009-09-14 22:10:08 +0000
+++ openlp/plugins/media/lib/mediaitem.py 2009-09-15 21:59:20 +0000
@@ -25,12 +25,6 @@
25import logging25import logging
26import os26import os
27import tempfile27import tempfile
28try:
29 import gst
30except:
31 NOGST = True
32 log = logging.getLogger(u'MediaMediaItemSetup')
33 log.warning(u'Can\'t generate Videos previews - import gst failed');
3428
35from PyQt4 import QtCore, QtGui29from PyQt4 import QtCore, QtGui
3630
@@ -70,54 +64,17 @@
70 MediaManagerItem.__init__(self, parent, icon, title)64 MediaManagerItem.__init__(self, parent, icon, title)
7165
72 def video_get_preview(self, filename):66 def video_get_preview(self, filename):
73 if NOGST:67 #
74 #68 # For now cross platform is an icon. Phonon does not support
75 # For now cross platform is an icon. Phonon does not support69 # individual frame access (yet?) and GStreamer is not available
76 # individual frame access (yet?) and GStreamer is not available70 # on Windows
77 # on Windows71 #
78 #72 image = QtGui.QPixmap(u':/media/media_video.png').toImage()
79 image = QtGui.QPixmap(u':/media/media_video.png').toImage()73 return image
80 return image
81 else:
82 """
83 Gets a preview of the first frame of a video file using GSTREAMER
84 (non-portable) - returns a QImage
85 """
86 try:
87 # Define your pipeline, just as you would at the command
88 # prompt. This is much easier than trying to create and link
89 # each gstreamer element in Python. This is great for
90 # pipelines that end with a filesink (i.e. there is no audible
91 # or visual output)
92 log.info ("Video preview %s"%( filename))
93 outfile = tempfile.NamedTemporaryFile(suffix='.png')
94 cmd = u'filesrc location="%s" ! decodebin ! ffmpegcolorspace ! pngenc ! filesink location="%s"'% (filename, outfile.name)
95 pipe = gst.parse_launch(cmd)
96 # Get a reference to the pipeline's bus
97 bus = pipe.get_bus()
98
99 # Set the pipeline's state to PLAYING
100 pipe.set_state(gst.STATE_PLAYING)
101
102 # Listen to the pipeline's bus indefinitely until we receive a
103 # EOS (end of stream) message. This is a super important step,
104 # or the pipeline might not work as expected. For example, in
105 # my example pipeline above, the pngenc will not export an
106 # actual image unless you have this line of code. It just
107 # exports a 0 byte png file. So... don't forget this step.
108 bus.poll(gst.MESSAGE_EOS, -1)
109 img = QtGui.QImage(outfile.name)
110 outfile.close()
111# os.unlink(outfile.name)
112 pipe.set_state(gst.STATE_NULL)
113 return img
114 except:
115 log.info("Can't generate video preview for some reason");
116 return None
11774
118 def generateSlideData(self, service_item):75 def generateSlideData(self, service_item):
119 indexes = self.ListView.selectedIndexes()76 indexes = self.ListView.selectedIndexes()
120 if len(items) > 1:77 if len(indexes) > 1:
121 return False78 return False
122 service_item.title = u'Media'79 service_item.title = u'Media'
123 for index in indexes:80 for index in indexes:
@@ -151,7 +108,7 @@
151 row = self.ListView.row(item)108 row = self.ListView.row(item)
152 self.ListView.takeItem(row)109 self.ListView.takeItem(row)
153 self.parent.config.set_list(110 self.parent.config.set_list(
154 self.ConfigSection, self.ListData.getFileList())111 self.ConfigSection, self.getFileList())
155112
156 def loadList(self, list):113 def loadList(self, list):
157 for file in list:114 for file in list: