Search in sources :

Example 6 with Device

use of org.fourthline.cling.model.meta.Device in project BeyondUPnP by kevinshine.

the class PlaybackCommand method play.

public static void play() {
    Device device = SystemManager.getInstance().getSelectedDevice();
    //Check selected device
    if (device == null)
        return;
    Service avtService = device.findService(SystemManager.AV_TRANSPORT_SERVICE);
    if (avtService != null) {
        ControlPoint cp = SystemManager.getInstance().getControlPoint();
        cp.execute(new Play(avtService) {

            @Override
            public void success(ActionInvocation invocation) {
                Log.i(TAG, "Play success.");
            }

            @Override
            public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) {
                Log.e(TAG, "Play failed");
            }
        });
    }
}
Also used : Play(org.fourthline.cling.support.avtransport.callback.Play) UpnpResponse(org.fourthline.cling.model.message.UpnpResponse) Device(org.fourthline.cling.model.meta.Device) ActionInvocation(org.fourthline.cling.model.action.ActionInvocation) Service(org.fourthline.cling.model.meta.Service) ControlPoint(org.fourthline.cling.controlpoint.ControlPoint)

Example 7 with Device

use of org.fourthline.cling.model.meta.Device in project libresonic by Libresonic.

the class ClingRouter method findConnectionService.

/**
     * Returns the UPnP service used for port mapping.
     */
private static Service findConnectionService(UpnpService upnpService) {
    class ConnectionServiceDiscoverer extends PortMappingListener {

        ConnectionServiceDiscoverer() {
            super(new PortMapping[0]);
        }

        @Override
        public Service discoverConnectionService(Device device) {
            return super.discoverConnectionService(device);
        }
    }
    ConnectionServiceDiscoverer discoverer = new ConnectionServiceDiscoverer();
    Collection<Device> devices = upnpService.getRegistry().getDevices();
    for (Device device : devices) {
        Service service = discoverer.discoverConnectionService(device);
        if (service != null) {
            return service;
        }
    }
    return null;
}
Also used : Device(org.fourthline.cling.model.meta.Device) UPnPService(org.libresonic.player.service.UPnPService) UpnpService(org.fourthline.cling.UpnpService) Service(org.fourthline.cling.model.meta.Service) PortMapping(org.fourthline.cling.support.model.PortMapping) PortMappingListener(org.fourthline.cling.support.igd.PortMappingListener)

Example 8 with Device

use of org.fourthline.cling.model.meta.Device in project BeyondUPnP by kevinshine.

the class LibraryFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_library, container, false);
    //Init content directory device ListView
    mCddListView = (ListView) view.findViewById(R.id.content_directory_devices);
    mArrayAdapter = new LibraryAdapter(getActivity());
    mCddListView.setAdapter(mArrayAdapter);
    mCddListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Device device = mArrayAdapter.getItem(position);
            String identifierString = device.getIdentity().getUdn().getIdentifierString();
            String objectId = "0";
            //Create new activity
            Intent intent = new Intent(getActivity(), ContentContainerActivity.class);
            intent.putExtra(ContentContainerActivity.OBJECT_ID_TAG, objectId);
            intent.putExtra(ContentContainerActivity.IDENTIFIER_STRING_TAG, identifierString);
            intent.putExtra(ContentContainerActivity.CONTENT_CONTAINER_TITLE, device.getDetails().getFriendlyName());
            getActivity().startActivity(intent);
        }
    });
    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout_library);
    mSwipeRefreshLayout.setOnRefreshListener(onRefreshListener);
    //SwipeRefresh style.
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright);
    return view;
}
Also used : Device(org.fourthline.cling.model.meta.Device) AdapterView(android.widget.AdapterView) Intent(android.content.Intent) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 9 with Device

use of org.fourthline.cling.model.meta.Device in project BeyondUPnP by kevinshine.

the class PlaybackCommand method getPositionInfo.

public static void getPositionInfo(final Handler handler) {
    Device device = SystemManager.getInstance().getSelectedDevice();
    //Check selected device
    if (device == null)
        return;
    Service avtService = device.findService(SystemManager.AV_TRANSPORT_SERVICE);
    if (avtService != null) {
        ControlPoint cp = SystemManager.getInstance().getControlPoint();
        cp.execute(new GetPositionInfo(avtService) {

            @Override
            public void received(ActionInvocation invocation, PositionInfo positionInfo) {
                Message msg = Message.obtain(handler, NowplayingFragment.GET_POSITION_INFO_ACTION);
                msg.obj = positionInfo;
                msg.sendToTarget();
            }

            @Override
            public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
                Log.e(TAG, "GetPositionInfo failed");
            }
        });
    }
}
Also used : Message(android.os.Message) UpnpResponse(org.fourthline.cling.model.message.UpnpResponse) Device(org.fourthline.cling.model.meta.Device) ActionInvocation(org.fourthline.cling.model.action.ActionInvocation) Service(org.fourthline.cling.model.meta.Service) GetPositionInfo(org.fourthline.cling.support.avtransport.callback.GetPositionInfo) PositionInfo(org.fourthline.cling.support.model.PositionInfo) ControlPoint(org.fourthline.cling.controlpoint.ControlPoint) GetPositionInfo(org.fourthline.cling.support.avtransport.callback.GetPositionInfo)

Example 10 with Device

use of org.fourthline.cling.model.meta.Device in project BeyondUPnP by kevinshine.

the class PlaybackCommand method getVolume.

public static void getVolume(final Handler handler) {
    Device device = SystemManager.getInstance().getSelectedDevice();
    //Check selected device
    if (device == null)
        return;
    Service rcService = device.findService(SystemManager.RENDERING_CONTROL_SERVICE);
    if (rcService != null) {
        ControlPoint cp = SystemManager.getInstance().getControlPoint();
        cp.execute(new GetVolume(rcService) {

            @Override
            public void received(ActionInvocation actionInvocation, int currentVolume) {
                //Send currentVolume to handler.
                Log.i(TAG, "GetVolume:" + currentVolume);
                Message msg = Message.obtain(handler, NowplayingFragment.GET_VOLUME_ACTION, currentVolume, 0);
                msg.sendToTarget();
            }

            @Override
            public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
                Log.e(TAG, "GetVolume failed");
            }
        });
    }
}
Also used : GetVolume(org.fourthline.cling.support.renderingcontrol.callback.GetVolume) Message(android.os.Message) UpnpResponse(org.fourthline.cling.model.message.UpnpResponse) Device(org.fourthline.cling.model.meta.Device) ActionInvocation(org.fourthline.cling.model.action.ActionInvocation) Service(org.fourthline.cling.model.meta.Service) ControlPoint(org.fourthline.cling.controlpoint.ControlPoint) ControlPoint(org.fourthline.cling.controlpoint.ControlPoint)

Aggregations

Device (org.fourthline.cling.model.meta.Device)13 Service (org.fourthline.cling.model.meta.Service)12 ActionInvocation (org.fourthline.cling.model.action.ActionInvocation)11 UpnpResponse (org.fourthline.cling.model.message.UpnpResponse)11 ControlPoint (org.fourthline.cling.controlpoint.ControlPoint)10 Message (android.os.Message)4 Play (org.fourthline.cling.support.avtransport.callback.Play)2 Stop (org.fourthline.cling.support.avtransport.callback.Stop)2 Intent (android.content.Intent)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 SystemManager (com.kevinshen.beyondupnp.core.SystemManager)1 UpnpService (org.fourthline.cling.UpnpService)1 UDN (org.fourthline.cling.model.types.UDN)1 GetMediaInfo (org.fourthline.cling.support.avtransport.callback.GetMediaInfo)1 GetPositionInfo (org.fourthline.cling.support.avtransport.callback.GetPositionInfo)1 GetTransportInfo (org.fourthline.cling.support.avtransport.callback.GetTransportInfo)1