Search in sources :

Example 1 with ControlPoint

use of org.fourthline.cling.controlpoint.ControlPoint in project BeyondUPnP by kevinshine.

the class PlaybackCommand method stop.

public static void stop() {
    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 Stop(avtService) {

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

            @Override
            public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) {
                Log.e(TAG, "Stop failed");
            }
        });
    }
}
Also used : 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)

Example 2 with ControlPoint

use of org.fourthline.cling.controlpoint.ControlPoint in project BeyondUPnP by kevinshine.

the class PlaybackCommand method getMediaInfo.

public static void getMediaInfo(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 GetMediaInfo(avtService) {

            @Override
            public void received(ActionInvocation invocation, MediaInfo mediaInfo) {
                Message msg = Message.obtain(handler, NowplayingFragment.GET_MEDIA_INFO_ACTION);
                msg.obj = mediaInfo;
                msg.sendToTarget();
            }

            @Override
            public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
                Log.e(TAG, "GetMediaInfo failed");
            }
        });
    }
}
Also used : GetMediaInfo(org.fourthline.cling.support.avtransport.callback.GetMediaInfo) MediaInfo(org.fourthline.cling.support.model.MediaInfo) GetMediaInfo(org.fourthline.cling.support.avtransport.callback.GetMediaInfo) 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)

Example 3 with ControlPoint

use of org.fourthline.cling.controlpoint.ControlPoint 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 4 with ControlPoint

use of org.fourthline.cling.controlpoint.ControlPoint in project BeyondUPnP by kevinshine.

the class PlaybackCommand method getTransportInfo.

public static void getTransportInfo(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 GetTransportInfo(avtService) {

            @Override
            public void received(ActionInvocation invocation, TransportInfo transportInfo) {
                TransportState ts = transportInfo.getCurrentTransportState();
                Log.i(TAG, "TransportState:" + ts.getValue());
                if (TransportState.PLAYING == ts) {
                    handler.sendEmptyMessage(NowplayingFragment.PLAY_ACTION);
                } else if (TransportState.PAUSED_PLAYBACK == ts) {
                    handler.sendEmptyMessage(NowplayingFragment.PAUSE_ACTION);
                } else if (TransportState.STOPPED == ts) {
                    handler.sendEmptyMessage(NowplayingFragment.STOP_ACTION);
                }
            }

            @Override
            public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
                Log.e(TAG, "GetTransportInfo failed");
            }
        });
    }
}
Also used : GetTransportInfo(org.fourthline.cling.support.avtransport.callback.GetTransportInfo) TransportInfo(org.fourthline.cling.support.model.TransportInfo) 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) GetTransportInfo(org.fourthline.cling.support.avtransport.callback.GetTransportInfo) ControlPoint(org.fourthline.cling.controlpoint.ControlPoint) TransportState(org.fourthline.cling.support.model.TransportState)

Example 5 with ControlPoint

use of org.fourthline.cling.controlpoint.ControlPoint 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)10 ActionInvocation (org.fourthline.cling.model.action.ActionInvocation)10 UpnpResponse (org.fourthline.cling.model.message.UpnpResponse)10 Device (org.fourthline.cling.model.meta.Device)10 Service (org.fourthline.cling.model.meta.Service)10 Message (android.os.Message)3 Play (org.fourthline.cling.support.avtransport.callback.Play)2 Stop (org.fourthline.cling.support.avtransport.callback.Stop)2 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 Pause (org.fourthline.cling.support.avtransport.callback.Pause)1 Seek (org.fourthline.cling.support.avtransport.callback.Seek)1 SetAVTransportURI (org.fourthline.cling.support.avtransport.callback.SetAVTransportURI)1 MediaInfo (org.fourthline.cling.support.model.MediaInfo)1 PositionInfo (org.fourthline.cling.support.model.PositionInfo)1 TransportInfo (org.fourthline.cling.support.model.TransportInfo)1 TransportState (org.fourthline.cling.support.model.TransportState)1 GetVolume (org.fourthline.cling.support.renderingcontrol.callback.GetVolume)1 SetVolume (org.fourthline.cling.support.renderingcontrol.callback.SetVolume)1