Loading Current playlist, then Playing it (1 Viewer)

hbe02

Portal Member
April 1, 2008
26
1
Home Country
Hi all, So ive been struggling lately with playing playlists. Ive had some programming issues which turned out to be actually a mis-installed MP. Anyways, my goal is to play a playlist file (.wpl) so i figured out how to load the (.wpl) playlist into the "Current playlist" and this is done as follows:
Code:
MediaPortal.Playlists.PlayList p = new MediaPortal.Playlists.PlayList();
                p = MediaPortal.Playlists.PlayListPlayer.SingletonPlayer.GetPlaylist(MediaPortal.Playlists.PlayListType.PLAYLIST_MUSIC);
                MediaPortal.Playlists.PlayListWPLIO wpl = new MediaPortal.Playlists.PlayListWPLIO();
                wpl.Load(p, "myplaylist.wpl");
                MediaPortal.Playlists.PlayListPlayer.SingletonPlayer.Init();
                p.Shuffle();
It is very important to note that if you just say g_player.Play("playlist.wpl") it will play it, but as 1 object, MP will not load any items and you wont be able to click"Next"

So far so good, now here is the problem. How do you play the "Current Playlist"? Ive tried:
Code:
MediaPortal.Playlists.PlayListPlayer.SingletonPlayer.Play(1);
but that didnt work! no responce from MP because the playlist should already be playing when you say .Play(1).
I also tried:
Code:
MediaPortal.Playlists.PlayListPlayer.SingletonPlayer.PlayNext();
and that didnt work either. Now what I concluded from a little experimenting is that you need to move the "Current Playlist" to "Now Playing" and then play, or at least play one track from the "Current Playlist"

I guess thats as far as i can go on my own, for now..hehe...Any Help?
 

and-81

Retired Team Member
  • Premium Supporter
  • March 7, 2005
    2,257
    183
    Melbourne
    Home Country
    Australia Australia
    I'll take this code and put it into my Shortcut player and PlayOnStart plugins and see what I can do.

    I'll post back here if I figure it out for you.

    Cheers,

    PS. I'll try adding it to my telnet interface too... It's coming along nicely but is suffering from a lack of attention (due to everything else taking up my time).
     

    hbe02

    Portal Member
    April 1, 2008
    26
    1
    Home Country
    Where is the documentation for these classes so i can at least look something up. Im absolutely stuck now. I think fiuring out how to load the current playlist to the now playing should solve the porblem.
     

    and-81

    Retired Team Member
  • Premium Supporter
  • March 7, 2005
    2,257
    183
    Melbourne
    Home Country
    Australia Australia
    There is no class level documentation. You should look at how MediaPortal does it itself in it's source code. I'm still looking into this for you but I've been very busy the last week.

    I'll see what I can find and get back to you ... so far it's giving me a headache too :(

    Cheers,
     

    hbe02

    Portal Member
    April 1, 2008
    26
    1
    Home Country
    im having trouble getting my hands on the source code.. if i can compile MP myself and run the program line by lin(which would take a long time) i can definitely figure out how this is done.
    anyways.. just for kicks, here is another way of playing a playlist, unfortunately, it gives same results as above :-(
    MediaPortal.GUI.Library.GUIMessage GM = new GUIMessage();
    GM.TargetWindowId = (int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_MUSIC_PLAYLIST;
    GM.Message = GUIMessage.MessageType.GUI_MSG_PLAYBACK_ENDED;

    GM.Label = "playlist.wpl";
    GM.SendToTargetWindow = true;
    MediaPortal.GUI.Library.GUIWindowManager.SendMessage(GM);
     

    jburnette

    Portal Pro
    August 24, 2006
    758
    116
    Kentucky
    Home Country
    United States of America United States of America
    Not sure if you're still needing to know how to do this, but I found myself in the same situation with something I'm working on and think I've figured it out. Below is the code I use to add video files to a playlist and play them. Seems to work fine for me.

    Code:
    //create your player and then get your playlist to work with
    MediaPortal.Playlists.PlayListPlayer plp = MediaPortal.Playlists.PlayListPlayer.SingletonPlayer;
    
                MediaPortal.Playlists.PlayList playlist = plp.GetPlaylist(MediaPortal.Playlists.PlayListType.PLAYLIST_VIDEO);
    
    //add your items
     MediaPortal.Playlists.PlayListItem pli = new MediaPortal.Playlists.PlayListItem();
                            pli.FileName = file;
                            pli.Type = MediaPortal.Playlists.PlayListItem.PlayListItemType.Video;
                            pli.Description = file;
                            playlist.Add(pli);
    
    //load the list shuffle if need be, then play
     plp.CurrentPlaylistType = MediaPortal.Playlists.PlayListType.PLAYLIST_VIDEO;
                playlist.Shuffle();
                
                plp.Play(0);

    Should be as simple as switching the type used to music.
     

    hbe02

    Portal Member
    April 1, 2008
    26
    1
    Home Country
    thanks a bunch for the follow up jburnette. Yes i am still lingering on this problem. i will try out your code and repost immediately.

    [EDIT]
    thanks alot for your followup. It finally worked. Here is what my modified code looks like:
    Code:
       //create your player and then get your playlist to work with
                    MediaPortal.Playlists.PlayListPlayer plp = MediaPortal.Playlists.PlayListPlayer.SingletonPlayer;
    
                    MediaPortal.Playlists.PlayList playlist = plp.GetPlaylist(MediaPortal.Playlists.PlayListType.PLAYLIST_MUSIC);
    
                    //add your items
                    MediaPortal.Playlists.PlayListWPLIO wpl = new MediaPortal.Playlists.PlayListWPLIO();
                    wpl.Load(playlist, FileToPlay.Trim());
                    
                    //load the list shuffle if need be, then play
                    plp.CurrentPlaylistType = MediaPortal.Playlists.PlayListType.PLAYLIST_MUSIC;
                    playlist.Shuffle();
    
                    plp.Play(0);
     

    Users who are viewing this thread

    Top Bottom