mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-09-15 22:12:24 +00:00
casting: add discovered devices directly to internal list when added
This commit is contained in:
parent
1176cee40b
commit
7169cd1b82
1 changed files with 7 additions and 15 deletions
|
@ -111,21 +111,6 @@ class ExpStateCasting {
|
|||
|
||||
init {
|
||||
org.fcast.sender_sdk.initLogger(org.fcast.sender_sdk.LogLevelFilter.DEBUG)
|
||||
onDeviceAdded.subscribe { device ->
|
||||
invokeInMainScopeIfRequired {
|
||||
val deviceHandle = CastingDeviceHandle(device)
|
||||
devices[deviceHandle.device.name()] = deviceHandle
|
||||
Log.i(TAG, "Device added: ${deviceHandle.device.name()}")
|
||||
}
|
||||
}
|
||||
|
||||
onDeviceRemoved.subscribe { deviceName ->
|
||||
invokeInMainScopeIfRequired {
|
||||
if (devices.containsKey(deviceName)) {
|
||||
devices.remove(deviceName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun handleUrl(context: Context, url: String) {
|
||||
|
@ -191,17 +176,24 @@ class ExpStateCasting {
|
|||
context,
|
||||
DiscoveryEventHandler(
|
||||
{ deviceInfo -> // Added
|
||||
Logger.i(TAG, "Device added: ${deviceInfo.name}")
|
||||
val device = _context.createDeviceFromInfo(deviceInfo)
|
||||
val deviceHandle = CastingDeviceHandle(device)
|
||||
devices[deviceHandle.device.name()] = deviceHandle
|
||||
invokeInMainScopeIfRequired {
|
||||
onDeviceAdded.emit(device)
|
||||
}
|
||||
},
|
||||
{ deviceName -> // Removed
|
||||
invokeInMainScopeIfRequired {
|
||||
if (devices.containsKey(deviceName)) {
|
||||
devices.remove(deviceName)
|
||||
}
|
||||
onDeviceRemoved.emit(deviceName)
|
||||
}
|
||||
},
|
||||
{ deviceInfo -> // Updated
|
||||
Logger.i(TAG, "Device updated: $deviceInfo")
|
||||
val handle = devices[deviceInfo.name]
|
||||
if (handle != null) {
|
||||
handle.device.setPort(deviceInfo.port)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue