View Full Version : Mediabridge DM Zones question
kwaugh
September 1st, 2010, 02:19 PM
Is it possible to access info from multiple zones via the Mediabridge component?
I have 3 zones enabled in MB, but I can only see info for 1 zone via the DM in girder.
Am I missing something?
Thanks!
K
tmorten
September 1st, 2010, 09:09 PM
I don't have much experience using the Device Manager GUI, but all the data for each zone is available at the variable level using the Component Manager. I'd be happy to share some LUA code that I use to access this information (I use it for generating a web interface) if that would be useful to you, so let me know.
Cheers,
Tim
kwaugh
September 2nd, 2010, 08:41 AM
That's my plan too - if you could share a snippet that would point me in the right direction, it would be much appreciated!
K
vettemanV8
September 2nd, 2010, 12:30 PM
Tim,
I would be very interested in see this code also. I am very much a beginner at this and I think this would be very helpful.
Thanks,
Jim
Solosid
September 2nd, 2010, 12:43 PM
Hi Tim,
is it possible to realease a code snippet for all to play with?
Cheers
Mark
tmorten
September 2nd, 2010, 01:49 PM
The example below sets up a local variable called MBInstance with a valid MediaBridge instance, and then sets up an array of strings called ZoneList with the names of all the available zones. If any calls fail, it posts errors both to the console and to the webserver, so you may want to delete one or the other depending on your application. Disclaimer: Ron (or others) should suggest changes if there's a more appropriate way of going about this, but the code below is derived from what I'm doing in my home setup, so hopefully I went about it the correct way! :)
-- Retrieve the MediaBridge instance
local MBInstance, ZoneList;
local MediaBridge = ComponentManager:GetComponentUsingName( 'MediaBridge' );
if ( MediaBridge ) then
-- Make sure that the component is enabled
if ( ComponentManager:IsComponentEnabled( MediaBridge ) == false ) then
ComponentManager:EnableComponent( MediaBridge );
end;
-- Retrieve the instance list
local InstanceList = MediaBridge:GetInstances( );
if ( InstanceList and table.getn( InstanceList ) > 0 ) then
-- Find the first valid instance
local i, iIndex;
for i = 1, table.getn( InstanceList ) do
if ( InstanceList[ i ] and InstanceList[ i ].CurrentZone ~= false ) then
iIndex = i;
break;
end;
end;
-- Choose the first valid instance
if ( iIndex ) then
MBInstance = InstanceList[ iIndex ];
else
szError = "ERROR: No valid Mediabridge instance found!";
webserver:print( szError );
print( szError );
return;
end;
if ( MBInstance ) then
-- Make sure some zones have been setup
if ( MBInstance:GetZoneCount( ) == 0 ) then
szError = "ERROR: No Mediabridge zones exist!";
webserver:print( szError );
print( szError );
return;
end;
-- Retrieve the zone list
ZoneList = MBInstance:GetZoneList( );
if ( ZoneList == nil ) then
szError = "Error: "..MBInstance:GetStatusDescription( );
webserver:print( "<p>"..szError.."<p>" );
print( szError );
szError = "Please verify that MediaBridge is running and properly configured.";
webserver:print( szError );
print( szError );
return;
end;
-- Post an error if there is no MediaBridge instance
else
szError = "ERROR: Unable to find a valid Mediabridge instance!";
webserver:print( szError );
print( szError );
return;
end;
else
szError = "ERROR: No Mediabridge instances available!";
webserver:print( szError );
print( szError );
return;
end;
end;
Now that you have a valid instance, and the list of valid zone names, you can query any data from any zone with the following:
MBInstance:GetZoneVariable( szZoneName, szVariableName );
For example:
local szPosition = MBInstance:GetZoneVariable( 'Master', 'MP_PlaylistPosition' );
Note that album cover images are only available using the experimental version of the MediaBridge component that I previously posted, which supports GAC+ calls (unrelated to the "GetZoneVariable" interface described above).
Cheers,
Tim
PS - To see what variables are available, you could make the instance global (remove the line that declares MBInstance as local), and use the Girder variable inspector to look at "MBInstance" and then "Zones" within it. Each zone has a long list of variables starting with "MP_" which you can query using the "GetZoneVariable" call described above.
kwaugh
September 2nd, 2010, 06:31 PM
...thanks for the response!
K
vettemanV8
September 2nd, 2010, 07:23 PM
Thanks for the sample!!!
Jim
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.