Improve behaviour of getOnlineState for XloveCam
This commit is contained in:
parent
1f9dcf1ca4
commit
341846e94e
|
@ -45,7 +45,7 @@ public class XloveCamModel extends AbstractModel {
|
|||
|
||||
@Override
|
||||
public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException {
|
||||
if (ignoreCache || onlineState == UNKNOWN) {
|
||||
if (ignoreCache) {
|
||||
String body = getModelPage();
|
||||
Matcher m = HLS_PLAYLIST_PATTERN.matcher(body);
|
||||
online = m.find();
|
||||
|
@ -54,6 +54,23 @@ public class XloveCamModel extends AbstractModel {
|
|||
return online;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
|
||||
if (failFast && onlineState != UNKNOWN) {
|
||||
return onlineState;
|
||||
} else {
|
||||
try {
|
||||
onlineState = isOnline(true) ? ONLINE : OFFLINE;
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
onlineState = OFFLINE;
|
||||
} catch (IOException | ExecutionException e) {
|
||||
onlineState = OFFLINE;
|
||||
}
|
||||
return onlineState;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StreamSource> getStreamSources() throws IOException, ExecutionException, ParseException, PlaylistException, JAXBException {
|
||||
MasterPlaylist masterPlaylist = getMasterPlaylist();
|
||||
|
|
Loading…
Reference in New Issue