Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ public void bindPlayer(@NonNull MediaData data, String key) {

if (mToken != null) {
mController = new MediaController(mContext, mToken);
mController.registerCallback(mCb);
} else {
mController = null;
}
Expand Down Expand Up @@ -1665,4 +1666,21 @@ private void setVisibleAndAlpha(ConstraintSet set, int actionId, boolean visible
set.setVisibility(actionId, visible ? ConstraintSet.VISIBLE : notVisibleValue);
set.setAlpha(actionId, visible ? 1.0f : 0.0f);
}

/**
* Here is to solve the problem that the panel title and artist are not syncing in time
* @author alphi-w-cn
*/
private final MediaController.Callback mCb = new MediaController.Callback() {
@Override
public void onMetadataChanged(MediaMetadata metadata) {
if (metadata != null) {
String title = metadata.getString(MediaMetadata.METADATA_KEY_TITLE);
String artist = metadata.getString(MediaMetadata.METADATA_KEY_ARTIST);
mMediaViewHolder.getTitleText().setText(title);
mMediaViewHolder.getArtistText().setText(artist);
mMediaViewController.refreshState(); // measure view and refresh the state
}
}
};
}