Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Mediabridge DM Zones question

  1. #1
    Join Date
    Jun 2005
    Posts
    339

    Default Mediabridge DM Zones question

    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

  2. #2
    Join Date
    Mar 2005
    Location
    Los Angeles, CA
    Posts
    1,003

    Default

    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

  3. #3
    Join Date
    Jun 2005
    Posts
    339

    Default Tim -

    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

  4. #4
    Join Date
    Apr 2008
    Posts
    6

    Default

    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

  5. #5
    Join Date
    Mar 2008
    Location
    Nottingham, England
    Posts
    406

    Default

    Hi Tim,

    is it possible to realease a code snippet for all to play with?

    Cheers

    Mark
    some people learn by writing, some by reading, some by listening and some by doing?...me I'm not learning at all

  6. #6
    Join Date
    Mar 2005
    Location
    Los Angeles, CA
    Posts
    1,003

    Default

    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!

    Code:
    -- 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:

    Code:
    MBInstance:GetZoneVariable( szZoneName, szVariableName );
    For example:
    Code:
    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.
    Last edited by tmorten; September 2nd, 2010 at 06:03 PM.

  7. #7
    Join Date
    Jun 2005
    Posts
    339

    Default Worked like a champ...

    ...thanks for the response!

    K

  8. #8
    Join Date
    Apr 2008
    Posts
    6

    Default

    Thanks for the sample!!!

    Jim

  9. #9
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    TMorten, sorry about dragging up a fossilized thread, but I'm trying to do something like this on my system. I need to know if JRMC is playing or not to run a command, and I can't get it into my head how to get that info from the MediaBridge component. I have tried running the code you have above, and it puts the MediaBridge variables into the variable, except for the zones. I do not get the zone info all. I just copied the code and removed the Local in front of the third line (the second of actual code). No zones. If I try to ask for something, like this:

    Code:
    local szPosition = MBInstance:GetZoneVariable( 'Tor', 'MP_PlaylistPosition' );
    print (szPosition)
    That just gives me the boolean printout "false". Do you have any pointers?
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  10. #10
    Join Date
    Mar 2005
    Location
    Los Angeles, CA
    Posts
    1,003

    Default

    Try also making ZoneList global (don't declare it as local), and look at its contents after executing the code. It should contain a list of valid zone names. Perhaps the zone name you're supplying isn't in that list?

    It's always possible a bug has crept into MediaBridge over the intervening years, but that code looks correct.

    Cheers,
    Tim

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •