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;
}
}
Aggregations