INTERACT FORUM
Windows => Plug-in Development => Topic started by: chrisjj 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.
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);
}
}
}
-
You have to test using the IMJPlaylistAutomation interface (http://wiki.jriver.com/index.php/MJPlaylistAutomation) to a particular playlist.
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...
if (pl.Get("Type") != 1) // then it is NOT a Playlist group (but might be a Smartlist or other special list)
or maybe
if (pl.Get("Type") == 0) // then it is a normal one
-
Type: 0 = normal playlist
Well, there's one reason Search didn't find it... Amended.
So, your ?? code would be...
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:
if(pl.Get("Type") != "1"/* is playlist */)
that works fine.
G, you're a star! Thank you very much.
(MC18-verified script attached FTR.)
-
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.