use of su.litvak.chromecast.api.v2.MediaStatus in project UniversalMediaServer by UniversalMediaServer.
the class ChromecastPlayer method startPoll.
public void startPoll() {
Runnable r = new Runnable() {
@Override
public void run() {
for (; ; ) {
try {
Thread.sleep(1000);
Status s1 = api.getStatus();
if (s1 == null || !s1.isAppRunning(MediaPlayer)) {
continue;
}
MediaStatus status = api.getMediaStatus();
if (status == null) {
continue;
}
state.playback = translateState(status.playerState);
Media m = status.media;
if (m != null) {
if (m.url != null) {
state.uri = status.media.url;
}
if (m.duration != null) {
state.duration = StringUtil.convertTimeToString(status.media.duration, "%02d:%02d:%02.0f");
}
}
state.position = StringUtil.convertTimeToString(status.currentTime, "%02d:%02d:%02.0f");
if (status.volume != null) {
state.volume = status.volume.level.intValue();
state.mute = status.volume.muted;
}
alert();
} catch (InterruptedException | IOException e) {
LOGGER.debug("Bad chromecast mediastate " + e);
}
}
}
};
poller = new Thread(r);
poller.start();
}
Aggregations