Browse Source

Save time instead of progress percentage

Fix imprecise resume points
3.0.x
Geoffrey Métais 9 years ago
parent
commit
d4670c1185
  1. 4
      medialibrary/jni/utils.cpp
  2. 2
      vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
  3. 4
      vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt

4
medialibrary/jni/utils.cpp

@ -68,7 +68,9 @@ mediaToMediaWrapper(JNIEnv* env, fields *fields, medialibrary::MediaPtr const& m
unsigned int height = hasVideoTracks ? videoTracks.at(0)->height() : 0;
int64_t duration = mediaPtr->duration();
const medialibrary::IMediaMetadata& progressMeta = mediaPtr->metadata( medialibrary::IMedia::MetadataType::Progress );
int64_t progress = progressMeta.isSet() ? duration * ( progressMeta.integer() / 100.0 ) : 0;
int64_t progress = progressMeta.isSet() ? progressMeta.integer() : 0;
// workaround to convert legacy percentage progress
if (progress != 0 && progress < 100) progress = duration * ( progress / 100.0 );
const medialibrary::IMediaMetadata& seenMeta = mediaPtr->metadata( medialibrary::IMedia::MetadataType::Seen );
int64_t seen = seenMeta.isSet() ? seenMeta.integer() : 0;

2
vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java

@ -3096,7 +3096,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
media = mMedialibrary.getMedia(mUri);
}
if (media != null && media.getId() != 0L && media.getTime() == 0L)
media.setTime((long) (media.getMetaLong(MediaWrapper.META_PROGRESS) * (double) media.getLength())/100L);
media.setTime(media.getMetaLong(MediaWrapper.META_PROGRESS));
} else
media = openedMedia;
if (media != null) {

4
vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt

@ -368,7 +368,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
progress = 0f
}
media.time = if (progress == 0f) 0L else time
media.setLongMeta(MediaWrapper.META_PROGRESS, (progress * 100).toLong())
media.setLongMeta(MediaWrapper.META_PROGRESS, media.time)
}
if (canSwitchToVideo) {
//Save audio delay
@ -535,7 +535,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
if (mw.length <= 0L && length > 0L) {
mw = medialibrary.findMedia(mw)
if (mw.id != 0L) {
mw.time = (mw.getMetaLong(MediaWrapper.META_PROGRESS) * length.toDouble()).toLong() / 100L
mw.time = mw.getMetaLong(MediaWrapper.META_PROGRESS)
if (mw.time > 0L) player.seek(mw.time)
}
}

Loading…
Cancel
Save