Beispiel #1
0
        private List <String> GetPlaylistsUnlocked(PlaylistContainer pc)
        {
            _session.FlushCaches();
            List <String> playlists = new List <String>();

            playlists.Add(FavoriteName);
            for (int i = 0; i < pc.NumPlaylists(); i++)
            {
                if (!pc.Playlist(i).Name().Equals(String.Empty))
                {
                    playlists.Add(pc.Playlist(i).Name());
                }
            }
            return(playlists);
        }
Beispiel #2
0
        private bool TryStartPlaylistUnlocked(String playlistName, bool random)
        {
            PlaylistContainer pc = GetPlaylistContainer();

            _currentlyPlayingPlaylist = null;
            if (pc == null)
            {
                return(false);
            }
            if (playlistName.Equals(FavoriteName))
            {
                lock (_session)
                {
                    _currentlyPlayingPlaylist = _session.StarredCreate();
                }
            }
            else
            {
                for (int i = 0; i < pc.NumPlaylists(); i++)
                {
                    Playlist list = pc.Playlist(i);
                    if (list.Name().Equals(playlistName))
                    {
                        _currentlyPlayingPlaylist = list;
                        break;
                    }
                }
            }
            if (_currentlyPlayingPlaylist == null)
            {
                return(false);
            }
            _playingOrder = Enumerable.Range(0, _currentlyPlayingPlaylist.NumTracks()).ToList();
            if (random)
            {
                List <int> straightPlayingOrder = _playingOrder.ToList();
                Random     rndGen = new Random();
                _playingOrder.Clear();
                while (straightPlayingOrder.Any())
                {
                    int index = rndGen.Next(straightPlayingOrder.Count);
                    _playingOrder.Add(straightPlayingOrder[index]);
                    straightPlayingOrder.RemoveAt(index);
                }
            }
            _currentTrackNum = 0;

            ResumeUnlocked();
            return(true);
        }