Example #1
0
 def render(self, view_manager):
     if self.__loader.is_loaded():
         session = view_manager.get_var('session')
         pm = view_manager.get_var('playlist_manager')
         list_obj = self.get_list(view_manager)
         sm = SettingsManager()
         
         #Set the thumbnails
         self._set_playlist_image(view_manager, self.__loader.get_thumbnails())
         
         #And the properties
         self._set_playlist_properties(view_manager)
         
         #Clear the list
         list_obj.reset()
         
         #Draw the items on the list
         for list_index, track_obj in enumerate(self.__loader.get_tracks()):
             show_track = (
                 track_obj.is_loaded() and
                 track_obj.error() == 0 and
                 (
                     track_obj.get_availability(session) == track.TrackAvailability.Available or
                     not sm.get_audio_hide_unplayable()
                 )
             )
             
             if show_track:
                 url, info = pm.create_track_info(track_obj, session, list_index)
                 list_obj.addItem(info)
         
         return True
Example #2
0
 def _handle_list_click(self, view_manager):
     item = self.get_list(view_manager).getSelectedItem()
     
     if item is not None:
         key = item.getLabel2()
         
         if key == 'settings':
             session = view_manager.get_var('session')
             settings_obj = SettingsManager()
             settings_obj.show_dialog(session)
         
         elif key == 'sign-off':
             self._do_logout(view_manager)
Example #3
0
    def _do_settings(self, view_manager):
        settings = SettingsManager()
        session = view_manager.get_var('session')

        #Store current values before they change
        before_cache_status = settings.get_cache_status()
        before_cache_management = settings.get_cache_management()
        before_cache_size = settings.get_cache_size()
        before_audio_normalize = settings.get_audio_normalize()
        before_audio_quality = settings.get_audio_quality()

        #Show the dialog
        settings.show_dialog()

        after_cache_status = settings.get_cache_status()
        after_cache_management = self.get_cache_management()
        after_cache_size = settings.get_cache_size()
        after_audio_normalize = settings.get_audio_normalize()
        after_audio_quality = settings.get_audio_quality()

        #Change these only if cache was and is enabled
        if before_cache_status and after_cache_status:

            #If cache management changed
            if before_cache_management != after_cache_management:
                if after_cache_management == CacheManagement.Automatic:
                    session.set_cache_size(0)
                elif after_cache_management == CacheManagement.Manual:
                    session.set_cache_size(after_cache_size * 1024)

            #If manual size changed
            if (after_cache_management == CacheManagement.Manual and
                    before_cache_size != after_cache_size):
                session.set_cache_size(after_cache_size * 1024)

        #Change volume normalization
        if before_audio_normalize != after_audio_normalize:
            session.set_volume_normalization(after_audio_normalize)

        #Change stream quality
        #FIXME: Repeated code, should be moved to utils
        br_map = {
            StreamQuality.Low: Bitrate.Rate96k,
            StreamQuality.Medium: Bitrate.Rate160k,
            StreamQuality.High: Bitrate.Rate320k,
        }
        if before_audio_quality != after_audio_quality:
            session.preferred_bitrate(br_map[after_audio_quality])