diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-02-23 19:04:16 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-02-23 19:04:16 +0100 |
commit | f94fc0289459e71d0e9c421243b939866fa5b4ec (patch) | |
tree | d99ae6199794ae8ad894d55256468fbd102d24fb | |
parent | 255cb2464d0e560336b205a1ad173aecb0b936e6 (diff) | |
download | AntennaPod-f94fc0289459e71d0e9c421243b939866fa5b4ec.zip |
played_duration was updated incorrectly
4 files changed, 24 insertions, 30 deletions
diff --git a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java index 4aae2b091..794afdefa 100644 --- a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -372,7 +372,6 @@ public abstract class MediaplayerActivity extends ActionBarActivity if (currentPosition != PlaybackService.INVALID_TIME && duration != PlaybackService.INVALID_TIME && controller.getMedia() != null) { - controller.getMedia().setPosition(currentPosition); txtvPosition.setText(Converter .getDurationStringLong(currentPosition)); txtvLength.setText(Converter.getDurationStringLong(duration)); diff --git a/src/de/danoeh/antennapod/feed/FeedMedia.java b/src/de/danoeh/antennapod/feed/FeedMedia.java index 81cae8507..fe2c3d17e 100644 --- a/src/de/danoeh/antennapod/feed/FeedMedia.java +++ b/src/de/danoeh/antennapod/feed/FeedMedia.java @@ -1,26 +1,26 @@ package de.danoeh.antennapod.feed; -import java.io.FileInputStream; -import java.io.InputStream; -import java.util.Date; -import java.util.List; -import java.util.concurrent.Callable; - import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; +import de.danoeh.antennapod.AppConfig; import de.danoeh.antennapod.PodcastApp; import de.danoeh.antennapod.preferences.PlaybackPreferences; import de.danoeh.antennapod.storage.DBReader; import de.danoeh.antennapod.storage.DBWriter; -import de.danoeh.antennapod.preferences.UserPreferences; import de.danoeh.antennapod.util.ChapterUtils; import de.danoeh.antennapod.util.playback.Playable; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.Date; +import java.util.List; +import java.util.concurrent.Callable; + public class FeedMedia extends FeedFile implements Playable { - private static final String TAG = "FeedMedia"; + private static final String TAG = "FeedMedia"; public static final int FEEDFILETYPE_FEEDMEDIA = 2; public static final int PLAYABLE_TYPE_FEEDMEDIA = 1; @@ -30,7 +30,7 @@ public class FeedMedia extends FeedFile implements Playable { private int duration; private int position; // Current position in file - private int played_duration; // How many ms of this file have been played (for autoflattring) + private int played_duration; // How many ms of this file have been played (for autoflattring) private long size; // File size in Byte private String mime_type; private volatile FeedItem item; @@ -142,24 +142,20 @@ public class FeedMedia extends FeedFile implements Playable { this.duration = duration; } - public int getPlayedDuration() { - return played_duration; - } + public int getPlayedDuration() { + return played_duration; + } public void setPlayedDuration(int played_duration) { this.played_duration = played_duration; } - public int getPosition() { + public int getPosition() { return position; } public void setPosition(int position) { - final int WAITING_INTERVAL = 5000; - if (position > this.position) - played_duration += Math.min(position - this.position, 1.1*WAITING_INTERVAL); - - this.position = position; + this.position = position; } public long getSize() { @@ -186,7 +182,7 @@ public class FeedMedia extends FeedFile implements Playable { * Sets the item object of this FeedMedia. If the given * FeedItem object is not null, it's 'media'-attribute value * will also be set to this media object. - * */ + */ public void setItem(FeedItem item) { this.item = item; if (item != null && item.getMedia() != this) { @@ -196,7 +192,8 @@ public class FeedMedia extends FeedFile implements Playable { public Date getPlaybackCompletionDate() { return playbackCompletionDate == null - ? null : (Date) playbackCompletionDate.clone(); } + ? null : (Date) playbackCompletionDate.clone(); + } public void setPlaybackCompletionDate(Date playbackCompletionDate) { this.playbackCompletionDate = playbackCompletionDate == null @@ -332,7 +329,7 @@ public class FeedMedia extends FeedFile implements Playable { @Override public void saveCurrentPosition(SharedPreferences pref, int newPosition) { setPosition(newPosition); - DBWriter.setFeedMediaPlaybackInformation(PodcastApp.getInstance(), this); + DBWriter.setFeedMediaPlaybackInformation(PodcastApp.getInstance(), this); } @Override diff --git a/src/de/danoeh/antennapod/service/playback/PlaybackService.java b/src/de/danoeh/antennapod/service/playback/PlaybackService.java index 095c982e8..6bc8c4127 100644 --- a/src/de/danoeh/antennapod/service/playback/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/playback/PlaybackService.java @@ -725,6 +725,7 @@ public class PlaybackService extends Service { private synchronized void saveCurrentPosition(boolean updatePlayedDuration, int deltaPlayedDuration) { int position = getCurrentPosition(); int duration = getDuration(); + float playbackSpeed = getCurrentPlaybackSpeed(); final Playable playable = mediaPlayer.getPSMPInfo().playable; if (position != INVALID_TIME && duration != INVALID_TIME && playable != null) { if (AppConfig.DEBUG) @@ -732,7 +733,7 @@ public class PlaybackService extends Service { if (updatePlayedDuration && playable instanceof FeedMedia) { FeedMedia m = (FeedMedia) playable; FeedItem item = m.getItem(); - m.setPlayedDuration(m.getPlayedDuration() + deltaPlayedDuration); + m.setPlayedDuration(m.getPlayedDuration() + ((int)(deltaPlayedDuration * playbackSpeed))); // Auto flattr if (FlattrUtils.hasToken() && UserPreferences.isAutoFlattr() && item.getPaymentLink() != null && item.getFlattrStatus().getUnflattred() && (m.getPlayedDuration() > UserPreferences.getPlayedDurationAutoflattrThreshold() * duration)) { diff --git a/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java b/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java index 20e2f703b..30f6de458 100644 --- a/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java +++ b/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java @@ -564,15 +564,12 @@ public class PlaybackServiceMediaPlayer { return 1; } - int retVal = 1; - if (playerStatus == PlayerStatus.PLAYING + float retVal = 1; + if ((playerStatus == PlayerStatus.PLAYING || playerStatus == PlayerStatus.PAUSED - || playerStatus == PlayerStatus.PREPARED) { - retVal = mediaPlayer.getCurrentPosition(); - } else if (media != null && media.getPosition() > 0) { - retVal = media.getPosition(); + || playerStatus == PlayerStatus.PREPARED) && mediaPlayer.canSetSpeed()) { + retVal = mediaPlayer.getCurrentSpeedMultiplier(); } - playerLock.unlock(); return retVal; } |