Playback position wasn't reset to 0 when playback has ended

This commit is contained in:
daniel oeh 2013-08-21 16:13:34 +02:00
parent 4291a96f2f
commit f9dd57de12
3 changed files with 12 additions and 2 deletions

View File

@ -783,7 +783,6 @@ public class PlaybackService extends Service {
DBWriter.removeQueueItem(PlaybackService.this, item.getId(), true); DBWriter.removeQueueItem(PlaybackService.this, item.getId(), true);
} }
DBWriter.addItemToPlaybackHistory(PlaybackService.this, (FeedMedia) media); DBWriter.addItemToPlaybackHistory(PlaybackService.this, (FeedMedia) media);
DBWriter.setFeedMedia(PlaybackService.this, (FeedMedia) media);
long autoDeleteMediaId = ((FeedComponent) media).getId(); long autoDeleteMediaId = ((FeedComponent) media).getId();
if (shouldStream) { if (shouldStream) {
autoDeleteMediaId = -1; autoDeleteMediaId = -1;

View File

@ -215,7 +215,7 @@ public class DBWriter {
media.setPlaybackCompletionDate(new Date()); media.setPlaybackCompletionDate(new Date());
PodDBAdapter adapter = new PodDBAdapter(context); PodDBAdapter adapter = new PodDBAdapter(context);
adapter.open(); adapter.open();
adapter.setMedia(media); adapter.setFeedMediaPlaybackCompletionDate(media);
adapter.close(); adapter.close();
EventDistributor.getInstance().sendPlaybackHistoryUpdateBroadcast(); EventDistributor.getInstance().sendPlaybackHistoryUpdateBroadcast();

View File

@ -398,6 +398,17 @@ public class PodDBAdapter {
} }
} }
public void setFeedMediaPlaybackCompletionDate(FeedMedia media) {
if (media.getId() != 0) {
ContentValues values = new ContentValues();
values.put(KEY_PLAYBACK_COMPLETION_DATE, media.getPlaybackCompletionDate().getTime());
db.update(TABLE_NAME_FEED_MEDIA, values, KEY_ID + "=?",
new String[]{String.valueOf(media.getId())});
} else {
Log.e(TAG, "setFeedMediaPlaybackCompletionDate: ID of media was 0");
}
}
/** /**
* Insert all FeedItems of a feed and the feed object itself in a single * Insert all FeedItems of a feed and the feed object itself in a single
* transaction * transaction