Where is the piece of code that loads playlists? (1 Viewer)

MrSensitive

Portal Pro
May 18, 2004
239
0
Belgium
I'm trying to find the code in MP that loads all avaialable playlists?

i could write it myself, but I can't figure out how to read the settings to determine the plylist folder location either.. :oops: plus I'm lazy why reinvent the wheel when it obviously is already spinning like crazy :p

any help would be greatly appreciated!
:D
 

patrick

Portal Pro
April 20, 2005
608
45
Southeast
Home Country
United States of America United States of America
Is this what you are looking for?
(Both pulled from GUIMusicBaseWindow.cs

Code:
m_strPlayListPath = xmlreader.GetValueAsString("music", "playlists", String.Empty);
_autoShuffleOnLoad = xmlreader.GetValueAsBool("musicfiles", "autoshuffle", false);

Code:
        protected void LoadPlayList(string strPlayList)
        {
            IPlayListIO loader = PlayListFactory.CreateIO(strPlayList);
            if (loader == null)
                return;

            PlayList playlist = new PlayList();

            if (!loader.Load(playlist, strPlayList))
            {
                TellUserSomethingWentWrong();
                return;
            }
            if (_autoShuffleOnLoad)
            {
                Random r = new Random((int)DateTime.Now.Ticks);
                int shuffleCount = r.Next() % 50;
                for (int i = 0; i < shuffleCount; ++i)
                {
                    playlist.Shuffle();
                }
            }

            if (playlist.Count == 1)
            {
                Log.Info("GUIMusicYears:Play:{0}", playlist[0].FileName);
                g_Player.Play(playlist[0].FileName);
                return;
            }

            // clear current playlist
            playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Clear();

            Song song = new Song();
            // add each item of the playlist to the playlistplayer
            for (int i = 0; i < playlist.Count; ++i)
            {
                PlayListItem playListItem = playlist[i];
                m_database.GetSongByFileName(playListItem.FileName, ref song);
                MusicTag tag = new MusicTag();
                tag.Album = song.Album;
                tag.Artist = song.Artist;
                tag.Genre = song.Genre;
                tag.Duration = song.Duration;
                tag.Title = song.Title;
                tag.Track = song.Track;
                tag.Rating = song.Rating; 
                playListItem.MusicTag = tag;
                playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Add(playListItem);
            }


            // if we got a playlist
            if (playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Count > 0)
            {
                // then get 1st song
                playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
                PlayListItem item = playlist[0];

                // and start playing it
                playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MUSIC;
                playlistPlayer.Reset();
                playlistPlayer.Play(0);

                // and activate the playlist window if its not activated yet
                if (GetID == GUIWindowManager.ActiveWindow)
                {
                    GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_MUSIC_PLAYLIST);
                }
            }
        }


HTH,
patrick
 

Users who are viewing this thread

Top Bottom