URI uri;
try {
uri = new URI(currentURI);
} catch (Exception ex) {
throw new AVTransportException(
ErrorCode.INVALID_ARGS, "CurrentURI can not be null or malformed"
);
}
if (currentURI.startsWith("http:")) {
try {
HttpFetch.validate(URIUtil.toURL(uri));
} catch (IOException ex) {
throw new AVTransportException(AVTransportErrorCode.READ_ERROR, "Unable to read requested URI: " + uri);
}
} else {
throw new AVTransportException(ErrorCode.INVALID_ACTION, "Requested URI was not a network stream.");
}
// Instantiate a new player
try {
if (player != null) {
player.cleanup();
}
player = PlayerFactory.getPlayer(uri.toString());
} catch (PlayerException e) {
throw new AVTransportException(ErrorCode.HUMAN_INTERVENTION_REQUIRED, "Unable to start media player backend.");
}
// Build media info
String duration = ModelUtil.toTimeString(player.getDuration());
mediaInfo = new MediaInfo(currentURI, currentURIMetaData, null, duration, null);