I am using googlecast sdk iOS 4.0.2 version to find castable devices under same wifi network, iOS version is 10.0 or above.
I created a singleton, and register the listener to it which successfully get called when find the devices on the very first time. After that can not get called anymore.
Because I don't need to start it automatically, so here following is my code to initialize the castcontext.
let criteria = GCKDiscoveryCriteria.init(applicationID: kGoogleCastApplicationID)
let options = GCKCastOptions.init(discoveryCriteria: criteria)
options.disableDiscoveryAutostart = false
options.stopReceiverApplicationWhenEndingSession = true
GCKCastContext.setSharedInstanceWith(
I set it to false because the following commments in the sdk.
/**
* A flag indicating whether the discovery of Cast devices should start automatically at
* context initialization time. If set to <code>NO</code>, discovery can be started and stopped
* on-demand by using the methods GCKDiscoveryManager::startDiscovery and
* GCKDiscoveryManager::stopDiscovery.
*
* @since 3.4
*/
Here's how I start and stop it.
start
func startDiscovery() {
if !discoveryManager.discoveryActive {
registerDiscover()
discoveryManager.startDiscovery()
}
}
stop
func stopDiscovery() {
if discoveryManager.discoveryActive {
removeDicover()
discoveryManager.stopDiscovery()
}
}
And one more weird thing is, on the console i see TIC Read Status [5:0x0]: 1:57
when app changing between foreground and background, and now my delegate get called. This is no helped anyway.
Anyone could help me to use the googlecast sdk correctly to start and stop it manually.
Thanks in advance.