Java Code Examples for org.fourthline.cling.support.model.SeekMode#valueOrExceptionOf()

The following examples show how to use org.fourthline.cling.support.model.SeekMode#valueOrExceptionOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
    public void seek(UnsignedIntegerFourBytes instanceId, String unit, String target) throws AVTransportException {
        final ZxtMediaPlayer player = getInstance(instanceId);
        SeekMode seekMode;
        try {
            seekMode = SeekMode.valueOrExceptionOf(unit);

            if (!seekMode.equals(SeekMode.REL_TIME)) {
                throw new IllegalArgumentException();
            }

//            final ClockTime ct = ClockTime.fromSeconds(ModelUtil.fromTimeString(target));
            int pos = (int) (Utils.getRealTime(target) * 1000);
            Log.i(TAG,"### " + unit + " target: "+ target +"  pos: " + pos);

//            if (getInstance(instanceId).getCurrentTransportInfo().getCurrentTransportState()
//                    .equals(TransportState.PLAYING)) {
//                getInstance(instanceId).pause();
//                getInstance(instanceId).seek(pos);
//                getInstance(instanceId).play();
//            } else if (getInstance(instanceId).getCurrentTransportInfo().getCurrentTransportState()
//                    .equals(TransportState.PAUSED_PLAYBACK)) {
                getInstance(instanceId).seek(pos);
//            }

        } catch (IllegalArgumentException ex) {
            throw new AVTransportException(
                    AVTransportErrorCode.SEEKMODE_NOT_SUPPORTED, "Unsupported seek mode: " + unit
            );
        }
    }
 
Example 2
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
    public void seek(UnsignedIntegerFourBytes instanceId, String unit, String target) throws AVTransportException {
        final ZxtMediaPlayer player = getInstance(instanceId);
        SeekMode seekMode;
        try {
            seekMode = SeekMode.valueOrExceptionOf(unit);

            if (!seekMode.equals(SeekMode.REL_TIME)) {
                throw new IllegalArgumentException();
            }

//            final ClockTime ct = ClockTime.fromSeconds(ModelUtil.fromTimeString(target));
            int pos = (int) (Utils.getRealTime(target) * 1000);
            Log.i(TAG,"### " + unit + " target: "+ target +"  pos: " + pos);

//            if (getInstance(instanceId).getCurrentTransportInfo().getCurrentTransportState()
//                    .equals(TransportState.PLAYING)) {
//                getInstance(instanceId).pause();
//                getInstance(instanceId).seek(pos);
//                getInstance(instanceId).play();
//            } else if (getInstance(instanceId).getCurrentTransportInfo().getCurrentTransportState()
//                    .equals(TransportState.PAUSED_PLAYBACK)) {
                getInstance(instanceId).seek(pos);
//            }

        } catch (IllegalArgumentException ex) {
            throw new AVTransportException(
                    AVTransportErrorCode.SEEKMODE_NOT_SUPPORTED, "Unsupported seek mode: " + unit
            );
        }
    }