Search in sources :

Example 1 with GetTransportInfo

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

Aggregations

ControlPoint (org.fourthline.cling.controlpoint.ControlPoint)1 ActionInvocation (org.fourthline.cling.model.action.ActionInvocation)1 UpnpResponse (org.fourthline.cling.model.message.UpnpResponse)1 Device (org.fourthline.cling.model.meta.Device)1 Service (org.fourthline.cling.model.meta.Service)1 GetTransportInfo (org.fourthline.cling.support.avtransport.callback.GetTransportInfo)1 TransportInfo (org.fourthline.cling.support.model.TransportInfo)1 TransportState (org.fourthline.cling.support.model.TransportState)1