Search code examples
wifichromecastdisconnect

Disconnect Chromecast when device leaves Wi-Fi network


I am developing an iOS application with Chromecast. I would like to disconnect the Chromecast (stop playing the content) when the device that sent the content leaves the Wi-Fi network. Is it possible to do this? How would you implement it?

Thank you!


Solution

  • Are you sure you want to do this? This is against the Cast UX design, and frankly, provides a bad user experience. Also, consider a case where your connectivity to the wifi is dropped temporarily for whatever reason, do you really want to stop the playback? What if there is another sender connected at the same time, do you still want to stop it? Lets say your phone goes to sleep and loses connectivity, do you want to stop the playback?

    As for the possibility of doing it, it obviously cannot be driven from the sender side since it has lost its connectivity. On the receiver side, you get a callback when senders get connected or disconnected, along with a "reason" so you need to implement your logic there.