예제 #1
0
    def test_generate_extensions_lists(self):
        """
        Test that the extensions are create correctly
        """
        # GIVEN: A MediaController and an active player with audio and video extensions
        media_controller = MediaController()
        media_player = MediaPlayer(None)
        media_player.is_active = True
        media_player.audio_extensions_list = [
            '*.mp3', '*.wav', '*.wma', '*.ogg'
        ]
        media_player.video_extensions_list = [
            '*.mp4', '*.mov', '*.avi', '*.ogm'
        ]
        media_controller.register_players(media_player)

        # WHEN: calling _generate_extensions_lists
        media_controller._generate_extensions_lists()

        # THEN: extensions list should have been copied from the player to the mediacontroller
        self.assertListEqual(media_player.video_extensions_list,
                             media_controller.video_extensions_list,
                             'Video extensions should be the same')
        self.assertListEqual(media_player.audio_extensions_list,
                             media_controller.audio_extensions_list,
                             'Audio extensions should be the same')
예제 #2
0
 def __init__(self, parent):
     """
     Constructor
     """
     MediaPlayer.__init__(self, parent, u'vlc')
     self.original_name = u'VLC'
     self.display_name = u'&VLC'
     self.parent = parent
     self.canFolder = True
     self.audio_extensions_list = AUDIO_EXT
     self.video_extensions_list = VIDEO_EXT
예제 #3
0
 def __init__(self, parent):
     """
     Constructor
     """
     MediaPlayer.__init__(self, parent, u'phonon')
     self.original_name = u'Phonon'
     self.display_name = u'&Phonon'
     self.parent = parent
     self.additional_extensions = ADDITIONAL_EXT
     mimetypes.init()
     for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
         mimetype = unicode(mimetype)
         if mimetype.startswith(u'audio/'):
             self._addToList(self.audio_extensions_list, mimetype)
         elif mimetype.startswith(u'video/'):
             self._addToList(self.video_extensions_list, mimetype)
예제 #4
0
 def bootstrap_initialise(self):
     """
     Check to see if we have any media Player's available.
     """
     log.debug('_check_available_media_players')
     controller_dir = os.path.join(AppLocation.get_directory(AppLocation.AppDir), 'core', 'ui', 'media')
     for filename in os.listdir(controller_dir):
         if filename.endswith('player.py') and not filename == 'mediaplayer.py':
             path = os.path.join(controller_dir, filename)
             if os.path.isfile(path):
                 module_name = 'openlp.core.ui.media.' + os.path.splitext(filename)[0]
                 log.debug('Importing controller %s', module_name)
                 try:
                     __import__(module_name, globals(), locals(), [])
                 # On some platforms importing vlc.py might cause
                 # also OSError exceptions. (e.g. Mac OS X)
                 except (ImportError, OSError):
                     log.warning('Failed to import %s on path %s', module_name, path)
     player_classes = MediaPlayer.__subclasses__()
     for player_class in player_classes:
         player = player_class(self)
         self.register_players(player)
     if not self.media_players:
         return False
     saved_players, overridden_player = get_media_players()
     invalid_media_players = \
         [media_player for media_player in saved_players if media_player not in self.media_players or
             not self.media_players[media_player].check_available()]
     if invalid_media_players:
         for invalidPlayer in invalid_media_players:
             saved_players.remove(invalidPlayer)
         set_media_players(saved_players, overridden_player)
     self._set_active_players()
     self._generate_extensions_lists()
     return True
예제 #5
0
    def generate_extensions_lists_test(self):
        """
        Test that the extensions are create correctly
        """
        # GIVEN: A MediaController and an active player with audio and video extensions
        media_controller = MediaController()
        media_player = MediaPlayer(None)
        media_player.is_active = True
        media_player.audio_extensions_list = ['*.mp3', '*.wav', '*.wma', '*.ogg']
        media_player.video_extensions_list = ['*.mp4', '*.mov', '*.avi', '*.ogm']
        media_controller.register_players(media_player)

        # WHEN: calling _generate_extensions_lists
        media_controller._generate_extensions_lists()

        # THEN: extensions list should have been copied from the player to the mediacontroller
        self.assertListEqual(media_player.video_extensions_list, media_controller.video_extensions_list,
                             'Video extensions should be the same')
        self.assertListEqual(media_player.audio_extensions_list, media_controller.audio_extensions_list,
                             'Audio extensions should be the same')
예제 #6
0
 def bootstrap_initialise(self):
     """
     Check to see if we have any media Player's available.
     """
     log.debug('_check_available_media_players')
     controller_dir = os.path.join(
         AppLocation.get_directory(AppLocation.AppDir), 'core', 'ui',
         'media')
     for filename in os.listdir(controller_dir):
         if filename.endswith(
                 'player.py') and not filename == 'mediaplayer.py':
             path = os.path.join(controller_dir, filename)
             if os.path.isfile(path):
                 module_name = 'openlp.core.ui.media.' + os.path.splitext(
                     filename)[0]
                 log.debug('Importing controller %s', module_name)
                 try:
                     __import__(module_name, globals(), locals(), [])
                 # On some platforms importing vlc.py might cause
                 # also OSError exceptions. (e.g. Mac OS X)
                 except (ImportError, OSError):
                     log.warning('Failed to import %s on path %s',
                                 module_name, path)
     player_classes = MediaPlayer.__subclasses__()
     for player_class in player_classes:
         player = player_class(self)
         self.register_players(player)
     if not self.media_players:
         return False
     saved_players, overridden_player = get_media_players()
     invalid_media_players = \
         [media_player for media_player in saved_players if media_player not in self.media_players or
             not self.media_players[media_player].check_available()]
     if invalid_media_players:
         for invalidPlayer in invalid_media_players:
             saved_players.remove(invalidPlayer)
         set_media_players(saved_players, overridden_player)
     self._set_active_players()
     self._generate_extensions_lists()
     return True
예제 #7
0
 def bootstrap_initialise(self):
     """
     Check to see if we have any media Player's available.
     """
     controller_dir = os.path.join('core', 'ui', 'media')
     # Find all files that do not begin with '.' (lp:#1738047) and end with player.py
     glob_pattern = os.path.join(controller_dir, '[!.]*player.py')
     extension_loader(glob_pattern, ['mediaplayer.py'])
     player_classes = MediaPlayer.__subclasses__()
     for player_class in player_classes:
         self.register_players(player_class(self))
     if not self.media_players:
         return False
     saved_players, overridden_player = get_media_players()
     invalid_media_players = \
         [media_player for media_player in saved_players if media_player not in self.media_players or
             not self.media_players[media_player].check_available()]
     if invalid_media_players:
         for invalidPlayer in invalid_media_players:
             saved_players.remove(invalidPlayer)
         set_media_players(saved_players, overridden_player)
     self._set_active_players()
     self._generate_extensions_lists()
     return True