Widget: Show correct played and total when current episode ends

This commit is contained in:
Martin Fietz 2015-05-14 17:44:54 +02:00
parent 73c4dfc04d
commit 7727270855
1 changed files with 9 additions and 9 deletions

View File

@ -117,11 +117,12 @@ public class PlayerWidgetService extends Service {
views.setTextViewText(R.id.txtvTitle, media.getEpisodeTitle());
if (status == PlayerStatus.PLAYING) {
String progressString = getProgressString(playbackService);
String progressString = getProgressString(media);
if (progressString != null) {
views.setTextViewText(R.id.txtvProgress, progressString);
}
if (status == PlayerStatus.PLAYING) {
views.setImageViewResource(R.id.butPlay, R.drawable.ic_pause_white_24dp);
if (Build.VERSION.SDK_INT >= 15) {
views.setContentDescription(R.id.butPlay, getString(R.string.pause_label));
@ -157,11 +158,10 @@ public class PlayerWidgetService extends Service {
return PendingIntent.getBroadcast(this, 0, startingIntent, 0);
}
private String getProgressString(PlaybackService ps) {
int position = ps.getCurrentPosition();
int duration = ps.getDuration();
if (position != PlaybackService.INVALID_TIME
&& duration != PlaybackService.INVALID_TIME) {
private String getProgressString(Playable media) {
int position = media.getPosition();
int duration = media.getDuration();
if (position > 0 && duration > 0) {
return Converter.getDurationStringLong(position) + " / "
+ Converter.getDurationStringLong(duration);
} else {