Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MP4 videos saving result in 3GP on Android API <=28 #1188

Merged
merged 9 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ To know more about breaking changes, see the [Migration Guide][].
### Fixes

- Do not use `privateFileURL` on iOS 18+.
- Fixes saving MP4 videos will result in 3GP on Android API 30-.
- Fixes nullable result returned when saving images and videos on Android.

## 3.5.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ class PhotoManagerPlugin(
resultHandler.reply(map)
} catch (e: Exception) {
LogUtils.error("save image error", e)
resultHandler.reply(null)
resultHandler.replyError(call.method, message = null, obj = e)
}
}

Expand All @@ -515,7 +515,7 @@ class PhotoManagerPlugin(
resultHandler.reply(map)
} catch (e: Exception) {
LogUtils.error("save image error", e)
resultHandler.reply(null)
resultHandler.replyError(call.method, message = null, obj = e)
}
}

Expand All @@ -537,7 +537,7 @@ class PhotoManagerPlugin(
resultHandler.reply(map)
} catch (e: Exception) {
LogUtils.error("save video error", e)
resultHandler.reply(null)
resultHandler.replyError(call.method, message = null, obj = e)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,18 @@ interface IDBUtils {
if (relativePath.isNotBlank()) {
put(RELATIVE_PATH, relativePath)
}
} else {
val albumDir = File(
Environment.getExternalStorageDirectory().path,
Environment.DIRECTORY_MOVIES
)
// Check if the directory exist.
File(albumDir, title).path.checkDirs()
// Using a duplicate file name that already exists on the device will cause
// inserts to fail on Android API 29-.
val basename = System.currentTimeMillis().toString()
val newFilePath = File(albumDir, "$basename.${file.extension}").absolutePath
put(DATA, newFilePath)
}
if (latLong != null) {
put(MediaStore.Video.VideoColumns.LATITUDE, latLong.first())
Expand Down
Loading