Search in sources :

Example 1 with ConnectableDevice

use of com.connectsdk.device.ConnectableDevice in project butter-android by butterproject.

the class BeamDeviceAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.casting_dialog_listitem, parent, false);
        holder = new ViewHolder(convertView);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    ConnectableDevice device = getItem(position);
    int imgResource = R.drawable.ic_dlna;
    Collection<DeviceService> services = device.getServices();
    ArrayList<String> textServices = new ArrayList<>(services.size());
    for (DeviceService service : services) {
        if (service instanceof CastService) {
            imgResource = R.drawable.ic_googlecast;
            textServices.add("Google Cast");
        } else if (service instanceof DLNAService) {
            imgResource = R.drawable.ic_dlna;
            textServices.add("DLNA");
        } else if (service instanceof AirPlayService) {
            imgResource = R.drawable.ic_airplay;
            textServices.add("AirPlay");
        } else if (service instanceof RokuService) {
            imgResource = R.drawable.ic_dlna;
            textServices.add("Roku");
        } else if (service instanceof WebOSTVService) {
            imgResource = R.drawable.ic_dlna;
            textServices.add("webOS TV");
        } else if (service instanceof NetcastTVService) {
            imgResource = R.drawable.ic_dlna;
            textServices.add("Netcast");
        }
    }
    String serviceText;
    if (textServices.size() == 0) {
        serviceText = "Beaming Device";
    } else {
        serviceText = TextUtils.join(",", textServices);
    }
    holder.icon.setImageResource(imgResource);
    holder.text1.setText(device.getFriendlyName());
    holder.text2.setText(serviceText);
    return convertView;
}
Also used : NetcastTVService(com.connectsdk.service.NetcastTVService) ConnectableDevice(com.connectsdk.device.ConnectableDevice) AirPlayService(com.connectsdk.service.AirPlayService) CastService(com.connectsdk.service.CastService) DeviceService(com.connectsdk.service.DeviceService) ArrayList(java.util.ArrayList) WebOSTVService(com.connectsdk.service.WebOSTVService) DLNAService(com.connectsdk.service.DLNAService) RokuService(com.connectsdk.service.RokuService)

Example 2 with ConnectableDevice

use of com.connectsdk.device.ConnectableDevice in project butter-android by butterproject.

the class NetcastTVService method getDIALService.

public DIALService getDIALService() {
    if (dialService == null) {
        DiscoveryManager discoveryManager = DiscoveryManager.getInstance();
        ConnectableDevice device = discoveryManager.getAllDevices().get(serviceDescription.getIpAddress());
        if (device != null) {
            DIALService foundService = null;
            for (DeviceService service : device.getServices()) {
                if (DIALService.class.isAssignableFrom(service.getClass())) {
                    foundService = (DIALService) service;
                    break;
                }
            }
            dialService = foundService;
        }
    }
    return dialService;
}
Also used : ConnectableDevice(com.connectsdk.device.ConnectableDevice) DiscoveryManager(com.connectsdk.discovery.DiscoveryManager)

Example 3 with ConnectableDevice

use of com.connectsdk.device.ConnectableDevice in project butter-android by butterproject.

the class WebOSTVService method getDLNAService.

private DeviceService getDLNAService() {
    Map<String, ConnectableDevice> allDevices = DiscoveryManager.getInstance().getAllDevices();
    ConnectableDevice device = null;
    DeviceService service = null;
    if (allDevices != null && allDevices.size() > 0)
        device = allDevices.get(this.serviceDescription.getIpAddress());
    if (device != null)
        service = device.getServiceByName("DLNA");
    return service;
}
Also used : ConnectableDevice(com.connectsdk.device.ConnectableDevice)

Example 4 with ConnectableDevice

use of com.connectsdk.device.ConnectableDevice in project butter-android by butterproject.

the class BeamPlayerPresenterImpl method prepareBeamUi.

private void prepareBeamUi() {
    try {
        ConnectableDevice connectedDevice = beamManager.getConnectedDevice();
        if (!connectedDevice.hasCapability(MediaControl.Position) || !connectedDevice.hasCapability(MediaControl.Seek) || !connectedDevice.hasCapability(MediaControl.Duration)) {
            hasSeekControl = false;
            view.hideSeekBar();
        }
        if (!connectedDevice.hasCapability(VolumeControl.Volume_Get) || !connectedDevice.hasCapability(VolumeControl.Volume_Set) || !connectedDevice.hasCapability(VolumeControl.Volume_Subscribe)) {
            hasVolumeControl = false;
            view.disableVolumePanel();
        }
        if (!connectedDevice.hasCapability(MediaControl.Pause)) {
            view.disablePlayButton();
        }
    } catch (Exception e) {
        // TODO: 3/25/17 This should be handled properly
        view.showErrorMessage(R.string.unknown_error);
        view.closeScreen();
    }
}
Also used : ConnectableDevice(com.connectsdk.device.ConnectableDevice)

Example 5 with ConnectableDevice

use of com.connectsdk.device.ConnectableDevice in project butter-android by butterproject.

the class NetcastTVService method getDLNAService.

public DLNAService getDLNAService() {
    if (dlnaService == null) {
        DiscoveryManager discoveryManager = DiscoveryManager.getInstance();
        ConnectableDevice device = discoveryManager.getAllDevices().get(serviceDescription.getIpAddress());
        if (device != null) {
            DLNAService foundService = null;
            for (DeviceService service : device.getServices()) {
                if (DLNAService.class.isAssignableFrom(service.getClass())) {
                    foundService = (DLNAService) service;
                    break;
                }
            }
            dlnaService = foundService;
        }
    }
    return dlnaService;
}
Also used : ConnectableDevice(com.connectsdk.device.ConnectableDevice) DiscoveryManager(com.connectsdk.discovery.DiscoveryManager)

Aggregations

ConnectableDevice (com.connectsdk.device.ConnectableDevice)10 DiscoveryManager (com.connectsdk.discovery.DiscoveryManager)3 AlertDialog (android.app.AlertDialog)1 Dialog (android.app.Dialog)1 Bundle (android.os.Bundle)1 FragmentManager (android.support.v4.app.FragmentManager)1 R (butter.droid.R)1 BeamDeviceAdapter (butter.droid.base.manager.internal.beaming.BeamDeviceAdapter)1 BeamManager (butter.droid.base.manager.internal.beaming.BeamManager)1 AirPlayService (com.connectsdk.service.AirPlayService)1 CastService (com.connectsdk.service.CastService)1 DLNAService (com.connectsdk.service.DLNAService)1 DeviceService (com.connectsdk.service.DeviceService)1 NetcastTVService (com.connectsdk.service.NetcastTVService)1 RokuService (com.connectsdk.service.RokuService)1 WebOSTVService (com.connectsdk.service.WebOSTVService)1 DaggerAppCompatDialogFragment (dagger.android.support.DaggerAppCompatDialogFragment)1 ArrayList (java.util.ArrayList)1 Inject (javax.inject.Inject)1