我的应用程序包含视频,音频和照片。我成功地投了他们三个。但是,当我投射图像时,minicontrollerfragment,Notification和ExpandedControllerActivity显示视频控件。 当我点击播放/暂停按钮时,它会一直旋转以拍照。
有没有办法可以禁用图片?我到处查看,但由于某种原因,我无法找到一个Photo的例子。
任何帮助将不胜感激。 谢谢。
以下是CastOptionsProvider的代码。
@Override
public CastOptions getCastOptions(Context context) {
NotificationOptions notificationOptions = new NotificationOptions.Builder()
.setTargetActivityClassName(ExpandedControlsActivity.class.getName())
.setActions(Arrays.asList(MediaIntentReceiver.ACTION_REWIND,MediaIntentReceiver.ACTION_TOGGLE_PLAYBACK, MediaIntentReceiver.ACTION_FORWARD, MediaIntentReceiver.ACTION_STOP_CASTING), new int[]{1,2,3})
.build();
CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
.setNotificationOptions(notificationOptions)
.setExpandedControllerActivityClassName(ExpandedControlsActivity.class.getName())
.build();
CastOptions castOptions = new CastOptions.Builder()
.setReceiverApplicationId(CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
.setCastMediaOptions(mediaOptions)
.build();
return castOptions;
}
这是我投射图像的方式:
MediaMetadata photoMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_PHOTO);
photoMetadata.putString(MediaMetadata.KEY_TITLE, "Casting to " + mCastSession.getCastDevice().getFriendlyName());
photoMetadata.addImage(new WebImage(Uri.parse(photoItem.getImageUrl())));
MediaInfo mediaInfo = new MediaInfo.Builder(photoItem.getImageUrl())
.setContentType("image/jpeg")
.setMetadata(photoMetadata)
.setStreamDuration(0)
.setStreamType(MediaInfo.STREAM_TYPE_NONE)
.build();
MediaLoadOptions mediaLoadOptions = new MediaLoadOptions.Builder()
.setAutoplay(true)
.setPlayPosition(0)
.build();
RemoteMediaClient remoteMediaClient = mCastSession.getRemoteMediaClient();
remoteMediaClient.load(mediaInfo, mediaLoadOptions);