[Android] Check if meta are set before reading them
Geoffrey Métais
git at videolan.org
Mon Jul 17 14:52:30 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jul 17 14:39:39 2017 +0200| [09f8921eaa4682756aa26561f86198a09a474056] | committer: Geoffrey Métais
Check if meta are set before reading them
> https://code.videolan.org/videolan/vlc-android/commit/09f8921eaa4682756aa26561f86198a09a474056
---
medialibrary/jni/utils.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/medialibrary/jni/utils.cpp b/medialibrary/jni/utils.cpp
index 8b4b08d53..3c29739d5 100644
--- a/medialibrary/jni/utils.cpp
+++ b/medialibrary/jni/utils.cpp
@@ -67,8 +67,10 @@ mediaToMediaWrapper(JNIEnv* env, fields *fields, medialibrary::MediaPtr const& m
unsigned int width = hasVideoTracks ? videoTracks.at(0)->width() : 0;
unsigned int height = hasVideoTracks ? videoTracks.at(0)->height() : 0;
int64_t duration = mediaPtr->duration();
- int64_t progress = duration * ( mediaPtr->metadata( medialibrary::IMedia::MetadataType::Progress ).integer() / 100.0 );
- int64_t seen = mediaPtr->metadata( medialibrary::IMedia::MetadataType::Seen ).integer();
+ const medialibrary::IMediaMetadata& progressMeta = mediaPtr->metadata( medialibrary::IMedia::MetadataType::Progress );
+ int64_t progress = progressMeta.isSet() ? duration * ( progressMeta.integer() / 100.0 ) : 0;
+ const medialibrary::IMediaMetadata& seenMeta = mediaPtr->metadata( medialibrary::IMedia::MetadataType::Seen );
+ int64_t seen = seenMeta.isSet() ? seenMeta.integer() : 0;
jobject item = env->NewObject(fields->MediaWrapper.clazz, fields->MediaWrapper.initID,
(jlong) mediaPtr->id(), mrl,(jlong) progress, (jlong) duration, type,
More information about the Android
mailing list