MediaInfo createMediaInfo() { MediaMetadata mediaMetadata = new MediaMetadata(mediaType); if (!TextUtils.isEmpty(title)) mediaMetadata.putString(MediaMetadata.KEY_TITLE, title); if (!TextUtils.isEmpty(subtitle)) mediaMetadata.putString(MediaMetadata.KEY_SUBTITLE, subtitle); for (String imageUrl : imageUrls) { mediaMetadata.addImage(new WebImage(Uri.parse(imageUrl))); } return new MediaInfo.Builder(url) .setStreamType(streamType) .setContentType(contentType) .setStreamDuration(streamDuration) .setMetadata(mediaMetadata) .build(); }
@Override public WebImage onPickImage(MediaMetadata mediaMetadata, int type) { if ((mediaMetadata == null) || !mediaMetadata.hasImages()) { return null; } List<WebImage> images = mediaMetadata.getImages(); if (images.size() == 1) { return images.get(0); } else { if (type == ImagePicker.IMAGE_TYPE_MEDIA_ROUTE_CONTROLLER_DIALOG_BACKGROUND) { return images.get(0); } else { return images.get(1); } } }
@Override public void displayImage(String url, String mimeType, String title, String description, String iconSrc, LaunchListener listener) { MediaMetadata mMediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_PHOTO); mMediaMetadata.putString(MediaMetadata.KEY_TITLE, title); mMediaMetadata.putString(MediaMetadata.KEY_SUBTITLE, description); if (iconSrc != null) { Uri iconUri = Uri.parse(iconSrc); WebImage image = new WebImage(iconUri, 100, 100); mMediaMetadata.addImage(image); } com.google.android.gms.cast.MediaInfo mediaInformation = new com.google.android.gms.cast.MediaInfo.Builder(url) .setContentType(mimeType) .setStreamType(com.google.android.gms.cast.MediaInfo.STREAM_TYPE_NONE) .setMetadata(mMediaMetadata) .setStreamDuration(0) .setCustomData(null) .build(); playMedia(mediaInformation, applicationID, listener); }
private static MediaInfo buildMediaInfo(String title, String studio, String subTitle, int duration, String url, String mimeType, String imgUrl, String bigImageUrl, List<MediaTrack> tracks) { MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, studio); movieMetadata.putString(MediaMetadata.KEY_TITLE, title); movieMetadata.addImage(new WebImage(Uri.parse(imgUrl))); movieMetadata.addImage(new WebImage(Uri.parse(bigImageUrl))); JSONObject jsonObj = null; try { jsonObj = new JSONObject(); jsonObj.put(KEY_DESCRIPTION, subTitle); } catch (JSONException e) { Log.e(TAG, "Failed to add description to the json object", e); } return new MediaInfo.Builder(url) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setContentType(mimeType) .setMetadata(movieMetadata) .setMediaTracks(tracks) .setStreamDuration(duration * 1000) .setCustomData(jsonObj) .build(); }
public static void a(JSONObject paramJSONObject, List<WebImage> paramList) { JSONArray localJSONArray; if ((paramList != null) && (!paramList.isEmpty())) { localJSONArray = new JSONArray(); Iterator localIterator = paramList.iterator(); while (localIterator.hasNext()) { localJSONArray.put(((WebImage)localIterator.next()).a()); } } try { paramJSONObject.put("images", localJSONArray); return; } catch (JSONException localJSONException) {} }
private static MediaInfo buildMediaInfo(String title, String subTitle, String studio, String url, String imgUrl, String bigImageUrl, List<MediaTrack> tracks) { MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, subTitle); movieMetadata.putString(MediaMetadata.KEY_TITLE, title); movieMetadata.putString(MediaMetadata.KEY_STUDIO, studio); movieMetadata.addImage(new WebImage(Uri.parse(imgUrl))); movieMetadata.addImage(new WebImage(Uri.parse(bigImageUrl))); return new MediaInfo.Builder(url) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setContentType(getMediaType()) .setMetadata(movieMetadata) .setMediaTracks(tracks) .build(); }
private static MediaInfo mediaInfo(EntryModel entry) { MediaMetadata mediaMetadata = new MediaMetadata(entry.getType() == Constants.TYPE_SONG ? MediaMetadata.MEDIA_TYPE_MUSIC_TRACK : MediaMetadata.MEDIA_TYPE_MOVIE); mediaMetadata.putString(MediaMetadata.KEY_TITLE, entry.getParent() != null ? entry.getParent() : entry.getTitle()); mediaMetadata.putString(MediaMetadata.KEY_SUBTITLE, entry.getParent() != null ? entry.getTitle() : entry.getLink()); Uri imageUri = Uri.parse(entry.getPictureURL(true)); mediaMetadata.addImage(new WebImage(imageUri)); mediaMetadata.addImage(new WebImage(imageUri)); return new MediaInfo.Builder(entry.getLink()) .setContentType((entry.getType() == Constants.TYPE_SONG ? "audio/" : "video/") + FilenameUtils.getExtension(entry.getLink())) .setStreamType(entry.getType() == Constants.TYPE_LIVE ? MediaInfo.STREAM_TYPE_LIVE : MediaInfo.STREAM_TYPE_BUFFERED) .setMetadata(mediaMetadata) .build(); }
public static MediaInfo buildMediaInfo(String title, String studio, String url, boolean isLiveStream) { MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); movieMetadata.putString(MediaMetadata.KEY_TITLE, title); movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, isLiveStream ? "Live" : "On Demand"); movieMetadata.putString(MediaMetadata.KEY_STUDIO, studio); movieMetadata.addImage(new WebImage(Uri.parse("http://cdn.nhl.com/nhl/images/logos/large.png"))); movieMetadata.addImage(new WebImage(Uri.parse("https://gcls.herokuapp.com/static/logo_por.jpg"))); return new MediaInfo.Builder(url) .setStreamType(isLiveStream ? MediaInfo.STREAM_TYPE_LIVE : MediaInfo.STREAM_TYPE_BUFFERED) .setContentType("application/vnd.apple.mpegurl") .setMetadata(movieMetadata) .build(); }
private MediaInfo buildMediaInfo(String mediaUrl, String contentType, String title, String subtitle, String studio, String imgUrl, String bigImgUrl) { // List<MediaTrack> mediaTracks = buildMediaTracks(); // TextTrackStyle textTrackStyle = TextTrackStyle.fromSystemSettings(this); MediaMetadata metadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); metadata.putString(MediaMetadata.KEY_TITLE, title); metadata.putString(MediaMetadata.KEY_SUBTITLE, subtitle); metadata.putString(MediaMetadata.KEY_STUDIO, studio); metadata.addImage(new WebImage(Uri.parse(imgUrl))); metadata.addImage(new WebImage(Uri.parse(bigImgUrl))); return new MediaInfo.Builder(mediaUrl) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setContentType(contentType) // .setMediaTracks(mediaTracks) // .setTextTrackStyle(textTrackStyle) .setMetadata(metadata) .build(); }
/** * Builds and returns a {@link Bundle} which contains a select subset of data in the * {@link MediaInfo}. Since {@link MediaInfo} is not {@link Parcelable}, one can use this * container bundle to pass around from one activity to another. */ public static Bundle fromMediaInfo(MediaInfo info) { if (null == info) { return null; } MediaMetadata md = info.getMetadata(); Bundle wrapper = new Bundle(); wrapper.putString(MediaMetadata.KEY_TITLE, md.getString(MediaMetadata.KEY_TITLE)); wrapper.putString(MediaMetadata.KEY_SUBTITLE, md.getString(MediaMetadata.KEY_SUBTITLE)); wrapper.putString(KEY_URL, info.getContentId()); wrapper.putString(MediaMetadata.KEY_STUDIO, md.getString(MediaMetadata.KEY_STUDIO)); wrapper.putString(KEY_CONTENT_TYPE, info.getContentType()); wrapper.putInt(KEY_STREAM_TYPE, info.getStreamType()); if (null != md.getImages()) { ArrayList<String> urls = new ArrayList<String>(); for (WebImage img : md.getImages()) { urls.add(img.getUrl().toString()); } wrapper.putStringArrayList(KEY_IMAGES, urls); } return wrapper; }
/** * Builds and returns a {@link MediaInfo} that was wrapped in a {@link Bundle} by */ public static MediaInfo toMediaInfo(Bundle wrapper) { if (null == wrapper) { return null; } MediaMetadata metaData = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); metaData.putString(MediaMetadata.KEY_SUBTITLE, wrapper.getString(MediaMetadata.KEY_SUBTITLE)); metaData.putString(MediaMetadata.KEY_TITLE, wrapper.getString(MediaMetadata.KEY_TITLE)); metaData.putString(MediaMetadata.KEY_STUDIO, wrapper.getString(MediaMetadata.KEY_STUDIO)); ArrayList<String> images = wrapper.getStringArrayList(KEY_IMAGES); if (null != images && !images.isEmpty()) { for (String url : images) { Uri uri = Uri.parse(url); metaData.addImage(new WebImage(uri)); } } return new MediaInfo.Builder(wrapper.getString(KEY_URL)).setStreamType(wrapper.getInt(KEY_STREAM_TYPE)) .setContentType(wrapper.getString(KEY_CONTENT_TYPE)) .setMetadata(metaData) .build(); }
public static void PlayRemote(String title, String url, String iconurl){ Log.i("CAST",title); MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK); movieMetadata.putString(MediaMetadata.KEY_TITLE, title); //movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, "MySubTitle"); movieMetadata.addImage(new WebImage(Uri.parse(iconurl))); //movieMetadata.addImage(new WebImage(Uri.parse(mSelectedMedia.getImage(1)))); MediaInfo mediaInfo = new MediaInfo.Builder(url) .setStreamType(MediaInfo.STREAM_TYPE_LIVE) .setContentType("audio/ogg") .setMetadata(movieMetadata) //.setStreamDuration(mSelectedMedia.getDuration() * 1000) .build(); RemoteMediaClient remoteMediaClient = mCastSession.getRemoteMediaClient(); remoteMediaClient.load(mediaInfo, true); }
private MediaInfo buildMediaInfo() { MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, episode.getAnime().getTitle()); movieMetadata.putString(MediaMetadata.KEY_TITLE, episode.getTitle()); movieMetadata.addImage(new WebImage(Uri.parse(episode.getAnime().getCover()))); return new MediaInfo.Builder(videoUrl) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setContentType("videos/mp4") .setMetadata(movieMetadata) .setStreamDuration(exoPlayer.getDuration() * 1000) .build(); }
private void playMedia(String url, SubtitleInfo subtitleInfo, String mimeType, String title, String description, String iconSrc, boolean shouldLoop, LaunchListener listener) { MediaMetadata mMediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); mMediaMetadata.putString(MediaMetadata.KEY_TITLE, title); mMediaMetadata.putString(MediaMetadata.KEY_SUBTITLE, description); if (iconSrc != null) { Uri iconUri = Uri.parse(iconSrc); WebImage image = new WebImage(iconUri, 100, 100); mMediaMetadata.addImage(image); } List<MediaTrack> mediaTracks = new ArrayList<>(); if(subtitleInfo != null) { MediaTrack subtitle = new MediaTrack.Builder(MEDIA_TRACK_ID, MediaTrack.TYPE_TEXT) .setName(subtitleInfo.getLabel()) .setSubtype(MediaTrack.SUBTYPE_SUBTITLES) .setContentId(subtitleInfo.getUrl()) .setContentType(subtitleInfo.getMimeType()) .setLanguage(subtitleInfo.getLanguage()) .build(); mediaTracks.add(subtitle); } com.google.android.gms.cast.MediaInfo mediaInformation = new com.google.android.gms.cast.MediaInfo.Builder(url) .setContentType(mimeType) .setStreamType(com.google.android.gms.cast.MediaInfo.STREAM_TYPE_BUFFERED) .setMetadata(mMediaMetadata) .setStreamDuration(1000) .setCustomData(null) .setMediaTracks(mediaTracks) .build(); playMedia(mediaInformation, applicationID, listener); }
/** * Helper method to convert a {@link android.media.MediaMetadata} to a * {@link MediaInfo} used for sending media to the receiver app. * * @param track {@link MediaMetadata} * @param customData custom data specifies the local mediaId used by the player. * @return mediaInfo {@link MediaInfo} */ private static MediaInfo toCastMediaMetadata(MediaMetadata track, JSONObject customData) { com.google.android.gms.cast.MediaMetadata mediaMetadata = new com.google.android.gms.cast.MediaMetadata(com.google.android.gms.cast.MediaMetadata.MEDIA_TYPE_MUSIC_TRACK); mediaMetadata.putString(com.google.android.gms.cast.MediaMetadata.KEY_TITLE, track.getDescription().getTitle() == null ? "" : track.getDescription().getTitle().toString()); mediaMetadata.putString(com.google.android.gms.cast.MediaMetadata.KEY_SUBTITLE, track.getDescription().getSubtitle() == null ? "" : track.getDescription().getSubtitle().toString()); mediaMetadata.putString(com.google.android.gms.cast.MediaMetadata.KEY_ALBUM_ARTIST, track.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST)); mediaMetadata.putString(com.google.android.gms.cast.MediaMetadata.KEY_ALBUM_TITLE, track.getString(MediaMetadataCompat.METADATA_KEY_ALBUM)); WebImage image = new WebImage( new Uri.Builder().encodedPath( track.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI)) .build()); // First image is used by the receiver for showing the audio album art. mediaMetadata.addImage(image); // Second image is used by Cast Companion Library on the full screen activity that is shown // when the cast dialog is clicked. mediaMetadata.addImage(image); MediaId id = MediaProvider.getInstance().getMediaId(track.getDescription().getMediaId()); //noinspection ResourceType return new MediaInfo.Builder(track.getString(MediaProvider.CUSTOM_METADATA_TRACK_SOURCE)) .setContentType(id.type == MediaId.TYPE_AUDIO ? MIME_TYPE_AUDIO_MPEG : MIME_TYPE_VIDEO_MPEG) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setMetadata(mediaMetadata) .setCustomData(customData) .build(); }
public void playMedia(String url, String subsUrl, String mimeType, String title, String description, String iconSrc, boolean shouldLoop, LaunchListener listener) { MediaMetadata mMediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); mMediaMetadata.putString(MediaMetadata.KEY_TITLE, title); mMediaMetadata.putString(MediaMetadata.KEY_SUBTITLE, description); if (iconSrc != null) { Uri iconUri = Uri.parse(iconSrc); WebImage image = new WebImage(iconUri, 100, 100); mMediaMetadata.addImage(image); } List<MediaTrack> mediaTracks = new ArrayList<>(); if(subsUrl != null) { MediaTrack subtitle = new MediaTrack.Builder(1, MediaTrack.TYPE_TEXT) .setName("Subtitle") .setSubtype(MediaTrack.SUBTYPE_SUBTITLES) .setContentId(subsUrl) .setContentType("text/vtt") .setLanguage("en") .build(); mediaTracks.add(subtitle); } com.google.android.gms.cast.MediaInfo mediaInformation = new com.google.android.gms.cast.MediaInfo.Builder(url) .setContentType(mimeType) .setStreamType(com.google.android.gms.cast.MediaInfo.STREAM_TYPE_BUFFERED) .setMetadata(mMediaMetadata) .setStreamDuration(1000) .setCustomData(null) .setMediaTracks(mediaTracks) .build(); playMedia(mediaInformation, applicationID, listener); }
private void castVideo(Anime anime, String url){ final RemoteMediaClient mediaClient = castSession.getRemoteMediaClient(); MediaMetadata animeMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); animeMetadata.putString(MediaMetadata.KEY_TITLE, anime.title); if(anime.coverURL != null && !anime.coverURL.isEmpty()) { animeMetadata.addImage(new WebImage(Uri.parse(anime.coverURL))); } MediaInfo animeInfo = new MediaInfo.Builder(url) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setContentType("video/mp4") .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setMetadata(animeMetadata) .build(); mediaClient.addListener(new RemoteMediaClient.Listener() { @Override public void onStatusUpdated() { Intent intent = new Intent(AnimeActivity.this, CastActivity.class); startActivity(intent); mediaClient.removeListener(this); finish(); } @Override public void onMetadataUpdated() {} @Override public void onQueueStatusUpdated() {} @Override public void onPreloadStatusUpdated() {} @Override public void onSendingRemoteMediaRequest() {} }); mediaClient.load(animeInfo, true, 0); }
/** * Helper method to convert a {@link android.media.MediaMetadata} to a * {@link com.google.android.gms.cast.MediaInfo} used for sending media to the receiver app. * * @param track {@link com.google.android.gms.cast.MediaMetadata} * @param customData custom data specifies the local mediaId used by the player. * @return mediaInfo {@link com.google.android.gms.cast.MediaInfo} */ private static MediaInfo toCastMediaMetadata(android.media.MediaMetadata track, JSONObject customData) { MediaMetadata mediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK); mediaMetadata.putString(MediaMetadata.KEY_TITLE, track.getDescription().getTitle() == null ? "" : track.getDescription().getTitle().toString()); mediaMetadata.putString(MediaMetadata.KEY_SUBTITLE, track.getDescription().getSubtitle() == null ? "" : track.getDescription().getSubtitle().toString()); mediaMetadata.putString(MediaMetadata.KEY_ALBUM_ARTIST, track.getString(android.media.MediaMetadata.METADATA_KEY_ALBUM_ARTIST)); mediaMetadata.putString(MediaMetadata.KEY_ALBUM_TITLE, track.getString(android.media.MediaMetadata.METADATA_KEY_ALBUM)); WebImage image = new WebImage( new Uri.Builder().encodedPath( track.getString(android.media.MediaMetadata.METADATA_KEY_ALBUM_ART_URI)) .build()); // First image is used by the receiver for showing the audio album art. mediaMetadata.addImage(image); // Second image is used by Cast Companion Library on the full screen activity that is shown // when the cast dialog is clicked. mediaMetadata.addImage(image); return new MediaInfo.Builder(track.getString(MusicProvider.CUSTOM_METADATA_TRACK_SOURCE)) .setContentType(MIME_TYPE_AUDIO_MPEG) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setMetadata(mediaMetadata) .setCustomData(customData) .build(); }
private MediaInfo buildMediaInfo() { MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, mSelectedMedia.getStudio()); movieMetadata.putString(MediaMetadata.KEY_TITLE, mSelectedMedia.getTitle()); movieMetadata.addImage(new WebImage(Uri.parse(mSelectedMedia.getImage(0)))); movieMetadata.addImage(new WebImage(Uri.parse(mSelectedMedia.getImage(1)))); return new MediaInfo.Builder(mSelectedMedia.getUrl()) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setContentType("videos/mp4") .setMetadata(movieMetadata) .setStreamDuration(mSelectedMedia.getDuration() * 1000) .build(); }
/** * Helper method to convert a {@link MediaMetadataCompat} to a * {@link com.google.android.gms.cast.MediaInfo} used for sending media to the receiver app. * * @param track {@link com.google.android.gms.cast.MediaMetadata} * @param customData custom data specifies the local mediaId used by the player. * @return mediaInfo {@link com.google.android.gms.cast.MediaInfo} */ private static MediaInfo toCastMediaMetadata(MediaMetadataCompat track, JSONObject customData) { MediaMetadata mediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK); mediaMetadata.putString(MediaMetadata.KEY_TITLE, track.getDescription().getTitle().toString()); mediaMetadata.putString(MediaMetadata.KEY_SUBTITLE, track.getDescription().getSubtitle().toString()); mediaMetadata.putString(MediaMetadata.KEY_ALBUM_ARTIST, track.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST)); mediaMetadata.putString(MediaMetadata.KEY_ALBUM_TITLE, track.getString(MediaMetadataCompat.METADATA_KEY_ALBUM)); WebImage image = new WebImage( new Uri.Builder().encodedPath( track.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI)) .build()); // First image is used by the receiver for showing the audio album art. mediaMetadata.addImage(image); // Second image is used by Cast Companion Library on the full screen activity that is shown // when the cast dialog is clicked. mediaMetadata.addImage(image); return new MediaInfo.Builder(track.getString(MusicProvider.CUSTOM_METADATA_TRACK_SOURCE)) .setContentType(MIME_TYPE_AUDIO_MPEG) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setMetadata(mediaMetadata) .setCustomData(customData) .build(); }
public ApplicationMetadata(int paramInt, String paramString1, String paramString2, List<WebImage> paramList, List<String> paramList1, String paramString3, Uri paramUri) { this.a = paramInt; this.b = paramString1; this.c = paramString2; this.d = paramList; this.e = paramList1; this.f = paramString3; this.g = paramUri; }
public CastDevice(int paramInt1, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, int paramInt2, List<WebImage> paramList, int paramInt3, int paramInt4) { this.a = paramInt1; this.b = paramString1; this.c = paramString2; if (this.c != null) {} try { InetAddress localInetAddress = InetAddress.getByName(this.c); if ((localInetAddress instanceof Inet4Address)) { this.k = ((Inet4Address)localInetAddress); } this.d = paramString3; this.e = paramString4; this.f = paramString5; this.g = paramInt2; this.h = paramList; this.i = paramInt3; this.j = paramInt4; return; } catch (UnknownHostException localUnknownHostException) { for (;;) { this.k = null; } } }
/** * Helper method to convert a {@link android.media.MediaMetadata} to a * {@link com.google.android.gms.cast.MediaInfo} used for sending media to the receiver app. * * @param track {@link com.google.android.gms.cast.MediaMetadata} * @param customData custom data specifies the local mediaId used by the player. * @return mediaInfo {@link com.google.android.gms.cast.MediaInfo} */ private static MediaInfo toCastMediaMetadata(MediaMetadataCompat track, JSONObject customData) { MediaMetadata mediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK); mediaMetadata.putString(MediaMetadata.KEY_TITLE, track.getDescription().getTitle() == null ? "" : track.getDescription().getTitle().toString()); mediaMetadata.putString(MediaMetadata.KEY_SUBTITLE, track.getDescription().getSubtitle() == null ? "" : track.getDescription().getSubtitle().toString()); mediaMetadata.putString(MediaMetadata.KEY_ALBUM_ARTIST, track.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST)); mediaMetadata.putString(MediaMetadata.KEY_ALBUM_TITLE, track.getString(MediaMetadataCompat.METADATA_KEY_ALBUM)); WebImage image = new WebImage( new Uri.Builder().encodedPath( track.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI)) .build()); // First image is used by the receiver for showing the audio album art. mediaMetadata.addImage(image); // Second image is used by Cast Companion Library on the full screen activity that is shown // when the cast dialog is clicked. mediaMetadata.addImage(image); //noinspection ResourceType return new MediaInfo.Builder(track.getString(MusicProviderSource.CUSTOM_METADATA_TRACK_SOURCE)) .setContentType(MIME_TYPE_AUDIO_MPEG) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setMetadata(mediaMetadata) .setCustomData(customData) .build(); }
private MediaInfo buildMediaInfo() { MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, video.getUser().getName()); movieMetadata.putString(MediaMetadata.KEY_TITLE, video.getName()); movieMetadata.addImage(new WebImage(Uri.parse(video.getThumbnailUrl()))); return new MediaInfo.Builder(videoUrl) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setContentType("videos/mp4") .setMetadata(movieMetadata) .setStreamDuration(exoPlayer.getDuration() * 1000) .build(); }
/** * Helper method to convert a {@link android.media.MediaMetadata} to a * {@link com.google.android.gms.cast.MediaInfo} used for sending media to the receiver app. * * @param track {@link com.google.android.gms.cast.MediaMetadata} * @param customData custom data specifies the local mediaId used by the player. * @return mediaInfo {@link com.google.android.gms.cast.MediaInfo} */ private static MediaInfo toCastMediaMetadata(android.media.MediaMetadata track, JSONObject customData) { MediaMetadata mediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK); mediaMetadata.putString(MediaMetadata.KEY_TITLE, track.getDescription().getTitle().toString()); mediaMetadata.putString(MediaMetadata.KEY_SUBTITLE, track.getDescription().getSubtitle().toString()); mediaMetadata.putString(MediaMetadata.KEY_ALBUM_ARTIST, track.getString(android.media.MediaMetadata.METADATA_KEY_ALBUM_ARTIST)); mediaMetadata.putString(MediaMetadata.KEY_ALBUM_TITLE, track.getString(android.media.MediaMetadata.METADATA_KEY_ALBUM)); WebImage image = new WebImage( new Uri.Builder().encodedPath( track.getString(android.media.MediaMetadata.METADATA_KEY_ALBUM_ART_URI)) .build()); // First image is used by the receiver for showing the audio album art. mediaMetadata.addImage(image); // Second image is used by Cast Companion Library on the full screen activity that is shown // when the cast dialog is clicked. mediaMetadata.addImage(image); return new MediaInfo.Builder(track.getString(MusicProvider.CUSTOM_METADATA_TRACK_SOURCE)) .setContentType(MIME_TYPE_AUDIO_MPEG) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setMetadata(mediaMetadata) .setCustomData(customData) .build(); }
private MediaInfo getMediaInfo(String stationName, String stationUrl, String imageUrl) { MediaMetadata mediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK); mediaMetadata.putString(MediaMetadata.KEY_TITLE, stationName); mediaMetadata.addImage(new WebImage(Uri.parse(imageUrl))); mediaMetadata.addImage(new WebImage(Uri.parse(imageUrl))); MediaInfo.Builder mediaInfo = new MediaInfo.Builder(stationUrl); mediaInfo.setContentType(Constants.MIME_AUDIO_MP3); mediaInfo.setStreamType(MediaInfo.STREAM_TYPE_LIVE); mediaInfo.setMetadata(mediaMetadata); return mediaInfo.build(); }
ApplicationMetadata(int paramInt, String paramString1, String paramString2, List<WebImage> paramList, List<String> paramList1, String paramString3, Uri paramUri) { this.kg = paramInt; this.kh = paramString1; this.mName = paramString2; this.ki = paramList; this.kj = paramList1; this.kk = paramString3; this.kl = paramUri; }
public WebImage getIcon(int paramInt1, int paramInt2) { if (this.kG.isEmpty()) return null; if ((paramInt1 <= 0) || (paramInt2 <= 0)) return (WebImage)this.kG.get(0); Object localObject1 = null; Object localObject2 = null; Iterator localIterator = this.kG.iterator(); while (localIterator.hasNext()) { WebImage localWebImage = (WebImage)localIterator.next(); int i = localWebImage.getWidth(); int j = localWebImage.getHeight(); if ((i >= paramInt1) && (j >= paramInt2)) { if ((localObject1 == null) || ((localObject1.getWidth() > i) && (localObject1.getHeight() > j))) localObject1 = localWebImage; } else if ((i < paramInt1) && (j < paramInt2) && ((localObject2 == null) || ((localObject2.getWidth() < i) && (localObject2.getHeight() < j)))) localObject2 = localWebImage; } if (localObject1 != null) return localObject1; if (localObject2 != null) return localObject2; return (WebImage)this.kG.get(0); }
@DebugLog public static MediaInfo buildMediaInfo(String trackTitle, String albumTitle, String artistName, String mimeType, String url, String imgUrl, String bigImageUrl) { MediaMetadata metadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK); if (trackTitle != null) { metadata.putString(MediaMetadata.KEY_TITLE, trackTitle); } if (albumTitle != null) { metadata.putString(MediaMetadata.KEY_ALBUM_TITLE, albumTitle); } if (artistName != null) { metadata.putString(MediaMetadata.KEY_ARTIST, artistName); } if (imgUrl != null) { metadata.addImage(new WebImage(Uri.parse(imgUrl))); } if (bigImageUrl != null) { metadata.addImage(new WebImage(Uri.parse(bigImageUrl))); } return new MediaInfo.Builder(url) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setContentType(mimeType.startsWith("audio") ? mimeType : "audio/*") // Workaround for application/ogg (vorbis) .setMetadata(metadata) .build(); }
private JSONArray getRoutes() { JSONArray routeList = new JSONArray(); List<RouteInfo> routesInMedia = mMediaRouter.getRoutes(); final int l = routesInMedia.size(); if (l == 0) { return routeList; } try { for (int i = 0; i < l; i++) { RouteInfo rInfo = routesInMedia.get(i); CastDevice dInfo = getDevice(rInfo); JSONObject jsonRoute = new JSONObject(); jsonRoute.put("id", rInfo.getId()); jsonRoute.put("name", rInfo.getName()); jsonRoute.put("description", rInfo.getDescription()); jsonRoute.put("isSelected", rInfo.isSelected()); jsonRoute.put("index", i); jsonRoute.put("volume", rInfo.getVolume()); if (dInfo != null) { jsonRoute.put("ipAddress", dInfo.getIpAddress()); List<WebImage> icons = dInfo.getIcons(); if ((icons != null) && !icons.isEmpty()) { WebImage icon = icons.get(0); jsonRoute.put("icon", icon.getUrl()); } } if (rInfo.isSelected()) { jsonRoute.put("isConnected", mSelectedDevice != null); } /*if (mSelectedDevice != null) { jsonRoute.put("ipAddress", mSelectedDevice.getIpAddress()); }*/ routeList.put(jsonRoute); } } catch (JSONException e) { Log.d(TAG, "failed to get routes list"); } return routeList; }