← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/futures into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/futures into lp:openlp.

    Requested reviews:
    OpenLP Core (openlp-core)


Improve the media plugin with the right supported file types
-- 
https://code.launchpad.net/~trb143/openlp/futures/+merge/20272
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py	2010-02-27 09:55:44 +0000
+++ openlp/plugins/media/lib/mediaitem.py	2010-02-27 14:59:14 +0000
@@ -61,9 +61,9 @@
 
     def retranslateUi(self):
         self.OnNewPrompt = self.trUtf8('Select Media')
-        self.OnNewFileMasks = self.trUtf8('Videos (*.avi *.mpeg *.mpg *.wmv '
-            '*.mov *.mp4 *.flv);;Audio (*.ogg *.mp3 *.wma *.wav *.flac)'
-            ';;All files (*)')
+        self.OnNewFileMasks = self.trUtf8('Videos (%s);;'
+            'Audio (%s);;'
+            'All files (*)' % (self.parent.video_list, self.parent.audio_list))
 
     def requiredIcons(self):
         MediaManagerItem.requiredIcons(self)

=== modified file 'openlp/plugins/media/mediaplugin.py'
--- openlp/plugins/media/mediaplugin.py	2010-02-27 09:55:44 +0000
+++ openlp/plugins/media/mediaplugin.py	2010-02-27 14:59:14 +0000
@@ -41,9 +41,25 @@
         # passed with drag and drop messages
         self.dnd_id = u'Media'
         self.status = PluginStatus.Active
-#        print Phonon.BackendCapabilities.availableMimeTypes()
-#        for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
-#            print mimetype
+        self.audio_list = u''
+        self.video_list = u''
+        for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
+            mimetype = unicode(mimetype)
+            type = mimetype.split(u'audio/x-')
+            self.audio_list, mimetype = self._add_to_list(self.audio_list, type, mimetype)
+            type = mimetype.split(u'audio/')
+            self.audio_list, mimetype = self._add_to_list(self.audio_list, type, mimetype)
+            type = mimetype.split(u'video/x-')
+            self.video_list, mimetype = self._add_to_list(self.video_list, type, mimetype)
+            type = mimetype.split(u'video/')
+            self.video_list, mimetype = self._add_to_list(self.video_list, type, mimetype)
+
+    def _add_to_list(self, list, value, type):
+        if len(value) == 2:
+            if list.find(value[1]) == -1:
+                list += u'*.%s ' % value[1]
+            type = u''
+        return list, type
 
     def initialise(self):
         log.info(u'Plugin Initialising')


Follow ups