Is there a callback for when a song changes? Basically, we'd need to see some code, but you're going to want to reset the rating back to 2 stars, or whatever the default number of stars is. Then you will want to use the OnRatingBarChange to save the ratings to a database. It appears that the "MediaPlayer" class has an OnCompletionListener to tell when a track is finished.
RatingBar ratingBar = (RatingBar)view.findViewById(R.id.ratingbar);
RatingBar.OnRatingBarChangeListener barListener =
new RatingBar.OnRatingBarChangeListener() {
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromTouch) {
// Do your database stuff here
}
}
and then your stuff for the onCompletion
//mp is the reference to your media player
mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
// Do what you need to do to reset the rating bar. Might need to make a public reference or create a way for this inner class to access the rating bar.
}
});