INTERACT FORUM

Windows => Plug-in Development => Topic started by: skeeterfood on September 29, 2009, 11:03:36 pm

Title: Play playlist through MJAutomation
Post by: skeeterfood on September 29, 2009, 11:03:36 pm
If I know the path to the playlist I want to play I can use mc14.exec to play it like this:
mc14.exe /Play TREEPATH=Playlists\Random\Songs\Everyone

How would I play the same playlist using MJAutomation?

It seems like I have to do something crazy like this (in crappy c-like pseudocode):

playlists = mcRef.GetPlaylists()
for (i=0; i < playlists.GetNumberPlaylists(); i++) {
  playlist = GetPlayList(i);
  if (playlist.Name() = "Random\Songs\Everyone") {
    files = playlist.GetFiles();
    files.Play();
  }
}

-John
Title: Re: Play playlist through MJAutomation
Post by: pbair on September 30, 2009, 04:20:07 am
Will something like this work?

files = mcRef.GetViewItem("Playlists\\Random\\Songs\\Everyone").GetFiles()
files.Play();

files.Sort([your sort scheme]) may also be needed to get the files in the order you want.  The wiki for .Sort() (http://wiki.jrmediacenter.com/index.php/MJFilesAutomation#void_Sort.28.29) really isn't clear to me though.  Anyone know how determine/select/define the sort scheme?
Title: Re: Play playlist through MJAutomation
Post by: johnnynine on October 10, 2009, 10:26:32 pm
Yes mcRef.GetViewItem() works.

How would you go about playing them in a specific zone? I assume files.Play() just plays the files in the active GUI zone?

I'm currently copying all the files to a specific zone's current playlist? This following works, but there must be a much simpler way to do it?

Code: [Select]
files = mcRef.GetViewItem("Playlists\\Random\\Songs\\Everyone").GetFiles();

int fileCount = files.GetNumberFiles();
for (int i=0; i<fileCount; i++)
{
    IMJFileAutomation file = files.GetFile(i);
    int key = file.GetKey();
    zonePlaylist.AddFileByKey(key, -1);
}
zonePlaylist.Play();

Thanks,
Johnny
Title: Re: Play playlist through MJAutomation
Post by: pbair on October 11, 2009, 06:49:02 am
Code: [Select]
files = mcRef.GetViewItem("Playlists\\Random\\Songs\\Everyone").GetFiles();

int fileCount = files.GetNumberFiles();
for (int i=0; i<fileCount; i++)
{
    IMJFileAutomation file = files.GetFile(i);
    int key = file.GetKey();
    zonePlaylist.AddFileByKey(key, -1);
}
zonePlaylist.Play();

I haven't dealt with zones yet.  Would be nice if you could simply specify the zone as an optional argument of the MJFilesAutomation Play() function.  For example, Files.Play(ZoneNumber).  If no ZoneNumber is specified, then the active zone could be assumed.