INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: How to determine whether GetPlaylist() is a playlist group?  (Read 1936 times)

chrisjj

  • Citizen of the Universe
  • *****
  • Posts: 750
How to determine whether GetPlaylist() is a playlist group?
« on: January 28, 2013, 05:29:51 pm »

I find MediaCenter.MCAutomation.GetPlaylists() returns playlists and playlist groups, whereas the documentation http://wiki.jriver.com/index.php/MJPlaylistsAutomation says only it returns playlists.

A bug, I guess.

Is there any way I can manually determine whether a given object returned by GetPlaylist() is a playlist or a playlist group?

Specifically I want to code a test at ? below.

Thanks.

Code: [Select]
using System;
using System.Windows.Forms;
//css_reference MediaCenter.dll;

class Script : MarshalByRefObject
{
    public void Init(MediaCenter.MCAutomation mediaCenterInterface)
    {                                           
        MediaCenter.IMJPlaylistsAutomation pls = mediaCenterInterface.GetPlaylists();
        int plqty = pls.GetNumberPlaylists();
        Console.WriteLine("Playlist qty = "+plqty.ToString());
        for(int counter = 0; counter < plqty; ++counter)
        {
            MediaCenter.IMJPlaylistAutomation pl = pls.GetPlaylist(counter);
            if(pl.?/* is playlist not playlist group*/)
                 Console.WriteLine(pl.Path + (pl.Path!=""?@"\":"") + pl.Name);
        } 
    }
}
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: How to determine whether GetPlaylist() is a playlist group?
« Reply #1 on: February 08, 2013, 11:12:38 am »

You have to test using the IMJPlaylistAutomation interface to a particular playlist.

Code: [Select]
string Get(string bstrProperty)

Description: lookup a property associated with a playlist
Parameters:

    bstrProperty: the name of the property

Return Value: the value of the property for this playlist
Properties (not complete list):

    Type: 0 = normal playlist, 1 = playlist folder, 2 = Smartlist, 3 = Special (e.g. 'Current Playcharts')

So, test IMJPlaylistAutomation.Get(Type) once you have the IMJPlaylistAutomation object.

That will return 1 for a playlist group (folder).

So, your ?? code would be...

Code: [Select]
if (pl.Get("Type") != 1)    // then it is NOT a Playlist group (but might be a Smartlist or other special list)
or maybe

Code: [Select]
if (pl.Get("Type") == 0)    // then it is a normal one
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

chrisjj

  • Citizen of the Universe
  • *****
  • Posts: 750
Re: How to determine whether GetPlaylist() is a playlist group?
« Reply #2 on: February 08, 2013, 11:40:13 am »

   Type: 0 = normal playlist

Well, there's one reason Search didn't find it... Amended.

So, your ?? code would be...

Code: [Select]
if (pl.Get("Type") != 1)    // then it is NOT a Playlist group (but might be a Smartlist or other special list)

Correcting for return type string:

Code: [Select]
if(pl.Get("Type") != "1"/* is playlist */)  
that works fine.

G, you're a star! Thank you very much.

(MC18-verified script attached FTR.)
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: How to determine whether GetPlaylist() is a playlist group?
« Reply #3 on: February 08, 2013, 11:57:19 am »

Thanks.  Yeah, I didn't bother to check on the return type when I added my example code, but I figured you'd get it.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/
Pages: [1]   Go Up