Search in sources :

Example 1 with Play

use of org.fourthline.cling.support.avtransport.callback.Play in project BeyondUPnP by kevinshine.

the class PlaybackCommand method playNewItem.

public static void playNewItem(final String uri, final String metadata) {
    Device device = SystemManager.getInstance().getSelectedDevice();
    //Check selected device
    if (device == null)
        return;
    final Service avtService = device.findService(SystemManager.AV_TRANSPORT_SERVICE);
    if (avtService != null) {
        final ControlPoint cp = SystemManager.getInstance().getControlPoint();
        cp.execute(new Stop(avtService) {

            @Override
            public void success(ActionInvocation invocation) {
                cp.execute(new SetAVTransportURI(avtService, uri, metadata) {

                    @Override
                    public void success(ActionInvocation invocation) {
                        //Second,Set Play command.
                        cp.execute(new Play(avtService) {

                            @Override
                            public void success(ActionInvocation invocation) {
                                Log.i(TAG, "PlayNewItem success:" + uri);
                            }

                            @Override
                            public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) {
                                Log.e(TAG, "playNewItem failed");
                            }
                        });
                    }

                    @Override
                    public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
                    }
                });
            }

            @Override
            public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
            }
        });
    }
}
Also used : Play(org.fourthline.cling.support.avtransport.callback.Play) UpnpResponse(org.fourthline.cling.model.message.UpnpResponse) Stop(org.fourthline.cling.support.avtransport.callback.Stop) 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) SetAVTransportURI(org.fourthline.cling.support.avtransport.callback.SetAVTransportURI)

Example 2 with Play

use of org.fourthline.cling.support.avtransport.callback.Play 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)

Aggregations

ControlPoint (org.fourthline.cling.controlpoint.ControlPoint)2 ActionInvocation (org.fourthline.cling.model.action.ActionInvocation)2 UpnpResponse (org.fourthline.cling.model.message.UpnpResponse)2 Device (org.fourthline.cling.model.meta.Device)2 Service (org.fourthline.cling.model.meta.Service)2 Play (org.fourthline.cling.support.avtransport.callback.Play)2 SetAVTransportURI (org.fourthline.cling.support.avtransport.callback.SetAVTransportURI)1 Stop (org.fourthline.cling.support.avtransport.callback.Stop)1