Search in sources :

Example 6 with MediaInfo

use of com.connectsdk.core.MediaInfo 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);
                }
            }
        }
    }
}
Also used : MediaInfo(com.connectsdk.core.MediaInfo) PlayStateStatus(com.connectsdk.service.capability.MediaControl.PlayStateStatus) JSONObject(org.json.JSONObject) ResponseListener(com.connectsdk.service.capability.listeners.ResponseListener)

Aggregations

MediaInfo (com.connectsdk.core.MediaInfo)6 ImageInfo (com.connectsdk.core.ImageInfo)4 ServiceCommandError (com.connectsdk.service.command.ServiceCommandError)3 ArrayList (java.util.ArrayList)2 JSONObject (org.json.JSONObject)2 SubtitleWrapper (butter.droid.base.providers.subs.model.SubtitleWrapper)1 RemoteMediaPlayer (com.amazon.whisperplay.fling.media.controller.RemoteMediaPlayer)1 MediaPlayerInfo (com.amazon.whisperplay.fling.media.service.MediaPlayerInfo)1 PlayStateStatus (com.connectsdk.service.capability.MediaControl.PlayStateStatus)1 MediaPlayer (com.connectsdk.service.capability.MediaPlayer)1 ResponseListener (com.connectsdk.service.capability.listeners.ResponseListener)1 FireTVServiceError (com.connectsdk.service.command.FireTVServiceError)1 MediaMetadata (com.google.android.gms.cast.MediaMetadata)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 JSONException (org.json.JSONException)1