-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConnectSDK cordova CapabilityFilters #47
Comments
Hi @MyCreativeWebSolutions, in your case you do not need to filter for capabilities, but for services. Here's a function that will return only AirPlay and Chromecast devices: function getFilteredDevices() {
var allDevices = ConnectSDK.discoveryManager.getDeviceList();
var filteredDevices = [];
for (i = 0; i < allDevices.length; i++) {
var device = allDevices[i];
if (device.hasService("AirPlay") || device.hasService("Chromecast")) {
filteredDevices.push(device);
}
}
return filteredDevices;
} |
Thank you somuch!.. Any ideas on how can I implement this with pickdevice() pop up function?
|
The built in pop-up is native. It won't be very simple to customize it with that filter. You'd have to start a custom branch of the whole plugin and make changes for both Android and IOS. You'd probably need to look at this file in the core library for the Android version: Connect-SDK-Android-Core/src/com/connectsdk/device/DevicePickerAdapter.java Instead of doing all of that I would recommend just building a custom picker in JavaScript. You can subscribe to the "devicelistchanged" event on the DiscoveryManager and repopulate your own list every time the event fires. The behavior will be very similar to the built-in picker. |
Hi @orilux Thank you somuch for your help!. The major issue we noticed in Cordova ConnectSDK is, the event "devicelistchanged" never fires.. Ex:-
Even tried
|
The events "devicefound" and "devicelost" are also not firing in Cordova |
Hi @MyCreativeWebSolutions, it looks like you are not passing your callback function correctly. You shouldn't pass the name of the function as a string. Change your code to this and see if it works: ConnectSDK.discoveryManager.on('devicelistchanged', getFilteredDevices); |
Hi @orilux That was very much helpful!.... Finally, we need to store this filtered list in a javascript sessionStorage or localStorage and retrieve it later. Any ideas on this?. Getting difficulty in storing this filteredlist in session.
|
I am guessing this is because of the asynchronous callback of A quick thing to try is to move the sessionsStorage code inside the iterator like this: ...
$.each(allDevices, function(idx, dv){
if (dv.hasService("AirPlay") || dv.hasService("Chromecast")) {
filteredDevices.push(dv);
}
window.sessionStorage.setItem("playdevices", JSON.stringify(filteredDevices));
});
... Keep in mind that this overwrites the sessionsStorage for every item in the array, so it is not the best solution. You should look into using an iterator that does not use callbacks. |
@orilux Looks like I can store deviceId or friendlyName in filteredDevices array and later retrieve it from sessionStorage without any issues. But entire device object cannot be stored or alerted using JSON.stringify. Is there a possible way to store only device parameter like its deviceID or friendlyName and later initiate a device object using that parameter?. P.S., I even tried calling getDeviceList later to get all devices and initiate the device object by cross checking the deviceID. But, getDeviceList in cordova only returns devices that are already connected/being streamed when called separately without any events. |
Saving the entire device object is a very bad idea, because the device's ip address might have changed next time you try to connect. You should save the deviceId and then when devicelistchanged fires you should iterate through all the devices in the array and look for the one that has a matching id. However if there is more than one device on the network devicelistchanged is going to fire multiple times so you will need to handle that. In other words, just because the device was not in the list the first time, it doesn't mean that it is not available. |
Hi, The major challenge here is, we need to save devices on devicelistchanged event and create a custom device picker that gets called on a button click. Any ideas on how to handle this situation? We are just trying to create a custom device picker here as per this thread. Thanks in advance!
|
@orilux @penelopus @Andolamin @jlai Hi Team, Can we please get some final thoughts on handling the above situation?. We really wish default picker would have device filtering instead of building this custom picker. Anyhow, We're expecting some small help in building the custom picker here. We are about to launch the App and this is the final thing holding us from doing that. Thanks, |
Hi, |
Is there some capabilityfilter options to filter ONLY airplay and chromecast devices?
The text was updated successfully, but these errors were encountered: