Search in sources :

Example 6 with ControlPoint

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

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

Example 8 with ControlPoint

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

the class PlaybackCommand method pause.

public static void pause() {
    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 Pause(avtService) {

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

            @Override
            public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) {
                Log.e(TAG, "Pause failed");
            }
        });
    }
}
Also used : Pause(org.fourthline.cling.support.avtransport.callback.Pause) 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 9 with ControlPoint

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

the class PlaybackCommand method seek.

/**
     * Seek
     * seek完成后通过handler重新启动position同步线程
     *
     * @param relativeTimeTarget 要seek到的值,该值为已播放的相对时间如:01:15:03
     * @param handler
     */
public static void seek(String relativeTimeTarget, 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 Seek(avtService, relativeTimeTarget) {

            @Override
            public void success(ActionInvocation invocation) {
                Log.i(TAG, "Seek success.");
                //Delay 1 second to synchronize remote device rel_time and SeekBar progress value.
                handler.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        handler.sendEmptyMessage(NowplayingFragment.RESUME_SEEKBAR_ACTION);
                    }
                }, 1000);
            }

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

Example 10 with ControlPoint

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

the class PlaybackCommand method setVolume.

public static void setVolume(int newVolume) {
    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 SetVolume(rcService, newVolume) {

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

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