home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Where is the piece of code that loads playlists?
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="patrick" data-source="post: 80164" data-attributes="member: 12502"><p>Is this what you are looking for? </p><p>(Both pulled from GUIMusicBaseWindow.cs</p><p></p><p>[CODE]</p><p>m_strPlayListPath = xmlreader.GetValueAsString("music", "playlists", String.Empty);</p><p>_autoShuffleOnLoad = xmlreader.GetValueAsBool("musicfiles", "autoshuffle", false);</p><p>[/CODE]</p><p></p><p>[CODE]</p><p> protected void LoadPlayList(string strPlayList)</p><p> {</p><p> IPlayListIO loader = PlayListFactory.CreateIO(strPlayList);</p><p> if (loader == null)</p><p> return;</p><p></p><p> PlayList playlist = new PlayList();</p><p></p><p> if (!loader.Load(playlist, strPlayList))</p><p> {</p><p> TellUserSomethingWentWrong();</p><p> return;</p><p> }</p><p> if (_autoShuffleOnLoad)</p><p> {</p><p> Random r = new Random((int)DateTime.Now.Ticks);</p><p> int shuffleCount = r.Next() % 50;</p><p> for (int i = 0; i < shuffleCount; ++i)</p><p> {</p><p> playlist.Shuffle();</p><p> }</p><p> }</p><p></p><p> if (playlist.Count == 1)</p><p> {</p><p> Log.Info("GUIMusicYears:Play:{0}", playlist[0].FileName);</p><p> g_Player.Play(playlist[0].FileName);</p><p> return;</p><p> }</p><p></p><p> // clear current playlist</p><p> playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Clear();</p><p></p><p> Song song = new Song();</p><p> // add each item of the playlist to the playlistplayer</p><p> for (int i = 0; i < playlist.Count; ++i)</p><p> {</p><p> PlayListItem playListItem = playlist[i];</p><p> m_database.GetSongByFileName(playListItem.FileName, ref song);</p><p> MusicTag tag = new MusicTag();</p><p> tag.Album = song.Album;</p><p> tag.Artist = song.Artist;</p><p> tag.Genre = song.Genre;</p><p> tag.Duration = song.Duration;</p><p> tag.Title = song.Title;</p><p> tag.Track = song.Track;</p><p> tag.Rating = song.Rating; </p><p> playListItem.MusicTag = tag;</p><p> playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Add(playListItem);</p><p> }</p><p></p><p></p><p> // if we got a playlist</p><p> if (playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Count > 0)</p><p> {</p><p> // then get 1st song</p><p> playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC);</p><p> PlayListItem item = playlist[0];</p><p></p><p> // and start playing it</p><p> playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MUSIC;</p><p> playlistPlayer.Reset();</p><p> playlistPlayer.Play(0);</p><p></p><p> // and activate the playlist window if its not activated yet</p><p> if (GetID == GUIWindowManager.ActiveWindow)</p><p> {</p><p> GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_MUSIC_PLAYLIST);</p><p> }</p><p> }</p><p> }</p><p>[/CODE]</p><p></p><p></p><p>HTH,</p><p>patrick</p></blockquote><p></p>
[QUOTE="patrick, post: 80164, member: 12502"] 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] [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); } } } [/CODE] HTH, patrick [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Where is the piece of code that loads playlists?
Contact us
RSS
Top
Bottom