use of com.connectsdk.service.capability.MediaControl.PlayStateStatus in project butter-android by butterproject.
the class DLNAHttpServer method handleEntry.
private void handleEntry(JSONObject entry) throws JSONException {
if (entry.has("TransportState")) {
String transportState = entry.getString("TransportState");
PlayStateStatus status = PlayStateStatus.convertTransportStateToPlayStateStatus(transportState);
for (URLServiceSubscription<?> sub : subscriptions) {
if (sub.getTarget().equalsIgnoreCase("playState")) {
for (int j = 0; j < sub.getListeners().size(); j++) {
@SuppressWarnings("unchecked") ResponseListener<Object> listener = (ResponseListener<Object>) sub.getListeners().get(j);
Util.postSuccess(listener, status);
}
}
}
}
if ((entry.has("Volume") && !entry.has("channel")) || (entry.has("Volume") && entry.getString("channel").equals("Master"))) {
int intVolume = entry.getInt("Volume");
float volume = (float) intVolume / 100;
for (URLServiceSubscription<?> sub : subscriptions) {
if (sub.getTarget().equalsIgnoreCase("volume")) {
for (int j = 0; j < sub.getListeners().size(); j++) {
@SuppressWarnings("unchecked") ResponseListener<Object> listener = (ResponseListener<Object>) sub.getListeners().get(j);
Util.postSuccess(listener, volume);
}
}
}
}
if ((entry.has("Mute") && !entry.has("channel")) || (entry.has("Mute") && entry.getString("channel").equals("Master"))) {
String muteStatus = entry.getString("Mute");
boolean mute;
try {
mute = (Integer.parseInt(muteStatus) == 1);
} catch (NumberFormatException e) {
mute = Boolean.parseBoolean(muteStatus);
}
for (URLServiceSubscription<?> sub : subscriptions) {
if (sub.getTarget().equalsIgnoreCase("mute")) {
for (int j = 0; j < sub.getListeners().size(); j++) {
@SuppressWarnings("unchecked") ResponseListener<Object> listener = (ResponseListener<Object>) sub.getListeners().get(j);
Util.postSuccess(listener, mute);
}
}
}
}
if (entry.has("CurrentTrackMetaData")) {
String trackMetaData = entry.getString("CurrentTrackMetaData");
MediaInfo info = DLNAMediaInfoParser.getMediaInfo(trackMetaData);
for (URLServiceSubscription<?> sub : subscriptions) {
if (sub.getTarget().equalsIgnoreCase("info")) {
for (int j = 0; j < sub.getListeners().size(); j++) {
@SuppressWarnings("unchecked") ResponseListener<Object> listener = (ResponseListener<Object>) sub.getListeners().get(j);
Util.postSuccess(listener, info);
}
}
}
}
}
Aggregations