[SOLVED] Speaker Selection

Forum to discuss MonkeyTunes DACP Server for MediaMonkey

Re: Speaker Selection

Postby Melloware » Fri Oct 08, 2010 2:17 pm

fantastic. Let me know if it gets approved. since this is .NET it should be fairly simply to roll into MT.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11068
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Speaker Selection

Postby Melloware » Fri Oct 08, 2010 9:15 pm

Great news. Roague Ameoba got back to me and said this...

If you want to interact with Airfoil through a .NET project, you'll need to add a reference to the Airfoil.exe file. If you want to interact with it via a COM interface, you should add a reference to the Airfoil.tlb file.

So a COM object is perfect and will make this possible! The hardest part will be reverse engineering the Apple Remote calls to control Speakers.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11068
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Speaker Selection

Postby Redth » Sat Oct 09, 2010 8:39 am

Melloware wrote:Great news. Roague Ameoba got back to me and said this...

If you want to interact with Airfoil through a .NET project, you'll need to add a reference to the Airfoil.exe file. If you want to interact with it via a COM interface, you should add a reference to the Airfoil.tlb file.

So a COM object is perfect and will make this possible! The hardest part will be reverse engineering the Apple Remote calls to control Speakers.


Let me know how that turns out for you. I tried adding a reference to the COM object and it told me I had to add a reference to the .NET assembly instead. I referenced Airfoil.exe, but you can't instantiate Airfoil App:

RogueAmoeba.Airfoil.Remoting.AirfoilApp afa = new RogueAmoeba.Airfoil.Remoting.AirfoilApp();

But it gives me an error that you cannot do so locally.. Upon further inspection in Reflector, it looks like the public ctor for AirfoilApp has the hard coded exception, but the private ctor is the one that works.

So, I guess I don't know how to interact with the RogueAmoeba.Airfoil.Remoting.* stuff properly, but if we could, it looks like exactly the kind of thing needed to interact with the speakers. Hopefully they gave you more info about how to use it. As for reverse engineering the apple dacp calls, what are you using? just wireshark or something? I can do some digging and see if I can help out in that area at all too. I think to setup a test environment we'd need to have at least 2 machines with itunes running, and then I think one can act as remote speakers (not sure). Otherwise we need an actual airport express to test with.
Redth
 
Posts: 15
Joined: Thu Oct 07, 2010 4:47 pm

Re: Speaker Selection

Postby Melloware » Sat Oct 09, 2010 9:08 am

I just did the same thing....

Code: Select all
// check for Airfoil Speakers
AirfoilApp airfoil = null;
try {
    airfoil = new AirfoilApp();
    ISpeakerCollection speakers = airfoil.GetSpeakers();
    for (int i = 0; i < speakers.Count(); i++) {
         ISpeaker speaker = speakers.Item(i);
         LOG.DebugFormat("Remote Speaker Found = {0}", speaker.Name());
    }
} catch (Exception ex) {
    LOG.Warn("Airfoil speakers not found");
    LOG.Error("Airfoil Error", ex);
} finally {
    airfoil = null;
}


Is throwing this error....
Code: Select all
2010-10-09 10:11:42,216 [ERROR] - (1) - Airfoil Error
System.Runtime.InteropServices.COMException (0x80004005): This class can not be used locally
   at RogueAmoeba.Airfoil.Remoting.AirfoilApp..ctor()



I just emailed them back asking how to do it properly from .NET. They originall sent me this Javascript example....

Code: Select all
var AirfoilApp = WScript.CreateObject("Airfoil3.Application");
var speakerCollection = AirfoilApp.GetSpeakers();
var i = 0; var connected = 0; for (i = 0; i < speakerCollection.Count(); i++) {
    var Speaker = speakerCollection.Item(i);
    if (Speaker.RequiresPassword == false)
    {
        Speaker.Connect();
        connected++;
    }
}
WScript.Echo("Connected to " + connected + " speakers");
AirfoilApp.SetLinkedVolume(true);


But that is using true COM and the TLB they provide was generated by .NET so it can't be imported by a .NET app only the Airfoil.exe assembly can be imported. I just emailed them...
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11068
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Speaker Selection

Postby Melloware » Sat Oct 09, 2010 12:25 pm

FIgured it out after much Googling and trial and error. THis is not a typical COM object but this works...

Code: Select all
IAirfoil airfoil = null;
try {
   Type t = Type.GetTypeFromProgID("Airfoil3.Application");
   airfoil = (IAirfoil)Activator.CreateInstance(t);
   ISpeakerCollection speakers = airfoil.GetSpeakers();
   for (int i = 0; i < speakers.Count(); i++) {
      ISpeaker speaker = speakers.Item(i);
      LOG.InfoFormat("Remote Speaker: {0}", speaker.Name());
   }
} catch (Exception ex) {
   LOG.Error("AirFoil Error", ex);
} finally {
   airfoil = null;
}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11068
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Speaker Selection

Postby Redth » Sat Oct 09, 2010 1:00 pm

Nice work!

Now, just to reverse engineer the DACP protocol for it
Redth
 
Posts: 15
Joined: Thu Oct 07, 2010 4:47 pm

Re: Speaker Selection

Postby Melloware » Sat Oct 09, 2010 4:07 pm

SHouldn't be a problem. Working on it now... will send you a BETA to test tomorrow?

Are you an Airfoil owner?
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11068
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Speaker Selection

Postby Redth » Sat Oct 09, 2010 5:14 pm

Great! Ill test on Monday. Its Canadian Thanksgiving this weekend. :)
Redth
 
Posts: 15
Joined: Thu Oct 07, 2010 4:47 pm

Re: Speaker Selection

Postby Melloware » Sat Oct 09, 2010 11:24 pm

I think their are bugs in this Airfoil API. I cannot get it to do what I want. I can get a list of Speakers and even activate a speaker but no sound comes out from MM. THe only way I can get sound to come out is to use the Airfoil UI and pick the "Primary Sound Driver" option and activate the speaker. The problem with that is I can't control that from the API. I have tried to emulate anything the UI is doing with their API but it does not seem to have any effect. I am either missing something or the API does not work.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11068
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Speaker Selection

Postby Redth » Sun Oct 10, 2010 1:01 pm

I'm going to play around with the COM api on monday, see if I can find anything that works...
Redth
 
Posts: 15
Joined: Thu Oct 07, 2010 4:47 pm

Re: Speaker Selection

Postby Melloware » Fri Dec 10, 2010 6:08 pm

Rogue Ameoba software got back to me after I sent them sample code and they have confirmed their COM API is broken based on my code. They did not release a timetable but did say they planned on fixing in a future version.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11068
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Speaker Selection

Postby Redth » Sat Dec 11, 2010 9:42 am

Thanks for the update :)
Redth
 
Posts: 15
Joined: Thu Oct 07, 2010 4:47 pm

Re: Speaker Selection

Postby Andulien » Fri Jun 17, 2011 2:42 pm

Hey there,

I love MonkeyTunes, and have been using it since quite a while. I have been trying to check in on this Forum from time to time, to see what's new. I've been thinking for a while to get Airfoil, but would like to see the speaker implementation first, so I can control remote if I want to play the music on my phone (with an app ;) ) or play it on my computer or other speakers.

Have you heard anything back from Rogue? If not, would you mind possibly asking them again? Since it has been more than half a year since the last note.

Would be awesome if you could. Thanks :)

Andulien
Andulien
 
Posts: 52
Joined: Fri Jun 17, 2011 2:03 pm

Re: Speaker Selection

Postby Melloware » Fri Jun 17, 2011 2:50 pm

I totally agree this would be a killer feature for MonkeyTunes. I have the code set for the Apple Remote part of controlling the speakers the only piece missing is the ability to them actually control your speakers through Airfoil.

I have not heard from them in months about the issue. I was happy they at least confirmed that they had bugs in their API and as soon as they fix them I will finish the implementation. I will reach out to them to see if there is any status update.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11068
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Speaker Selection

Postby Andulien » Fri Jun 17, 2011 2:56 pm

Sweet. Thanks a bunch. Yea it sure would be a killer feature :D You'd be way ahead of other's hehe I had another question, but will open a seperate thread for that.

Thanks for the amazing quick response :)
Andulien
 
Posts: 52
Joined: Fri Jun 17, 2011 2:03 pm

PreviousNext

Return to MonkeyTunes for MediaMonkey

Who is online

Users browsing this forum: No registered users and 2 guests