Question

I want to build an android application in which the android device work as airplay server (receiver) and iOS device as a client(sender). I have followed this link . But here you have to first register to the port to appear as a airplay option on iOS device from the command line using :

mDNS -R MyAirplayService _airplay._tcp local 22555

When i run this java code I can see airplay icon on my iOS device . But how it can be don in android device ? Is there any open source code or library to do this ?

Was it helpful?

Solution 2

If I'm not mistaken, Airplay is an Apple-only API. I have tried getting it to be recognizable on android and I was largely unsuccessful. You may want to consider another mode of transmission for the streaming audio.

OTHER TIPS

That code is basically registering an airplay tcp service in the local network, so that any other iOS device on the same local network can discover this airplay service, and therefore display the airplay icon as an option.

  • In iOS, this can be done using the Bonjour/NSNetService. Please refer to the Apple's official tutorial.

    NSNetService *service;
    service = [[NSNetService alloc] initWithDomain:@""// 1
                                type:@"_airplay._tcp"
                                //this will show up as the airplay name
                                name:@"myiOSAirplayServer" 
                                port:port];
    if(service)
    {
        [service setDelegate:delegateObject];// 2
        [service publish];// 3
    }
    else
    {
        NSLog(@"An error occurred initializing the NSNetService object.");
    }
    
  • In Android, this can be done using Network Service Discovery, and the official example is here:

    public void registerService(int port) {
      NsdServiceInfo serviceInfo  = new NsdServiceInfo();
      //this will show up as the airplay name
      serviceInfo.setServiceName("myAndroidAirplayServer");
      serviceInfo.setServiceType("_airplay._tcp.");
      serviceInfo.setPort(port);
    
      mNsdManager = Context.getSystemService(Context.NSD_SERVICE);
    
      mNsdManager.registerService(
            serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
    }
    

However, doing so just registers the service in local network, and gives you an icon in the iOS device. To do the real airplay server/mirroring service, you need to do a lot more. If you want to know that, please check my iOS app that works as an Airplay mirroring server, https://www.youtube.com/watch?v=0d6ggJMypIk. There is also an open source project that is written in python, called PyOpenAirMirror.

I would look at Erica Sadun's utilities. I may be mistaken, but I think they are open source. She has written a server, player/transmitter etc. for AirPlay.

http://ericasadun.com/category/airplayer/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top