Merge lp:~mjthompson/openlp/media_plugin into lp:openlp
- media_plugin
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~mjthompson/openlp/media_plugin |
Merge into: | lp:openlp |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~mjthompson/openlp/media_plugin |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raoul Snyman | Needs Fixing | ||
Tim Bentley | Needs Fixing | ||
Review via email:
|
This proposal has been superseded by a proposal from 2009-07-02.
Commit message
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Martin Thompson (mjthompson) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tim Bentley (trb143) wrote : | # |
Sorry but this will break the other plugins.
adding self.ServiceIte
Also is incorrect.
- service_
92 + service_
should be
This does not work for bibles as the media_image for bibles is _verses instead of _bibles.
Use of assert causes problems and rejections on a number of boxes can we have throws error instead.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Raoul Snyman (raoul-snyman) wrote : | # |
Please don't use this, it throws Eric4 out (and is incorrect Python):
assert 0, 'This fn needs to be defined by the plugin'
Rather use:
raise NotImplementedE
Rather return None, and do a check on the other side... "image is not None":
264 + except:
265 + log.info("Can't generate video preview for some reason");
266 + import sys
267 + print sys.exc_info()
268 + return QtGui.QImage()
This should be in a docstring:
43 # self.ListViewWi
44 # each plugin needs to inherit a class from this and pass that *class* (not an instance) to here
45 # via the ListViewWithDnD
46 + # self.ServiceIte
47 + # self.PreviewFun
48 + # If this fn is not defined, a default will be used (treat the filename as an image)
49 +
50 # The assumption is that given that at least two plugins are of the form
51 # "text with an icon" then all this will help
52 # even for plugins of another sort, the setup of the right-click menu, common toolbar
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Martin Thompson (mjthompson) wrote : | # |
On Wed, Jul 01, 2009 at 05:14:09AM -0000 or thereabouts, Tim Bentley wrote:
> Review: Needs Fixing
> Sorry but this will break the other plugins.
>
> adding self.ServiceIte
>
Should I add it to the other plugins then...?
> Also is incorrect.
> - service_
> 92 + service_
>
> should be
> service_
> This does not work for bibles as the media_image for bibles is _verses instead of _bibles.
which would also fix this problem.
>
> Use of assert causes problems and rejections on a number of boxes can we have throws error instead.
OK.
Cheers,
Martin
- 480. By Martin Thompson
-
Changes from review
Unmerged revisions
Preview Diff
1 | === modified file 'openlp/core/lib/listwithpreviews.py' | |||
2 | --- openlp/core/lib/listwithpreviews.py 2009-06-23 20:59:38 +0000 | |||
3 | +++ openlp/core/lib/listwithpreviews.py 2009-06-30 20:35:53 +0000 | |||
4 | @@ -35,14 +35,18 @@ | |||
5 | 35 | self.items = [] | 35 | self.items = [] |
6 | 36 | self.rowheight = 50 | 36 | self.rowheight = 50 |
7 | 37 | self.maximagewidth = self.rowheight * 16 / 9.0; | 37 | self.maximagewidth = self.rowheight * 16 / 9.0; |
12 | 38 | if new_preview_function is not None: | 38 | self.preview_function = new_preview_function |
9 | 39 | self.make_preview=new_preview_function | ||
10 | 40 | else: | ||
11 | 41 | self.make_preview=self.preview_function | ||
13 | 42 | 39 | ||
15 | 43 | def preview_function(self, filename): | 40 | def make_preview(self, filename): |
16 | 44 | if os.path.exists(filename): | 41 | if os.path.exists(filename): |
18 | 45 | preview = QtGui.QImage(filename) | 42 | if self.preview_function is not None: |
19 | 43 | preview=self.preview_function(filename) | ||
20 | 44 | else: | ||
21 | 45 | preview = QtGui.QImage(filename) | ||
22 | 46 | else: | ||
23 | 47 | preview = None | ||
24 | 48 | |||
25 | 49 | if preview is not None: | ||
26 | 46 | w = self.maximagewidth; | 50 | w = self.maximagewidth; |
27 | 47 | h = self.rowheight | 51 | h = self.rowheight |
28 | 48 | preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) | 52 | preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) |
29 | 49 | 53 | ||
30 | === modified file 'openlp/core/lib/mediamanageritem.py' | |||
31 | --- openlp/core/lib/mediamanageritem.py 2009-06-25 20:03:41 +0000 | |||
32 | +++ openlp/core/lib/mediamanageritem.py 2009-06-30 20:35:53 +0000 | |||
33 | @@ -18,7 +18,7 @@ | |||
34 | 18 | Place, Suite 330, Boston, MA 02111-1307 USA | 18 | Place, Suite 330, Boston, MA 02111-1307 USA |
35 | 19 | """ | 19 | """ |
36 | 20 | import types | 20 | import types |
38 | 21 | 21 | import os | |
39 | 22 | from PyQt4 import QtCore, QtGui | 22 | from PyQt4 import QtCore, QtGui |
40 | 23 | from openlp.core.lib.toolbar import * | 23 | from openlp.core.lib.toolbar import * |
41 | 24 | from openlp.core.lib import translate | 24 | from openlp.core.lib import translate |
42 | @@ -122,6 +122,10 @@ | |||
43 | 122 | # self.ListViewWithDnD_class - there is a base list class with DnD assigned to it (openlp.core.lib.BaseListWithDnD()) | 122 | # self.ListViewWithDnD_class - there is a base list class with DnD assigned to it (openlp.core.lib.BaseListWithDnD()) |
44 | 123 | # each plugin needs to inherit a class from this and pass that *class* (not an instance) to here | 123 | # each plugin needs to inherit a class from this and pass that *class* (not an instance) to here |
45 | 124 | # via the ListViewWithDnD_class member | 124 | # via the ListViewWithDnD_class member |
46 | 125 | # self.ServiceItemIconName - string referring to an icon file or a resource icon | ||
47 | 126 | # self.PreviewFunction - a function which returns a QImage to represent the item (a preview usually) - no scaling required - that's done later | ||
48 | 127 | # If this fn is not defined, a default will be used (treat the filename as an image) | ||
49 | 128 | |||
50 | 125 | # The assumption is that given that at least two plugins are of the form | 129 | # The assumption is that given that at least two plugins are of the form |
51 | 126 | # "text with an icon" then all this will help | 130 | # "text with an icon" then all this will help |
52 | 127 | # even for plugins of another sort, the setup of the right-click menu, common toolbar | 131 | # even for plugins of another sort, the setup of the right-click menu, common toolbar |
53 | @@ -166,7 +170,10 @@ | |||
54 | 166 | #Add the List widget | 170 | #Add the List widget |
55 | 167 | self.ListView = self.ListViewWithDnD_class() | 171 | self.ListView = self.ListViewWithDnD_class() |
56 | 168 | self.ListView.uniformItemSizes = True | 172 | self.ListView.uniformItemSizes = True |
58 | 169 | self.ListData = ListWithPreviews() | 173 | try: |
59 | 174 | self.ListData = ListWithPreviews(self.PreviewFunction) | ||
60 | 175 | except AttributeError: | ||
61 | 176 | self.ListData = ListWithPreviews(None) | ||
62 | 170 | self.ListView.setModel(self.ListData) | 177 | self.ListView.setModel(self.ListData) |
63 | 171 | self.ListView.setGeometry(QtCore.QRect(10, 100, 256, 591)) | 178 | self.ListView.setGeometry(QtCore.QRect(10, 100, 256, 591)) |
64 | 172 | self.ListView.setSpacing(1) | 179 | self.ListView.setSpacing(1) |
65 | @@ -219,25 +226,25 @@ | |||
66 | 219 | self.parent.config.set_list(self.ConfigSection, self.ListData.getFileList()) | 226 | self.parent.config.set_list(self.ConfigSection, self.ListData.getFileList()) |
67 | 220 | 227 | ||
68 | 221 | def generateSlideData(self): | 228 | def generateSlideData(self): |
70 | 222 | assert (0, 'This fn needs to be defined by the plugin'); | 229 | assert 0, 'This fn needs to be defined by the plugin' |
71 | 223 | 230 | ||
72 | 224 | def onPreviewClick(self): | 231 | def onPreviewClick(self): |
73 | 225 | log.debug(self.PluginTextShort+u'Preview Requested') | 232 | log.debug(self.PluginTextShort+u'Preview Requested') |
74 | 226 | service_item = ServiceItem(self.parent) | 233 | service_item = ServiceItem(self.parent) |
76 | 227 | service_item.addIcon(u':/media/media_image.png') | 234 | service_item.addIcon(self.ServiceItemIconName) |
77 | 228 | self.generateSlideData(service_item) | 235 | self.generateSlideData(service_item) |
78 | 229 | self.parent.preview_controller.addServiceItem(service_item) | 236 | self.parent.preview_controller.addServiceItem(service_item) |
79 | 230 | 237 | ||
80 | 231 | def onLiveClick(self): | 238 | def onLiveClick(self): |
81 | 232 | log.debug(self.PluginTextShort+u' Live Requested') | 239 | log.debug(self.PluginTextShort+u' Live Requested') |
82 | 233 | service_item = ServiceItem(self.parent) | 240 | service_item = ServiceItem(self.parent) |
84 | 234 | service_item.addIcon(u':/media/media_image.png') | 241 | service_item.addIcon(self.ServiceItemIconName) |
85 | 235 | self.generateSlideData(service_item) | 242 | self.generateSlideData(service_item) |
86 | 236 | self.parent.live_controller.addServiceItem(service_item) | 243 | self.parent.live_controller.addServiceItem(service_item) |
87 | 237 | 244 | ||
88 | 238 | def onAddClick(self): | 245 | def onAddClick(self): |
89 | 239 | log.debug(self.PluginTextShort+u' Add Requested') | 246 | log.debug(self.PluginTextShort+u' Add Requested') |
90 | 240 | service_item = ServiceItem(self.parent) | 247 | service_item = ServiceItem(self.parent) |
92 | 241 | service_item.addIcon(u':/media/media_image.png') | 248 | service_item.addIcon(self.ServiceItemIconName) |
93 | 242 | self.generateSlideData(service_item) | 249 | self.generateSlideData(service_item) |
94 | 243 | self.parent.service_manager.addServiceItem(service_item) | 250 | self.parent.service_manager.addServiceItem(service_item) |
95 | 244 | 251 | ||
96 | === modified file 'openlp/plugins/images/lib/mediaitem.py' | |||
97 | --- openlp/plugins/images/lib/mediaitem.py 2009-06-25 20:01:02 +0000 | |||
98 | +++ openlp/plugins/images/lib/mediaitem.py 2009-06-25 21:09:52 +0000 | |||
99 | @@ -49,7 +49,8 @@ | |||
100 | 49 | self.OnNewFileMasks = u'Images (*.jpg *jpeg *.gif *.png *.bmp)' | 49 | self.OnNewFileMasks = u'Images (*.jpg *jpeg *.gif *.png *.bmp)' |
101 | 50 | # this next is a class, not an instance of a class - it will | 50 | # this next is a class, not an instance of a class - it will |
102 | 51 | # be instanced by the base MediaManagerItem | 51 | # be instanced by the base MediaManagerItem |
104 | 52 | self.ListViewWithDnD_class = ImageListView | 52 | self.ListViewWithDnD_class = ImageListView |
105 | 53 | self.ServiceItemIconName = u':/media/media_image.png' | ||
106 | 53 | MediaManagerItem.__init__(self, parent, icon, title) | 54 | MediaManagerItem.__init__(self, parent, icon, title) |
107 | 54 | 55 | ||
108 | 55 | 56 | ||
109 | 56 | 57 | ||
110 | === modified file 'openlp/plugins/media/lib/mediaitem.py' | |||
111 | --- openlp/plugins/media/lib/mediaitem.py 2009-06-16 18:21:24 +0000 | |||
112 | +++ openlp/plugins/media/lib/mediaitem.py 2009-06-30 20:35:53 +0000 | |||
113 | @@ -19,13 +19,25 @@ | |||
114 | 19 | """ | 19 | """ |
115 | 20 | import logging | 20 | import logging |
116 | 21 | import os | 21 | import os |
118 | 22 | 22 | import tempfile | |
119 | 23 | try: | ||
120 | 24 | import gst | ||
121 | 25 | except: | ||
122 | 26 | log = logging.getLogger(u'MediaMediaItemSetup') | ||
123 | 27 | log.warning(u'Can\'t generate Vidoe previews - import gst failed'); | ||
124 | 28 | |||
125 | 23 | from PyQt4 import QtCore, QtGui | 29 | from PyQt4 import QtCore, QtGui |
126 | 24 | 30 | ||
127 | 25 | from openlp.core.lib import MediaManagerItem, translate | 31 | from openlp.core.lib import MediaManagerItem, translate |
128 | 26 | 32 | ||
129 | 27 | from openlp.plugins.media.lib import MediaTab | 33 | from openlp.plugins.media.lib import MediaTab |
130 | 28 | from openlp.plugins.media.lib import FileListData | 34 | from openlp.plugins.media.lib import FileListData |
131 | 35 | # from listwithpreviews import ListWithPreviews | ||
132 | 36 | from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD | ||
133 | 37 | class MediaListView(BaseListWithDnD): | ||
134 | 38 | def __init__(self, parent=None): | ||
135 | 39 | self.PluginName = u'Media' | ||
136 | 40 | BaseListWithDnD.__init__(self, parent) | ||
137 | 29 | 41 | ||
138 | 30 | class MediaMediaItem(MediaManagerItem): | 42 | class MediaMediaItem(MediaManagerItem): |
139 | 31 | """ | 43 | """ |
140 | @@ -36,100 +48,76 @@ | |||
141 | 36 | log.info(u'Media Media Item loaded') | 48 | log.info(u'Media Media Item loaded') |
142 | 37 | 49 | ||
143 | 38 | def __init__(self, parent, icon, title): | 50 | def __init__(self, parent, icon, title): |
144 | 51 | self.TranslationContext = u'MediaPlugin' | ||
145 | 52 | self.PluginTextShort = u'Media' | ||
146 | 53 | self.ConfigSection = u'images' | ||
147 | 54 | self.OnNewPrompt = u'Select Media(s)' | ||
148 | 55 | self.OnNewFileMasks = u'Videos (*.avi *.mpeg *.mpg *.mp4);;Audio (*.ogg *.mp3 *.wma);;All files (*)' | ||
149 | 56 | # this next is a class, not an instance of a class - it will | ||
150 | 57 | # be instanced by the base MediaManagerItem | ||
151 | 58 | self.ListViewWithDnD_class = MediaListView | ||
152 | 59 | self.ServiceItemIconName = u':/media/media_image.png' | ||
153 | 60 | self.PreviewFunction = self.video_get_preview | ||
154 | 39 | MediaManagerItem.__init__(self, parent, icon, title) | 61 | MediaManagerItem.__init__(self, parent, icon, title) |
155 | 40 | 62 | ||
234 | 41 | def setupUi(self): | 63 | def video_get_preview(self, filename): |
235 | 42 | # Add a toolbar | 64 | |
236 | 43 | self.addToolbar() | 65 | """Gets a preview of the first frame of a video file using |
237 | 44 | # Create buttons for the toolbar | 66 | GSTREAMER (non-portable??? - Can't figure out how to do with |
238 | 45 | ## New Media Button ## | 67 | Phonon - returns a QImage""" |
239 | 46 | self.addToolbarButton( | 68 | |
240 | 47 | translate(u'MediaMediaItem',u'New Media'), | 69 | try: |
241 | 48 | translate(u'MediaMediaItem',u'Load Media into openlp.org'), | 70 | # Define your pipeline, just as you would at the command prompt. |
242 | 49 | ':/videos/video_load.png', self.onMediaNewClick, 'MediaNewItem') | 71 | # This is much easier than trying to create and link each gstreamer element in Python. |
243 | 50 | ## Delete Media Button ## | 72 | # This is great for pipelines that end with a filesink (i.e. there is no audible or visual output) |
244 | 51 | self.addToolbarButton( | 73 | log.info ("Video preview %s"%( filename)) |
245 | 52 | translate(u'MediaMediaItem',u'Delete Media'), | 74 | outfile=tempfile.NamedTemporaryFile(suffix='.png') |
246 | 53 | translate(u'MediaMediaItem',u'Delete the selected Media item'), | 75 | cmd=u'filesrc location="%s" ! decodebin ! ffmpegcolorspace ! pngenc ! filesink location="%s"'% (filename, outfile.name) |
247 | 54 | ':/videos/video_delete.png', self.onMediaDeleteClick, 'MediaDeleteItem') | 76 | pipe = gst.parse_launch(cmd) |
248 | 55 | ## Separator Line ## | 77 | # Get a reference to the pipeline's bus |
249 | 56 | self.addToolbarSeparator() | 78 | bus = pipe.get_bus() |
250 | 57 | ## Preview Media Button ## | 79 | |
251 | 58 | self.addToolbarButton( | 80 | # Set the pipeline's state to PLAYING |
252 | 59 | translate(u'MediaMediaItem',u'Preview Media'), | 81 | pipe.set_state(gst.STATE_PLAYING) |
253 | 60 | translate(u'MediaMediaItem',u'Preview the selected Media item'), | 82 | |
254 | 61 | ':/system/system_preview.png', self.onMediaPreviewClick, 'MediaPreviewItem') | 83 | # Listen to the pipeline's bus indefinitely until we receive a EOS (end of stream) message. |
255 | 62 | ## Live Media Button ## | 84 | # This is a super important step, or the pipeline might not work as expected. For example, |
256 | 63 | self.addToolbarButton( | 85 | # in my example pipeline above, the pngenc will not export an actual image unless you have |
257 | 64 | translate(u'MediaMediaItem',u'Go Live'), | 86 | # this line of code. It just exports a 0 byte png file. So... don't forget this step. |
258 | 65 | translate(u'MediaMediaItem',u'Send the selected Media item live'), | 87 | bus.poll(gst.MESSAGE_EOS, -1) |
259 | 66 | ':/system/system_live.png', self.onMediaLiveClick, 'MediaLiveItem') | 88 | img=QtGui.QImage(outfile.name) |
260 | 67 | ## Add Media Button ## | 89 | outfile.close() |
261 | 68 | self.addToolbarButton( | 90 | # os.unlink(outfile.name) |
262 | 69 | translate(u'MediaMediaItem',u'Add Media To Service'), | 91 | pipe.set_state(gst.STATE_NULL) |
263 | 70 | translate(u'MediaMediaItem',u'Add the selected Media items(s) to the service'), | 92 | return img |
264 | 71 | ':/system/system_add.png',self.onMediaAddClick, 'MediaAddItem') | 93 | except: |
265 | 72 | ## Add the Medialist widget ## | 94 | log.info("Can't generate video preview for some reason"); |
266 | 73 | 95 | import sys | |
267 | 74 | self.MediaListView = QtGui.QListView() | 96 | print sys.exc_info() |
268 | 75 | self.MediaListView.setAlternatingRowColors(True) | 97 | return QtGui.QImage() |
269 | 76 | self.MediaListData = FileListData() | 98 | |
270 | 77 | self.MediaListView.setModel(self.MediaListData) | 99 | |
271 | 78 | 100 | def generateSlideData(self, service_item): | |
272 | 79 | self.PageLayout.addWidget(self.MediaListView) | 101 | indexes = self.ListView.selectedIndexes() |
273 | 80 | 102 | service_item.title = u'Media' | |
196 | 81 | #define and add the context menu | ||
197 | 82 | self.MediaListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) | ||
198 | 83 | |||
199 | 84 | self.MediaListView.addAction(self.contextMenuAction( | ||
200 | 85 | self.MediaListView, ':/system/system_preview.png', | ||
201 | 86 | translate(u'MediaMediaItem',u'&Preview Media'), self.onMediaPreviewClick)) | ||
202 | 87 | self.MediaListView.addAction(self.contextMenuAction( | ||
203 | 88 | self.MediaListView, ':/system/system_live.png', | ||
204 | 89 | translate(u'MediaMediaItem',u'&Show Live'), self.onMediaLiveClick)) | ||
205 | 90 | self.MediaListView.addAction(self.contextMenuAction( | ||
206 | 91 | self.MediaListView, ':/system/system_add.png', | ||
207 | 92 | translate(u'MediaMediaItem',u'&Add to Service'), self.onMediaAddClick)) | ||
208 | 93 | |||
209 | 94 | def initialise(self): | ||
210 | 95 | list = self.parent.config.load_list(u'Media') | ||
211 | 96 | self.loadMediaList(list) | ||
212 | 97 | |||
213 | 98 | def onMediaNewClick(self): | ||
214 | 99 | files = QtGui.QFileDialog.getOpenFileNames(None, | ||
215 | 100 | translate(u'MediaMediaItem', u'Select Media(s) items'), | ||
216 | 101 | self.parent.config.get_last_dir(), | ||
217 | 102 | u'Videos (*.avi *.mpeg);;Audio (*.mp3 *.ogg *.wma);;All files (*)') | ||
218 | 103 | if len(files) > 0: | ||
219 | 104 | self.loadMediaList(files) | ||
220 | 105 | dir, filename = os.path.split(unicode(files[0])) | ||
221 | 106 | self.parent.config.set_last_dir(dir) | ||
222 | 107 | self.parent.config.set_list(u'media', self.MediaListData.getFileList()) | ||
223 | 108 | |||
224 | 109 | def getFileList(self): | ||
225 | 110 | filelist = [item[0] for item in self.MediaListView]; | ||
226 | 111 | return filelist | ||
227 | 112 | |||
228 | 113 | def loadMediaList(self, list): | ||
229 | 114 | for files in list: | ||
230 | 115 | self.MediaListData.addRow(files) | ||
231 | 116 | |||
232 | 117 | def onMediaDeleteClick(self): | ||
233 | 118 | indexes = self.MediaListView.selectedIndexes() | ||
274 | 119 | for index in indexes: | 103 | for index in indexes: |
280 | 120 | current_row = int(index.row()) | 104 | filename = self.ListData.getFilename(index) |
281 | 121 | self.MediaListData.removeRow(current_row) | 105 | frame = QtGui.QImage(unicode(filename)) |
282 | 122 | self.parent.config.set_list(u'media', self.MediaListData.getFileList()) | 106 | (path, name) = os.path.split(filename) |
283 | 123 | 107 | service_item.add_from_image(path, name, frame) | |
284 | 124 | def onMediaPreviewClick(self): | 108 | |
285 | 109 | |||
286 | 110 | def onPreviewClick(self): | ||
287 | 125 | log.debug(u'Media Preview Button pressed') | 111 | log.debug(u'Media Preview Button pressed') |
289 | 126 | items = self.MediaListView.selectedIndexes() | 112 | items = self.ListView.selectedIndexes() |
290 | 127 | for item in items: | 113 | for item in items: |
292 | 128 | text = self.MediaListData.getValue(item) | 114 | text = self.ListData.getValue(item) |
293 | 129 | print text | 115 | print text |
294 | 130 | 116 | ||
295 | 131 | def onMediaLiveClick(self): | 117 | def onMediaLiveClick(self): |
296 | 118 | log.debug(u'Media Live Button pressed') | ||
297 | 132 | pass | 119 | pass |
298 | 133 | 120 | ||
299 | 134 | def onMediaAddClick(self): | ||
300 | 135 | pass | ||
301 | 136 | \ No newline at end of file | 121 | \ No newline at end of file |
302 | 122 | # def onMediaAddClick(self): | ||
303 | 123 | # log.debug(u'Media Add Button pressed') | ||
304 | 124 | # pass | ||
305 | 137 | 125 | ||
306 | === modified file 'openlp/plugins/media/mediaplugin.py' | |||
307 | --- openlp/plugins/media/mediaplugin.py 2009-06-16 18:21:24 +0000 | |||
308 | +++ openlp/plugins/media/mediaplugin.py 2009-06-30 20:35:53 +0000 | |||
309 | @@ -22,7 +22,7 @@ | |||
310 | 22 | 22 | ||
311 | 23 | from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab | 23 | from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab |
312 | 24 | from openlp.plugins.media.lib import MediaTab,MediaMediaItem | 24 | from openlp.plugins.media.lib import MediaTab,MediaMediaItem |
314 | 25 | 25 | from video_preview import video_get_preview | |
315 | 26 | class MediaPlugin(Plugin): | 26 | class MediaPlugin(Plugin): |
316 | 27 | 27 | ||
317 | 28 | def __init__(self, plugin_helpers): | 28 | def __init__(self, plugin_helpers): |
318 | 29 | 29 | ||
319 | === removed file 'openlp/plugins/media/video_render.py' | |||
320 | --- openlp/plugins/media/video_render.py 2009-06-22 20:44:35 +0000 | |||
321 | +++ openlp/plugins/media/video_render.py 1970-01-01 00:00:00 +0000 | |||
322 | @@ -1,70 +0,0 @@ | |||
323 | 1 | # -*- coding: utf-8 -*- | ||
324 | 2 | # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 | ||
325 | 3 | """ | ||
326 | 4 | OpenLP - Open Source Lyrics Projection | ||
327 | 5 | Copyright (c) 2008 Raoul Snyman | ||
328 | 6 | Portions copyright (c) 2008 Martin Thompson, Tim Bentley, | ||
329 | 7 | |||
330 | 8 | This program is free software; you can redistribute it and/or modify it under | ||
331 | 9 | the terms of the GNU General Public License as published by the Free Software | ||
332 | 10 | Foundation; version 2 of the License. | ||
333 | 11 | |||
334 | 12 | This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
335 | 13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
336 | 14 | PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
337 | 15 | |||
338 | 16 | You should have received a copy of the GNU General Public License along with | ||
339 | 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
340 | 18 | Place, Suite 330, Boston, MA 02111-1307 USA | ||
341 | 19 | """ | ||
342 | 20 | import os | ||
343 | 21 | from PyQt4 import QtCore, QtGui | ||
344 | 22 | |||
345 | 23 | # xxx this needs a try, except once we've decided what to do if it fails | ||
346 | 24 | from PyQt4.phonon import Phonon | ||
347 | 25 | |||
348 | 26 | # from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab | ||
349 | 27 | # from openlp.plugins.media.lib import MediaTab,MediaMediaItem | ||
350 | 28 | |||
351 | 29 | """Renders a video to some surface or other """ | ||
352 | 30 | |||
353 | 31 | class w(QtGui.QMainWindow): | ||
354 | 32 | def __init__(self, parent=None): | ||
355 | 33 | super(QtGui.QMainWindow, self).__init__(parent) | ||
356 | 34 | self.resize(640,480) | ||
357 | 35 | self.setWindowTitle(u'simple media player') | ||
358 | 36 | self.show() | ||
359 | 37 | |||
360 | 38 | if __name__==u'__main__': | ||
361 | 39 | app = QtGui.QApplication([]) | ||
362 | 40 | # widget = QtGui.QWidget() | ||
363 | 41 | # widget.resize(320, 240) | ||
364 | 42 | # widget.setWindowTitle(u'simple') | ||
365 | 43 | # widget.show() | ||
366 | 44 | # QCore.QCoreApplication.setApplicationName(u'OpenLP') | ||
367 | 45 | mainwindow=w() | ||
368 | 46 | widget=QtGui.QWidget(mainwindow) | ||
369 | 47 | mainwindow.setCentralWidget(widget) | ||
370 | 48 | widget.setLayout(QtGui.QVBoxLayout(widget)) | ||
371 | 49 | # videofile=u'r-128.rm' | ||
372 | 50 | videofile=u'/extra_space/Download/coa360download56Kbps240x160.mpg' | ||
373 | 51 | source=Phonon.MediaSource(videofile) | ||
374 | 52 | |||
375 | 53 | media=Phonon.MediaObject(widget) | ||
376 | 54 | media.setCurrentSource(source) | ||
377 | 55 | |||
378 | 56 | video=Phonon.VideoWidget(widget) | ||
379 | 57 | audio=Phonon.AudioOutput(Phonon.MusicCategory) | ||
380 | 58 | # controller=Phonon.MediaController(media) | ||
381 | 59 | Phonon.createPath(media, video); | ||
382 | 60 | Phonon.createPath(media, audio); | ||
383 | 61 | # player=Phonon.VideoPlayer(Phonon.VideoCategory, widget) | ||
384 | 62 | slider=Phonon.SeekSlider(media, mainwindow) | ||
385 | 63 | widget.layout().addWidget(slider) | ||
386 | 64 | widget.layout().addWidget(video) | ||
387 | 65 | slider.show() | ||
388 | 66 | |||
389 | 67 | video.show() | ||
390 | 68 | media.play() | ||
391 | 69 | app.exec_() | ||
392 | 70 |
Previews for video items - uses gstreamer as I can;t find a way to make Phonon do it. This may be unportable? But gets us through until Phonon gets the functionality.
No previews for audio files yet