Java Code Examples for com.google.android.gms.cast.MediaInfo#getMetadata()
The following examples show how to use
com.google.android.gms.cast.MediaInfo#getMetadata() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoCastManager.java From android with Apache License 2.0 | 6 votes |
/** * Updates the information and state of a MiniController. * * @throws TransientNetworkDisconnectionException * @throws NoConnectionException */ private void updateMiniController(IMiniController controller) throws TransientNetworkDisconnectionException, NoConnectionException { checkConnectivity(); checkRemoteMediaPlayerAvailable(); if (mRemoteMediaPlayer.getStreamDuration() > 0 || isRemoteStreamLive()) { MediaInfo mediaInfo = getRemoteMediaInformation(); MediaMetadata mm = mediaInfo.getMetadata(); controller.setStreamType(mediaInfo.getStreamType()); controller.setPlaybackStatus(mState, mIdleReason); controller.setSubTitle(mContext.getResources().getString(R.string.casting_to_device, mDeviceName)); controller.setTitle(mm.getString(MediaMetadata.KEY_TITLE)); if (!mm.getImages().isEmpty()) { controller.setIcon(mm.getImages().get(0).getUrl()); } } }
Example 2
Source File: CastUtils.java From UTubeTV with The Unlicense | 6 votes |
/** * 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; }
Example 3
Source File: LiveStreamActivity.java From Pocket-Plays-for-Twitch with GNU General Public License v3.0 | 5 votes |
@Override protected Bundle getStreamArguments() { boolean autoPlay = true; Intent intent = getIntent(); ChannelInfo mChannelInfo = intent.getParcelableExtra(getResources().getString(R.string.intent_key_streamer_info)); int currentViewers = intent.getIntExtra(getResources().getString(R.string.intent_key_stream_viewers), -1); if (mChannelInfo == null) { try { CastContext sharedContext = Service.getShareCastContext(this); MediaInfo mediaInfo = null; if (sharedContext != null) { mediaInfo = sharedContext.getSessionManager().getCurrentCastSession().getRemoteMediaClient().getMediaInfo(); } if (mediaInfo != null) { MediaMetadata metadata = mediaInfo.getMetadata(); mChannelInfo = new Gson().fromJson(metadata.getString(getString(R.string.stream_fragment_streamerInfo)), new TypeToken<ChannelInfo>() { }.getType()); autoPlay = false; } } catch (Exception e) { e.printStackTrace(); } } Bundle args = new Bundle(); args.putParcelable(getString(R.string.stream_fragment_streamerInfo), mChannelInfo); args.putInt(getString(R.string.stream_fragment_viewers), currentViewers); args.putBoolean(getString(R.string.stream_fragment_autoplay), autoPlay); return args; }
Example 4
Source File: Utils.java From android with Apache License 2.0 | 5 votes |
/** * 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. * * @param info * @return * @see <code>toMediaInfo()</code> */ 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 (!md.getImages().isEmpty()) { ArrayList<String> urls = new ArrayList<String>(); for (WebImage img : md.getImages()) { urls.add(img.getUrl().toString()); } wrapper.putStringArrayList(KEY_IMAGES, urls); } JSONObject customData = info.getCustomData(); if (null != customData) { wrapper.putString(KEY_CUSTOM_DATA, customData.toString()); } return wrapper; }
Example 5
Source File: VideoCastManager.java From UTubeTV with The Unlicense | 5 votes |
/** * Updates the information and state of a MiniController. */ private void updateMiniController(IMiniController controller) throws TransientNetworkDisconnectionException, NoConnectionException { checkConnectivity(); checkRemoteMediaPlayerAvailable(); if (mRemoteMediaPlayer.getStreamDuration() > 0) { MediaInfo mediaInfo = getRemoteMediaInformation(); MediaMetadata mm = mediaInfo.getMetadata(); controller.setStreamType(mediaInfo.getStreamType()); controller.setPlaybackStatus(mState, mIdleReason); controller.setSubTitle(mContext.getResources() .getString(R.string.casting_to_device, mDeviceName)); controller.setTitle(mm.getString(MediaMetadata.KEY_TITLE)); controller.setIcon(mm.getImages().get(0).getUrl()); } }
Example 6
Source File: CastUtils.java From UTubeTV with The Unlicense | 5 votes |
/** * Returns the URL of an image for the MediaInformation at the given level. Level should * be a number between 0 and <code>n - 1</code> where <code>n * </code> is the number of images for that given item. */ public static String getImageUrl(MediaInfo info, int level) { MediaMetadata mm = info.getMetadata(); if (null != mm && null != mm.getImages() && mm.getImages().size() > level) { return mm.getImages().get(level).getUrl().toString(); } return null; }
Example 7
Source File: QueueListAdapter.java From CastVideos-android with Apache License 2.0 | 4 votes |
@Override public void onBindViewHolder(final QueueItemViewHolder holder, int position) { Log.d(TAG, "[upcoming] onBindViewHolder() for position: " + position); final MediaQueueItem item = mProvider.getItem(position); holder.mContainer.setTag(R.string.queue_tag_item, item); holder.mPlayPause.setTag(R.string.queue_tag_item, item); holder.mPlayUpcoming.setTag(R.string.queue_tag_item, item); holder.mStopUpcoming.setTag(R.string.queue_tag_item, item); // Set listeners holder.mContainer.setOnClickListener(mItemViewOnClickListener); holder.mPlayPause.setOnClickListener(mItemViewOnClickListener); holder.mPlayUpcoming.setOnClickListener(mItemViewOnClickListener); holder.mStopUpcoming.setOnClickListener(mItemViewOnClickListener); MediaInfo info = item.getMedia(); MediaMetadata metaData = info.getMetadata(); holder.mTitleView.setText(metaData.getString(MediaMetadata.KEY_TITLE)); holder.mDescriptionView.setText(metaData.getString(MediaMetadata.KEY_SUBTITLE)); if (!metaData.getImages().isEmpty()) { String url = metaData.getImages().get(0).getUrl().toString(); mImageLoader = CustomVolleyRequest.getInstance(mAppContext) .getImageLoader(); mImageLoader.get(url, ImageLoader.getImageListener(holder.mImageView, 0, 0)); holder.mImageView.setImageUrl(url, mImageLoader); } holder.mDragHandle.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { mDragStartListener.onStartDrag(holder); } return false; } }); if (item == mProvider.getCurrentItem()) { holder.updateControlsStatus(QueueItemViewHolder.CURRENT); updatePlayPauseButtonImageResource(holder.mPlayPause); } else if (item == mProvider.getUpcomingItem()) { holder.updateControlsStatus(QueueItemViewHolder.UPCOMING); } else { holder.updateControlsStatus(QueueItemViewHolder.NONE); holder.mPlayPause.setVisibility(View.GONE); } }
Example 8
Source File: Utils.java From android with Apache License 2.0 | 3 votes |
/** * Returns the URL of an image for the {@link MediaInformation} at the given level. Level should * be a number between 0 and <code>n - 1</code> where <code>n * </code> is the number of images for that given item. * * @param info * @param level * @return */ public static String getImageUrl(MediaInfo info, int level) { MediaMetadata mm = info.getMetadata(); if (null != mm && mm.getImages().size() > level) { return mm.getImages().get(level).getUrl().toString(); } return null; }