def shuffle_by(playlist, field)
            pl = playlist.entries.wait.value
            artists = Hash.new
            rnd = Random.new
            playlist.clear.wait
            field = field.to_sym
            pl.each do |id|
                infos = self.medialib_get_info(id).wait.value
                a = infos[field].first[1]
                if artists.has_key?(a)
                    artists[a].insert(0,id)
                else
                    artists[a] = [id]
                end
            end

            artist_names = artists.keys
            for _ in pl
                artist_idx = (rnd.rand * artist_names.length).to_i
                artist = artist_names[artist_idx]
                songs = artists[artist]
                song_idx = rnd.rand * songs.length
                song = songs[song_idx]
                playlist.add_entry(song).wait
                songs.delete(song)
                if songs.empty?
                    artists.delete(artist)
                    artist_names.delete(artist)
                end
            end
        end
def shuffle_by(playlist, field)
            pl = playlist.entries.wait.value
            artists = Hash.new
            rnd = Random.new
            playlist.clear.wait
            field = field.to_sym
            pl.each do |id|
                infos = self.medialib_get_info(id).wait.value
                a = infos[field].first[1]
                if artists.has_key?(a)
                    artists[a].insert(0,id)
                else
                    artists[a] = [id]
                end
            end

            artist_names = artists.keys
            for _ in pl
                artist_idx = (rnd.rand * artist_names.length).to_i
                artist = artist_names[artist_idx]
                songs = artists[artist]
                song_idx = rnd.rand * songs.length
                song = songs[song_idx]
                playlist.add_entry(song).wait
                songs.delete(song)
                if songs.empty?
                    artists.delete(artist)
                    artist_names.delete(artist)
                end
            end
        end
Shuffles the playlist by selecting randomly among the tracks as
 grouped by the given field

 shuffle_by is intended to change between different
 artists/albums/genres more frequently than if all tracks were
 shuffled based on a uniform distribution. In particular, it works
 well at preventing one very large group of songs (like A. R.
 Rahman's full discography) from dominating your playlist, but
 leaves many such entries at the end of the playlist.