diff --git a/android/src/main/kotlin/com/kasem/receive_sharing_intent/ReceiveSharingIntentPlugin.kt b/android/src/main/kotlin/com/kasem/receive_sharing_intent/ReceiveSharingIntentPlugin.kt index 0d7bfa3a..21d2bbd0 100644 --- a/android/src/main/kotlin/com/kasem/receive_sharing_intent/ReceiveSharingIntentPlugin.kt +++ b/android/src/main/kotlin/com/kasem/receive_sharing_intent/ReceiveSharingIntentPlugin.kt @@ -143,7 +143,7 @@ class ReceiveSharingIntentPlugin : FlutterPlugin, ActivityAware, MethodCallHandl return when (intent.action) { Intent.ACTION_SEND -> { val uri = intent.getParcelableExtra(Intent.EXTRA_STREAM) - val path = FileDirectory.getAbsolutePath(applicationContext, uri) + val path = uri?.let{ FileDirectory.getAbsolutePath(applicationContext, it) } if (path != null) { val type = getMediaType(path) val thumbnail = getThumbnail(path, type) @@ -204,7 +204,7 @@ class ReceiveSharingIntentPlugin : FlutterPlugin, ActivityAware, MethodCallHandl if (type != MediaType.VIDEO) return null // get duration for video only val retriever = MediaMetadataRetriever() retriever.setDataSource(path) - val duration = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION).toLongOrNull() + val duration = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)?.toLongOrNull() retriever.release() return duration } diff --git a/ios/Classes/SwiftReceiveSharingIntentPlugin.swift b/ios/Classes/SwiftReceiveSharingIntentPlugin.swift index b4ccd8fb..c78bfdd2 100644 --- a/ios/Classes/SwiftReceiveSharingIntentPlugin.swift +++ b/ios/Classes/SwiftReceiveSharingIntentPlugin.swift @@ -149,7 +149,8 @@ public class SwiftReceiveSharingIntentPlugin: NSObject, FlutterPlugin, FlutterSt guard let path = getAbsolutePath(for: $0.path) else { return nil } - return SharedMediaFile.init(path: $0.path, thumbnail: nil, duration: nil, type: $0.type) + let pathWithoutPrefix = String($0.path.dropFirst(7))//knock 'file://' off here... + return SharedMediaFile.init(path: pathWithoutPrefix, thumbnail: nil, duration: nil, type: $0.type) } latestMedia = sharedMediaFiles if(setInitialData) {