use of com.google.android.gms.common.images.WebImage in project HybridMediaPlayer by mkaflowski.
the class ExoMediaPlayer method buildMediaQueueItem.
private MediaQueueItem buildMediaQueueItem(String url, MediaSourceInfo mediaSourceInfo, int position) {
if (mediaSourceInfo == null)
mediaSourceInfo = MediaSourceInfo.PLACEHOLDER;
MediaMetadata movieMetadata = new MediaMetadata(mediaSourceInfo.isVideo() ? MediaMetadata.MEDIA_TYPE_MOVIE : MediaMetadata.MEDIA_TYPE_MUSIC_TRACK);
movieMetadata.putString(MediaMetadata.KEY_TITLE, mediaSourceInfo.getTitle());
movieMetadata.putString(MediaMetadata.KEY_ALBUM_ARTIST, mediaSourceInfo.getAuthor());
movieMetadata.putInt(MediaMetadata.KEY_TRACK_NUMBER, position);
movieMetadata.addImage(new WebImage(Uri.parse(mediaSourceInfo.getImageUrl())));
MediaInfo mediaInfo = new MediaInfo.Builder(url).setStreamType(MediaInfo.STREAM_TYPE_BUFFERED).setContentType(mediaSourceInfo.isVideo() ? MimeTypes.VIDEO_UNKNOWN : MimeTypes.AUDIO_UNKNOWN).setMetadata(movieMetadata).build();
return new MediaQueueItem.Builder(mediaInfo).build();
}
use of com.google.android.gms.common.images.WebImage in project Timber by naman14.
the class TimberCastHelper method startCasting.
public static void startCasting(CastSession castSession, Song song) {
String ipAddress = TimberUtils.getIPAddress(true);
URL baseUrl;
try {
baseUrl = new URL("http", ipAddress, Constants.CAST_SERVER_PORT, "");
} catch (MalformedURLException e) {
e.printStackTrace();
return;
}
String songUrl = baseUrl.toString() + "/song?id=" + song.id;
String albumArtUrl = baseUrl.toString() + "/albumart?id=" + song.albumId;
MediaMetadata musicMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK);
musicMetadata.putString(MediaMetadata.KEY_TITLE, song.title);
musicMetadata.putString(MediaMetadata.KEY_ARTIST, song.artistName);
musicMetadata.putString(MediaMetadata.KEY_ALBUM_TITLE, song.albumName);
musicMetadata.putInt(MediaMetadata.KEY_TRACK_NUMBER, song.trackNumber);
musicMetadata.addImage(new WebImage(Uri.parse(albumArtUrl)));
try {
MediaInfo mediaInfo = new MediaInfo.Builder(songUrl).setStreamType(MediaInfo.STREAM_TYPE_BUFFERED).setContentType("audio/mpeg").setMetadata(musicMetadata).setStreamDuration(song.duration).build();
RemoteMediaClient remoteMediaClient = castSession.getRemoteMediaClient();
remoteMediaClient.load(mediaInfo, true, 0);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.google.android.gms.common.images.WebImage in project AntennaPod by AntennaPod.
the class MediaInfoCreator method from.
public static MediaInfo from(RemoteMedia media) {
MediaMetadata metadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_GENERIC);
metadata.putString(MediaMetadata.KEY_TITLE, media.getEpisodeTitle());
metadata.putString(MediaMetadata.KEY_SUBTITLE, media.getFeedTitle());
if (!TextUtils.isEmpty(media.getImageLocation())) {
metadata.addImage(new WebImage(Uri.parse(media.getImageLocation())));
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(media.getPubDate());
metadata.putDate(MediaMetadata.KEY_RELEASE_DATE, calendar);
if (!TextUtils.isEmpty(media.getFeedAuthor())) {
metadata.putString(MediaMetadata.KEY_ARTIST, media.getFeedAuthor());
}
if (!TextUtils.isEmpty(media.getFeedUrl())) {
metadata.putString(CastUtils.KEY_FEED_URL, media.getFeedUrl());
}
if (!TextUtils.isEmpty(media.getFeedLink())) {
metadata.putString(CastUtils.KEY_FEED_WEBSITE, media.getFeedLink());
}
if (!TextUtils.isEmpty(media.getEpisodeIdentifier())) {
metadata.putString(CastUtils.KEY_EPISODE_IDENTIFIER, media.getEpisodeIdentifier());
} else {
metadata.putString(CastUtils.KEY_EPISODE_IDENTIFIER, media.getDownloadUrl());
}
if (!TextUtils.isEmpty(media.getEpisodeLink())) {
metadata.putString(CastUtils.KEY_EPISODE_LINK, media.getEpisodeLink());
}
String notes = media.getNotes();
if (notes != null) {
metadata.putString(CastUtils.KEY_EPISODE_NOTES, notes);
}
// Default id value
metadata.putInt(CastUtils.KEY_MEDIA_ID, 0);
metadata.putInt(CastUtils.KEY_FORMAT_VERSION, CastUtils.FORMAT_VERSION_VALUE);
metadata.putString(CastUtils.KEY_STREAM_URL, media.getStreamUrl());
MediaInfo.Builder builder = new MediaInfo.Builder(media.getDownloadUrl()).setContentType(media.getMimeType()).setStreamType(MediaInfo.STREAM_TYPE_BUFFERED).setMetadata(metadata);
if (media.getDuration() > 0) {
builder.setStreamDuration(media.getDuration());
}
return builder.build();
}
use of com.google.android.gms.common.images.WebImage in project AntennaPod by AntennaPod.
the class CastUtils method makeRemoteMedia.
/**
* Converts {@link MediaInfo} objects into the appropriate implementation of {@link Playable}.
* @return {@link Playable} object in a format proper for casting.
*/
public static Playable makeRemoteMedia(MediaInfo media) {
MediaMetadata metadata = media.getMetadata();
int version = metadata.getInt(KEY_FORMAT_VERSION);
if (version <= 0 || version > MAX_VERSION_FORWARD_COMPATIBILITY) {
Log.w(TAG, "MediaInfo object obtained from the cast device is not compatible with this" + "version of AntennaPod CastUtils, curVer=" + FORMAT_VERSION_VALUE + ", object version=" + version);
return null;
}
List<WebImage> imageList = metadata.getImages();
String imageUrl = null;
if (!imageList.isEmpty()) {
imageUrl = imageList.get(0).getUrl().toString();
}
String notes = metadata.getString(KEY_EPISODE_NOTES);
RemoteMedia result = new RemoteMedia(media.getContentId(), metadata.getString(KEY_EPISODE_IDENTIFIER), metadata.getString(KEY_FEED_URL), metadata.getString(MediaMetadata.KEY_SUBTITLE), metadata.getString(MediaMetadata.KEY_TITLE), metadata.getString(KEY_EPISODE_LINK), metadata.getString(MediaMetadata.KEY_ARTIST), imageUrl, metadata.getString(KEY_FEED_WEBSITE), media.getContentType(), metadata.getDate(MediaMetadata.KEY_RELEASE_DATE).getTime(), notes);
if (result.getDuration() == 0 && media.getStreamDuration() > 0) {
result.setDuration((int) media.getStreamDuration());
}
return result;
}
Aggregations