| |||||||
| Plugins Plugins developed and maintained by users. Want to create your own plugin? Start a thread in here. |
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Portal Member Join Date: Apr 2008
Posts: 26
Thanks: 2
Thanked 1 Time in 1 Post
Country: | it has come to my attention that using Code: MediaPortal.Player.g_Player.Play(whatever.mp3, MediaPortal.Player.g_Player.MediaType.Music) and it plays music perfectly, but with one major problem. when i say put playlist.wpl instead of the .mp3 file above. the playlist plays, but MP plays it as a single file, so the song list does not appear in "current playlist" and i cannot go "next track" any ideas? |
| | |
| | #2 (permalink) |
| Portal Developer Join Date: Mar 2005 Location: Melbourne Age: 27
Posts: 2,248
Thanks: 30
Thanked 140 Times in 88 Posts
Country: | What happens if you don't specify the MediaType?
__________________ - Aaron. IR Server Suite - Version 1.0.4.1 MCE Replacement Plugin - Version 1.0.4.1 You don't need the MCE Replacement Driver |
| | |
| | #4 (permalink) |
| Portal Developer Join Date: Mar 2005 Location: Melbourne Age: 27
Posts: 2,248
Thanks: 30
Thanked 140 Times in 88 Posts
Country: | hmm, I'll look into it further and get back to you ... in the meantime, check out the mediaportal source code and see how it's done there.
__________________ - Aaron. IR Server Suite - Version 1.0.4.1 MCE Replacement Plugin - Version 1.0.4.1 You don't need the MCE Replacement Driver |
| | |
| This User Say Thank You: |
| | #5 (permalink) |
| Portal Member Join Date: Aug 2006 Location: Kentucky Age: 23
Posts: 700
Thanks: 125
Thanked 90 Times in 49 Posts
Country: | I think that for playing a playlist you have to use the PlaylistPlayer Class in the Mediaportal.Playlists namespace. I've never actually used it, I just remember seeing it. |
| | |
| | #6 (permalink) |
| Portal Member Join Date: Apr 2008
Posts: 26
Thanks: 2
Thanked 1 Time in 1 Post
Country: | I looked around the class, cant find anything that works, i tried: MediaPortal.Playlists.PlayListPlayer.SingletonPlay er.g_Player.Play(FileToPlay.Trim()); but that gave me the exact same result as before btw i tried the following: went to music folder added an album to playlist it was playing under current playlist and now playing perfectly and i can click next and that works i treid "save" typed a name and pressed "done" then i clicked "MY Playlists" MP hangs for about 4 seconds then just resumes operation in current screen.. does not go to "My Playlists" i tried searching with windows search for the playlist i entered..and i didnt find it. any ideas? Last edited by hbe02; 2008-04-07 at 23:11. Reason: Automerged Doublepost |
| | |
| | #7 (permalink) |
| Portal Member | Here is how I play a playlist: Code: using MediaPortal.Playlists;
public void PlayPlaylist(string playlistName)
{
PlayListPlayer playlistPlayer = PlayListPlayer.SingletonPlayer;
playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
string strPlayListPath = string.Empty;
using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
{
strPlayListPath = xmlreader.GetValueAsString("music", "playlists", string.Empty);
strPlayListPath = MediaPortal.Util.Utils.RemoveTrailingSlash(strPlayListPath);
}
string playlistFileName = Path.Combine(strPlayListPath, playlistName);
PlayList tempPlaylist = GetPlaylistByPath(playlistFileName);
if (!File.Exists(playlistFileName) && tempPlaylist != null)
return;
playlist.Clear();
playlist.Name = tempPlaylist.Name;
foreach (PlayListItem item in tempPlaylist)
{
playlist.Add(item);
}
if (playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Count > 0)
{
playlistPlayer.Reset();
playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MUSIC;
playlistPlayer.Play(0);
}
}
private PlayList GetPlaylistByPath(string path)
{
IPlayListIO io;
string ext = System.IO.Path.GetExtension(path);
PlayList playlist = new PlayList();
switch (ext.ToLower())
{
case ".m3u":
io = new PlayListM3uIO();
break;
case ".pls":
io = new PlayListM3uIO();
break;
case ".b4s":
io = new PlayListM3uIO();
break;
case ".wpl":
io = new PlayListM3uIO();
break;
default:
return playlist;
}
if (io.Load(playlist, path))
return playlist;
else
return null;
}
Darick If you are calling the above from a thread other than the main, then you may need to invoke it to run on the main thread, otherwise it could cause an error. Code:
private delegate void PlayPlaylistHandler(string playlistName);
public void SomeMethod()
{
string someplaylist = "someplaylist";
System.Windows.Forms.Control currentform = System.Windows.Forms.Form.FromHandle(GUIGraphicsContext.ActiveForm);
if (currentform.InvokeRequired)
{
PlayPlaylistHandler handler = new PlayPlaylistHandler(PlayPlaylist);
currentform.Invoke(handler, new object[] {someplaylist });
}
else
{
PlayPlaylist(someplaylist);
}
Darick Last edited by darick_c; 2008-07-30 at 03:22. Reason: Automerged Doublepost |
| | |
| | #8 (permalink) |
| Portal Member | I have just been struggling with the same thing. I tried your code, Darick, but MP only plays the first file in the m3u playlist. When I open "current playlist" it is empty, and when I go to "now playing" there is no "next track" waiting. I want to be able to load an m3u playlist in code, and then skip back and forth between its tracks. Does this work with the code you posted? If so, I must be doing something wrong... ![]() |
| | |
| | #9 (permalink) |
| Portal Member Join Date: Aug 2006 Location: Kentucky Age: 23
Posts: 700
Thanks: 125
Thanked 90 Times in 49 Posts
Country: | Fjoms, here's another method that may work for you: Loading Current playlist, then Playing it |
| | |
| This User Say Thank You: |
![]() |
| Bookmarks |
| Tags |
| playlist code |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Playlist error from Syntax M3U playlist file | Luccio | Support | 9 | Yesterday 23:38 |
| 'My Playlist', a better 'play all/random' | fredklein | Improvement Suggestions | 0 | 2008-03-06 03:30 |
| play radio and fav. playlist with one keystroke | xpeet | Newcomers Forum | 0 | 2007-11-29 22:18 |
| Display playlist name in Playlist view? | Doodles | Listen Music | 0 | 2007-10-19 19:29 |
| MyMusic: MP doesn't show playlist and crashes after loading large playlist | The_Stig | fixed 0.2.0.0 bugs | 1 | 2006-09-15 09:32 |