Adding more fields in MediaMetada GoogleCast

£可爱£侵袭症+ 提交于 2019-12-13 18:26:48

问题


When I cast Video from android phone to Chromecast device, I want to add additional fields for my own application. But when I get this field from the API (VideoCastManager.getRemoteMediaInformation()). It always return null for String, zero for int.
Here I use another field is MediaMetadata.KEY_ARTIST:

MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
movieMetadata.putString(MediaMetadata.KEY_TITLE, video.getFullName());
movieMetadata.putString(MediaMetadata.KEY_ARTIST, String.valueOf(video.getId()));// video ID
movieMetadata.addImage(new WebImage(Uri.parse(video.getThumbnail())));

mSelectedMedia = new MediaInfo.Builder(link)
                .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
                .setContentType("video/mp4")
                .setMetadata(movieMetadata)
                .build();
mCastManager.loadMedia(mSelectedMedia, true, position);

But when I get this field, it always return null

MediaInfo mediaInfo = mCastManager.getRemoteMediaInformation();
MediaMetadata md = mediaInfo.getMetadata();
String title = md.getString(MediaMetadata.KEY_TITLE));
String videoID = md.getString(MediaMetadata.KEY_ARTIST);// always return null;

It just works with these field: KEY_TITLE, KEY_STUDIO, KEY_SUBTITLE. Can anyone explain this for me? Thanks.

P/S: For me, I guess MovieMetaDta( MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE) ) class just has 3 above fields.


回答1:


The easiest for you would be to use the customData field on the MediaInfo object.



来源:https://stackoverflow.com/questions/22600416/adding-more-fields-in-mediametada-googlecast

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!