Search in sources :

Example 1 with MediaPlayerInfo

use of com.amazon.whisperplay.fling.media.service.MediaPlayerInfo in project butter-android by butterproject.

the class FireTVService method getMediaInfo.

/**
 * Get MediaInfo available only during playback otherwise returns an error
 * @param listener
 */
@Override
public void getMediaInfo(final MediaInfoListener listener) {
    final String error = "Error getting media info";
    RemoteMediaPlayer.AsyncFuture<MediaPlayerInfo> asyncFuture = null;
    try {
        asyncFuture = remoteMediaPlayer.getMediaInfo();
        handleAsyncFutureWithConversion(listener, asyncFuture, new ConvertResult<MediaInfo, MediaPlayerInfo>() {

            @Override
            public MediaInfo convert(MediaPlayerInfo data) throws JSONException {
                JSONObject metaJson = null;
                metaJson = new JSONObject(data.getMetadata());
                List<ImageInfo> images = null;
                if (metaJson.has(META_ICON_IMAGE)) {
                    images = new ArrayList<ImageInfo>();
                    images.add(new ImageInfo(metaJson.getString(META_ICON_IMAGE)));
                }
                MediaInfo mediaInfo = new MediaInfo(data.getSource(), metaJson.getString(META_MIME_TYPE), metaJson.getString(META_TITLE), metaJson.getString(META_DESCRIPTION), images);
                return mediaInfo;
            }
        }, error);
    } catch (Exception e) {
        Util.postError(listener, new FireTVServiceError(error));
        return;
    }
}
Also used : RemoteMediaPlayer(com.amazon.whisperplay.fling.media.controller.RemoteMediaPlayer) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) JSONException(org.json.JSONException) ExecutionException(java.util.concurrent.ExecutionException) MediaInfo(com.connectsdk.core.MediaInfo) JSONObject(org.json.JSONObject) MediaPlayerInfo(com.amazon.whisperplay.fling.media.service.MediaPlayerInfo) FireTVServiceError(com.connectsdk.service.command.FireTVServiceError) ArrayList(java.util.ArrayList) List(java.util.List) ImageInfo(com.connectsdk.core.ImageInfo)

Aggregations

RemoteMediaPlayer (com.amazon.whisperplay.fling.media.controller.RemoteMediaPlayer)1 MediaPlayerInfo (com.amazon.whisperplay.fling.media.service.MediaPlayerInfo)1 ImageInfo (com.connectsdk.core.ImageInfo)1 MediaInfo (com.connectsdk.core.MediaInfo)1 FireTVServiceError (com.connectsdk.service.command.FireTVServiceError)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1