Reputation: 375
i need to retrieve the some data(Custom Data) from the receiver app then only i can update my sender App UI in Mobile, I just passed the CustomData to receiver app while connecting to the Chromecast
device which is working fine. i found the mRemoteMediaPlayer.setOnMetadataUpdatedListener
but where how can i get the custom data from the receiver?.
Thanks in Advance
my Code part is
if (mRemoteMediaPlayer == null || !mApiClient.isConnected()) {
Toast.makeText(this.ctx, "No Connection", Toast.LENGTH_LONG)
.show();
return;
}
MediaMetadata mediaMetadata = new MediaMetadata(
MediaMetadata.MEDIA_TYPE_MUSIC_TRACK);
mediaMetadata.putString(MediaMetadata.KEY_ALBUM_ARTIST, ""
+ singers.getText().toString());
mediaMetadata.putString(mediaMetadata.KEY_ALBUM_TITLE, ""
+ songTitle.getText().toString());
mediaMetadata
.addImage(new WebImage(Uri.parse(cdImgurlList.get(0))));
MediaInfo mediaInfo = new MediaInfo.Builder(songUrl)
.setContentType("audio/mp3")
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setCustomData(customjsonArrayWrapper) //here pass the customData to the receiver.
.setMetadata(mediaMetadata).build();
mRemoteMediaPlayer
.load(mApiClient, mediaInfo, true)
.setResultCallback(
new ResultCallback<RemoteMediaPlayer.MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (result.getStatus().isSuccess()) {
Log.d(TAG, "Media loaded Successfully"
+ result.getStatus());
Toast.makeText(
RaagaActivity.this,
"Media Channel loaded Successfully"
+ result.getStatus(),
Toast.LENGTH_SHORT).show();
// Update the UI While chrome casting
UpdateUIControlsinCasting();
} else {
Log.d(TAG,
"Media loaded Not Successfully"
+ result.getStatus());
Toast.makeText(
RaagaActivity.this,
"Media Channel not loaded Successfully"
+ result.getStatus(),
Toast.LENGTH_SHORT).show();
}
}
});
} catch (IllegalStateException e) {
String err = (e.getMessage()==null)?"IllegalStateException":e.getMessage();
Log.e(TAG, err);
} catch (Exception e) {
// TODO: handle exception
String err = (e.getMessage()==null)?"Exception":e.getMessage();
Log.e(TAG, err);
Upvotes: 0
Views: 688
Reputation: 19044
If you want to retrieve the custom data when metadata updates, try the following: when onMetadataUpdated()
of OnMetadataUpdateListener
is called, get the MediaInfo
by calling mediaInfo = mRemoteMediaPlayer.getMediaInfo()
and then get the custom data via mediaIfo.getCustomData()
.
Upvotes: 1