View Full Version : GAC Schemes: How to avoid sending 5000 tracks to Playing Now
Jlee
August 8th, 2004, 11:33 PM
After trying OpusNR MikeC suggested that there should be a way of stopping someone from sending 5000 tracks to Playing Now. Well I've sort of thought of a way round this problem with my GAC scheme playlist listing. Currently when I hit the playlists button to call up the GAC scheme I get a heirarchical view of smartlists I've set up in MC E.g.:
Random Albums>>
Any album
Favourite Album
Rock Album
Rock & Pop Tracks>>
Rated 2* and above
Rated 3* and above
etc. etc.
Schemes like 'Rock and Pop Rated 2* and above' include rules in MC to limit the selection to 100 random tracks. The problem arises if someone hits play without drilling down far enough e.g. hitting play next to 'Rock and Pop Tracks>>' will send 28,500 tracks to playing now on my system. So a solution to this could be to name everything except the last level with > as the last character. Then the Play and Add to Play buttons would have lua code that would say:
If MP.GACScheme last character == '>' then
drill down to next level (or do nothing or jump to a sarcastic message!)
else
execute LX Play
end
Now then MikeC or Rob, you probably notice that the above code is not the best Lua scripting you ever saw! Any chance of a translation? I am learning slowly but with me it's real slow!
Mastiff
August 8th, 2004, 11:49 PM
Don't complain, J! I'm not really learning or understanding anything even though I'm trying! :oops:
Jlee
August 9th, 2004, 06:08 AM
Just to prove I did actually try and understand the Lua book (even though most of it is gobbledegook to me) here's my effort at the first line:
if string.sub(MP.GACScheme,-1,-1)=='>' then
If that's right I just need to understand how to execute the 'LX PLAY {MP.GACSheme}' action in a line of Lua. I believe that the syntax will be NetRemote.ExecuteAction([plugin id],[param 1],[param 2],[ir name],[call number]); but don't know what goes where.
Ben S
August 9th, 2004, 06:15 AM
Take a look at the jrmc800x600.lua file that is installed with the 1.0 prerelease, it has information concerning loading up GACs. You'll see how I load the GAC when you go to the "Media Library" panel, and how it forces a GAC reload if the host changes and you are on the panel.
function loadGAC()
gac_loaded = 1;
NetRemote.SetVariable('MP.GACStart','0');
NetRemote.SetVariable('MP.GACScheme','Media Library\\Audio\\Album');
NetRemote.SetVariable('MP.GACCount','25');
NetRemote.SetVariable('MP.GACSize','M');
NetRemote.ExecuteAction(-10,2,255,'GAC "{MP.GACScheme}" {MP.GACStart} {MP.GACCount} {MP.GACSize}',1);
end;
Ben S
August 9th, 2004, 06:18 AM
So you can use the same basic thing.
Plugin ID: -10 (MediaBridge plugin instance)
Param1: 2
Param2: 255 (2,255 identifies the command you want to use)
IRName: 'LX PLAY [GAC PATH]'
Call Number: 1
NetRemote.ExecuteAction(-10,2,255,'LX PLAY "[GAC PATH]"',1);
Jlee
August 9th, 2004, 06:25 AM
I think I understand most of that, I'm just not sure what this means:
Param1: 2
Param2: 255 (2,255 identifies the command you want to use)
Will these values always be 2 & 255 for every NR command I want to execute? If not how would I know what to use?
Ben S
August 9th, 2004, 06:29 AM
You'd have to use some of the reference that's around (including this not up to date page (http://www.netremote.org/dl/driver_ref.html)).
2,255 is the value for "send a string command to JRMC". Then you would have to know some of the string commands (of which LX and GAC are two).
Jlee
August 9th, 2004, 06:44 AM
Thanks that makes sense. So the combination of command 1 & 2 tell NR what type of action to perform in the same way as a Tonto hex code does. While your here can you tell me if my attempted one line of Lua above is correct?
Ben S
August 9th, 2004, 06:55 AM
Yes.
This:
5001 0000 0000 0002 fff6 0002 00FF 0000
=
-10,2,255
as seen in this wiki page (http://www.netremote.org/pmwiki/index.php/Docs/CCF) (scroll down to "Codes in Tonto").
As to your lua, I believe you'd just want
if (string.sub(NetRemote.GetVariable('MP.GACScheme '),-1) == '>') then
...
end;
Note that you'd use NetRemote.GetVariable (as you can't access NetRemote variables as if they had "scope" in lua) and that want the whole string starting 1 character from the end, so only need to pass the first -1.
Jlee
August 9th, 2004, 07:00 AM
Thanks Ben.
I'd like to say I was close but I wasn't. I think I'll stick to my day job in future and leave coding to the experts :D
Cocophone
August 9th, 2004, 07:21 AM
As an alternative you could delete some of your Rock and Pop Music and add some diversity with Country, Blues, and Folk-Rock music. :)
Jlee
August 9th, 2004, 07:58 AM
That would solve the problem too because if I added a smartlist rule that only selects those genres I would only pick out about 100 tracks.
avid
August 9th, 2004, 08:10 AM
Maybe Mastiff can let you have some Norwegian thrash metal?
Mastiff
August 9th, 2004, 08:36 AM
How little you know... Thrash is an american metal form. It's black metal that's norwegian! Burning churches and all that, you know! :evil:
Jlee
August 9th, 2004, 08:57 AM
Help! It's not working. I'm trying this code and it works as long as the stuff under the else statement only has one 'ExecuteAction'. If I try and add more actions to execute (in this case 3 in total) it just doesn't do anything. I know that each action works as I've tried each one of the 3 one their own.
if (string.sub(NetRemote.GetVariable('MP.GACAlbumPath _<LoopIndex>'),-1) == '>') then
NetRemote.GoDevice('MC','GACMessage');
else
NetRemote.ExecuteAction(-10,2,255,'LX PLAY {MP.GACAlbumPath_<LoopIndex>} -1',1);
NetRemote.ExecuteAction(-1,0,1,"MC.RefreshPNDelay");
NetRemote.SetVariable('LastGAC',NetRemote.GetVaria ble('MP.GACAlbumPath_<LoopIndex>'));
NetRemote.SetVariable('LastPlayMode','PLAY');
NetRemote.ExecuteAction(-1,0,1,"MC.SetLastGAC("..NetRemote.GetVariable('MP.GACAlbumPath_<LoopIndex>')..")");
end;
Jlee
August 9th, 2004, 10:26 AM
Though I don't understand why the above code doesn't work I got round this. On the play button in my Playlists GAC scheme I'm now simply using this:
if (string.sub(NetRemote.GetVariable('MP.GACAlbumPath _<LoopIndex>'),-1) == '>') then
NetRemote.GoDevice('MC','GACMessage');
else
NetRemote.ExecuteAction(-10,2,255,'LX PLAY {MP.GACAlbumPath_<LoopIndex>} -1',1);
NetRemote.GoDevice('MC','Main');
end;
I execute the other stuff using normal Tonto codes as I did before which means I have to execute them even if the Error Message (the GAC Message panel above) is shown. This means that I set some variables that I use on my Repeat Last Playlist button which effectively means that using the repeat button after an incorrect playlist select would send thousands of tracks to Playing now. Therefore I've added similar Lua code and error message to my Repeat button to stop this happening.
All we need now is some way to stop people using the JRMC tree view in NR to play thousands of files. That will have to be one for Ben.
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.