Airplay on an Android device

I want to create an Android app where the Android device acts as a server (receiver) and an iOS device as a client (sender). I followed this link. But here you must first register for the port so that it appears as a cast option on the iOS device from the command line using:

mDNS -R MyAirplayService _airplay._tcp local 22555

      

When I run this Java code, I see the broadcast icon on my iOS device. But how can this be done on an Android device? Is there any open source or library out there for this?

+3


source to share


3 answers


If I'm not mistaken, Airplay is an Apple-only API. I've tried getting it to be recognizable on android and I've been pretty much unsuccessful. You might want to consider another way to stream audio.



0


source


This code basically registers a tpp service over the air on the local network, so that any other iOS device on the same local network can detect this broadcast service and therefore display the broadcast icon as an option.

  • On iOS, this can be done using Bonjour / NSNetService . Please refer to the official Apple manual.

    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.");
    }
    
          

  • On 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, this simply registers the service on the local network and gives you an icon on the iOS device. To make a real airplay server / mirroring service you need to do a lot more. If you want to know, please check out my iOS app, which runs as an Airplay mirroring server, https://www.youtube.com/watch?v=0d6ggJMypIk . There is also an open source project written in python called PyOpenAirMirror.

+1


source


I would look at Eric Sadun's utilities. I may be wrong, but I think they are open source. She wrote the server, player / transmitter, etc. For AirPlay.

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

0


source







All Articles