org.fourthline.cling.support.avtransport.AVTransportException Java Examples

The following examples show how to use org.fourthline.cling.support.avtransport.AVTransportException. 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 DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void setPlayMode(UnsignedIntegerFourBytes instanceId, String newPlayMode) throws AVTransportException {
    AVTransport transport = findStateMachine(instanceId).getCurrentState().getTransport();
    try {
        transport.setTransportSettings(
                new TransportSettings(
                        PlayMode.valueOf(newPlayMode),
                        transport.getTransportSettings().getRecQualityMode()
                )
        );
    } catch (IllegalArgumentException ex) {
        throw new AVTransportException(
                AVTransportErrorCode.PLAYMODE_NOT_SUPPORTED, "Unsupported play mode: " + newPlayMode
        );
    }
}
 
Example #2
Source File: AVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected AVTransportStateMachine findStateMachine(UnsignedIntegerFourBytes instanceId, boolean createDefaultTransport) throws AVTransportException {
    synchronized (stateMachines) {
        long id = instanceId.getValue();
        AVTransportStateMachine stateMachine = stateMachines.get(id);
        if (stateMachine == null && id == 0 && createDefaultTransport) {
            log.fine("Creating default transport instance with ID '0'");
            stateMachine = createStateMachine(instanceId);
            stateMachines.put(id, stateMachine);
        } else if (stateMachine == null) {
            throw new AVTransportException(AVTransportErrorCode.INVALID_INSTANCE_ID);
        }
        log.fine("Found transport control with ID '" + id + "'");
        return stateMachine;
    }
}
 
Example #3
Source File: AVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void previous(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    try {
        findStateMachine(instanceId).previous();
    } catch (TransitionException ex) {
        throw new AVTransportException(AVTransportErrorCode.TRANSITION_NOT_AVAILABLE, ex.getMessage());
    }
}
 
Example #4
Source File: AVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void next(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    try {
        findStateMachine(instanceId).next();
    } catch (TransitionException ex) {
        throw new AVTransportException(AVTransportErrorCode.TRANSITION_NOT_AVAILABLE, ex.getMessage());
    }
}
 
Example #5
Source File: AVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void record(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    try {
        findStateMachine(instanceId).record();
    } catch (TransitionException ex) {
        throw new AVTransportException(AVTransportErrorCode.TRANSITION_NOT_AVAILABLE, ex.getMessage());
    }
}
 
Example #6
Source File: AVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void pause(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    try {
        findStateMachine(instanceId).pause();
    } catch (TransitionException ex) {
        throw new AVTransportException(AVTransportErrorCode.TRANSITION_NOT_AVAILABLE, ex.getMessage());
    }
}
 
Example #7
Source File: AVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void play(UnsignedIntegerFourBytes instanceId, String speed) throws AVTransportException {
    try {
        findStateMachine(instanceId).play(speed);
    } catch (TransitionException ex) {
        throw new AVTransportException(AVTransportErrorCode.TRANSITION_NOT_AVAILABLE, ex.getMessage());
    }
}
 
Example #8
Source File: AVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void stop(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    try {
        findStateMachine(instanceId).stop();
    } catch (TransitionException ex) {
        throw new AVTransportException(AVTransportErrorCode.TRANSITION_NOT_AVAILABLE, ex.getMessage());
    }
}
 
Example #9
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setNextAVTransportURI(UnsignedIntegerFourBytes instanceId,
                                  String nextURI,
                                  String nextURIMetaData) throws AVTransportException {
    log.info("### TODO: Not implemented: SetNextAVTransportURI");
    // Not implemented
}
 
Example #10
Source File: AVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void setPlayMode(UnsignedIntegerFourBytes instanceId, String newPlayMode) throws AVTransportException {
    AVTransport transport = findStateMachine(instanceId).getCurrentState().getTransport();
    try {
        transport.setTransportSettings(
                new TransportSettings(
                        PlayMode.valueOf(newPlayMode),
                        transport.getTransportSettings().getRecQualityMode()
                )
        );
    } catch (IllegalArgumentException ex) {
        throw new AVTransportException(
                AVTransportErrorCode.PLAYMODE_NOT_SUPPORTED, "Unsupported play mode: " + newPlayMode
        );
    }
}
 
Example #11
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
            );
        }
    }
 
Example #12
Source File: AVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected ZxtMediaPlayer getInstance(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    ZxtMediaPlayer player = getPlayers().get(instanceId);
    if (player == null) {
        throw new AVTransportException(AVTransportErrorCode.INVALID_INSTANCE_ID);
    }
    return player;
}
 
Example #13
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected ZxtMediaPlayer getInstance(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    ZxtMediaPlayer player = getPlayers().get(instanceId);
    if (player == null) {
        throw new AVTransportException(AVTransportErrorCode.INVALID_INSTANCE_ID);
    }
    return player;
}
 
Example #14
Source File: AVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void setRecordQualityMode(UnsignedIntegerFourBytes instanceId, String newRecordQualityMode) throws AVTransportException {
    AVTransport transport = findStateMachine(instanceId).getCurrentState().getTransport();
    try {
        transport.setTransportSettings(
                new TransportSettings(
                        transport.getTransportSettings().getPlayMode(),
                        RecordQualityMode.valueOrExceptionOf(newRecordQualityMode)
                )
        );
    } catch (IllegalArgumentException ex) {
        throw new AVTransportException(
                AVTransportErrorCode.RECORDQUALITYMODE_NOT_SUPPORTED, "Unsupported record quality mode: " + newRecordQualityMode
        );
    }
}
 
Example #15
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void setRecordQualityMode(UnsignedIntegerFourBytes instanceId, String newRecordQualityMode) throws AVTransportException {
    AVTransport transport = findStateMachine(instanceId).getCurrentState().getTransport();
    try {
        transport.setTransportSettings(
                new TransportSettings(
                        transport.getTransportSettings().getPlayMode(),
                        RecordQualityMode.valueOrExceptionOf(newRecordQualityMode)
                )
        );
    } catch (IllegalArgumentException ex) {
        throw new AVTransportException(
                AVTransportErrorCode.RECORDQUALITYMODE_NOT_SUPPORTED, "Unsupported record quality mode: " + newRecordQualityMode
        );
    }
}
 
Example #16
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void stop(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    try {
        findStateMachine(instanceId).stop();
    } catch (TransitionException ex) {
        throw new AVTransportException(AVTransportErrorCode.TRANSITION_NOT_AVAILABLE, ex.getMessage());
    }
}
 
Example #17
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void play(UnsignedIntegerFourBytes instanceId, String speed) throws AVTransportException {
    try {
        findStateMachine(instanceId).play(speed);
    } catch (TransitionException ex) {
        throw new AVTransportException(AVTransportErrorCode.TRANSITION_NOT_AVAILABLE, ex.getMessage());
    }
}
 
Example #18
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void pause(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    try {
        findStateMachine(instanceId).pause();
    } catch (TransitionException ex) {
        throw new AVTransportException(AVTransportErrorCode.TRANSITION_NOT_AVAILABLE, ex.getMessage());
    }
}
 
Example #19
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void record(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    try {
        findStateMachine(instanceId).record();
    } catch (TransitionException ex) {
        throw new AVTransportException(AVTransportErrorCode.TRANSITION_NOT_AVAILABLE, ex.getMessage());
    }
}
 
Example #20
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void next(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    try {
        findStateMachine(instanceId).next();
    } catch (TransitionException ex) {
        throw new AVTransportException(AVTransportErrorCode.TRANSITION_NOT_AVAILABLE, ex.getMessage());
    }
}
 
Example #21
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void previous(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    try {
        findStateMachine(instanceId).previous();
    } catch (TransitionException ex) {
        throw new AVTransportException(AVTransportErrorCode.TRANSITION_NOT_AVAILABLE, ex.getMessage());
    }
}
 
Example #22
Source File: AVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setNextAVTransportURI(UnsignedIntegerFourBytes instanceId,
                                  String nextURI,
                                  String nextURIMetaData) throws AVTransportException {
    log.info("### TODO: Not implemented: SetNextAVTransportURI");
    // Not implemented
}
 
Example #23
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected AVTransportStateMachine findStateMachine(UnsignedIntegerFourBytes instanceId, boolean createDefaultTransport) throws AVTransportException {
    synchronized (stateMachines) {
        long id = instanceId.getValue();
        AVTransportStateMachine stateMachine = stateMachines.get(id);
        if (stateMachine == null && id == 0 && createDefaultTransport) {
            log.fine("Creating default transport instance with ID '0'");
            stateMachine = createStateMachine(instanceId);
            stateMachines.put(id, stateMachine);
        } else if (stateMachine == null) {
            throw new AVTransportException(AVTransportErrorCode.INVALID_INSTANCE_ID);
        }
        log.fine("Found transport control with ID '" + id + "'");
        return stateMachine;
    }
}
 
Example #24
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 #25
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public PositionInfo getPositionInfo(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    return findStateMachine(instanceId).getCurrentState().getTransport().getPositionInfo();
}
 
Example #26
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void record(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    // Not implemented
    log.info("### TODO: Not implemented: Record");
}
 
Example #27
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setPlayMode(UnsignedIntegerFourBytes instanceId, String newPlayMode) throws AVTransportException {
    // Not implemented
    log.info("### TODO: Not implemented: SetPlayMode");
}
 
Example #28
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public TransportSettings getTransportSettings(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    return findStateMachine(instanceId).getCurrentState().getTransport().getTransportSettings();
}
 
Example #29
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public DeviceCapabilities getDeviceCapabilities(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    return findStateMachine(instanceId).getCurrentState().getTransport().getDeviceCapabilities();
}
 
Example #30
Source File: AVTransportService.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public MediaInfo getMediaInfo(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    return findStateMachine(instanceId).getCurrentState().getTransport().getMediaInfo();
}