Author Topic: List of static playlists  (Read 8838 times)

Pako

  • Full Member
  • ***
  • Posts: 132
I can get (using API) a list of playlists. It is simple.
However, I would need to get a list of only "static" playlists (created by the user as "Playlist" or using "send to: <new playlist>").
Is it possible?

Thanks, Pako

boroda

  • Sr. Member
  • ****
  • Posts: 4653
No, but you can get playlist type with mbApiInterface.Playlist_GetType(playlist)

Pako

  • Full Member
  • ***
  • Posts: 132
Oh, thank you. This function returns (enum) PlaylistFormat.
So I have two additional questions:
1) Static playlist format is always MBP?
2) Other playlist (than static) is never MBP?
If the answer to both questions is yes, then my problem is solved.
Note: I'm interested solely on the playlists that are displayed in the navigation panel.

Thanks, Pako

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34369
Anything that is not:
PlaylistFormat.Smart
PlaylistFormat.Radio

is a static playlist

Pako

  • Full Member
  • ***
  • Posts: 132
Anything that is not:
PlaylistFormat.Smart
PlaylistFormat.Radio

is a static playlist

I'm very sorry, but I did not understand your response.  :(
This is certainly due to my poor English.
In addition - I do not know the "smart playlist".
In my version of the API does not exist.
Can someone please clarify?

Pako

boroda

  • Sr. Member
  • ****
  • Posts: 4653
'Smart' is auto playlist.
'Radio' is playlist mixer.
All other types are static playlists

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34369
mbApiInterface.Playlist_QueryPlaylists()
loop begin
  playlistUrl = mbApiInterface.Playlist_QueryGetNextPlaylist()
  if playlistUrl is null then exit loop
  PlaylistFormat format = mbApiInterface.Playlist_GetType(playlistUrl)
  if format <> PlaylistFormat.Smart and format <> PlaylistFormat.Radio
      //  this is a static playlist
  end if
loop end


PlaylistFormat.Smart refers to auto-playlists

Pako

  • Full Member
  • ***
  • Posts: 132
I thank you (boroda74 and Steven) very much for your explanation and patience.
Now I'm completely clear.
Only the "smart" I really can not use:
Code
        public enum PlaylistFormat
        {
            Unknown = 0,
            M3u = 1,
            Xspf = 2,
            Asx = 3,
            Wpl = 4,
            Pls = 5,
            Auto = 7,
            M3uAscii = 8,
            AsxFile = 9,
            Radio = 10,
            M3uExtended = 11,
            Mbp = 12
        }
Somewhere I can download a new version of the API?

Pako

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34369
all of the functions have been in the API for a long time so you should already have access to them.
if you want static playlists only then you need to exclude Radio and Smart

Pako

  • Full Member
  • ***
  • Posts: 132
all of the functions have been in the API for a long time so you should already have access to them.
if you want static playlists only then you need to exclude Radio and Smart
It seems that I am in this case "slow on the uptake," or we "talk at cross Purposes".
I understand practically everything.
Just my "Microsoft Visual C# 2010 Express" will not let me write the expression "PlaylistFormat.Smart".
This is not possible because the "Smart" does not exist in the enumerator "PlaylistFormat".
So I can add it there?
What integer I have to assign it?
Or should I replace the "Auto" item?

I'm very sorry and thank you.
Pako

boroda

  • Sr. Member
  • ****
  • Posts: 4653
Yes it seems that ".Auto"  is auto-playlist

Pako

  • Full Member
  • ***
  • Posts: 132
Yes it seems that ".Auto"  is auto-playlist
I thank you very much, you saved me. Everything is therefore as I assumed ....
After all - this works as expected:
Code
        internal string pQueryPlaylists(bool stat)
        {
            if (mbApiInterface.Playlist_QueryPlaylists())
            {
                string f = "dummy";
                Dictionary<string, string> dict = new Dictionary<string, string>();
                string name = String.Empty;
                while (f != null)
                {
                    f = mbApiInterface.Playlist_QueryGetNextPlaylist();
                    if (f != null)
                    {
                        if (stat) {
                            Plugin.PlaylistFormat pf = mbApiInterface.Playlist_GetType(f);
                            if (pf == Plugin.PlaylistFormat.Auto || pf == Plugin.PlaylistFormat.Radio) { continue; }
                        }
                        name = mbApiInterface.Playlist_GetName(f);
                        if (!dict.ContainsKey(name)) dict.Add(name, f);
                    }
                }
                return Dict2Json(dict);
            }
            return String.Empty;
        }

Thanks again, Pako