fixed frame capture for transient videos
This commit is contained in:
parent
214650ebe4
commit
0848881738
3 changed files with 5 additions and 9 deletions
|
@ -158,7 +158,7 @@ class MediaFileHandler(private val activity: Activity) : MethodCallHandler {
|
|||
destinationDir = ensureTrailingSeparator(destinationDir)
|
||||
provider.captureFrame(activity, desiredName, exifFields, bytes, destinationDir, object : ImageOpCallback {
|
||||
override fun onSuccess(fields: FieldMap) = result.success(fields)
|
||||
override fun onFailure(throwable: Throwable) = result.error("captureFrame-failure", "failed to capture frame", throwable.message)
|
||||
override fun onFailure(throwable: Throwable) = result.error("captureFrame-failure", "failed to capture frame for uri=$uri", throwable.message)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -56,10 +56,6 @@ abstract class ImageProvider {
|
|||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
open suspend fun scanNewPath(context: Context, path: String, mimeType: String): FieldMap {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
suspend fun exportMultiple(
|
||||
context: Context,
|
||||
imageExportMimeType: String,
|
||||
|
@ -203,7 +199,7 @@ abstract class ImageProvider {
|
|||
val fileName = destinationDocFile.name
|
||||
val destinationFullPath = destinationDir + fileName
|
||||
|
||||
return scanNewPath(context, destinationFullPath, exportMimeType)
|
||||
return MediaStoreImageProvider().scanNewPath(context, destinationFullPath, exportMimeType)
|
||||
}
|
||||
|
||||
@Suppress("BlockingMethodInNonBlockingContext")
|
||||
|
@ -301,7 +297,7 @@ abstract class ImageProvider {
|
|||
|
||||
val fileName = destinationDocFile.name
|
||||
val destinationFullPath = destinationDir + fileName
|
||||
val newFields = scanNewPath(context, destinationFullPath, captureMimeType)
|
||||
val newFields = MediaStoreImageProvider().scanNewPath(context, destinationFullPath, captureMimeType)
|
||||
callback.onSuccess(newFields)
|
||||
} catch (e: Exception) {
|
||||
callback.onFailure(e)
|
||||
|
@ -332,7 +328,7 @@ abstract class ImageProvider {
|
|||
|
||||
scanObsoletePath(context, oldPath, mimeType)
|
||||
try {
|
||||
callback.onSuccess(scanNewPath(context, newFile.path, mimeType))
|
||||
callback.onSuccess(MediaStoreImageProvider().scanNewPath(context, newFile.path, mimeType))
|
||||
} catch (e: Exception) {
|
||||
callback.onFailure(e)
|
||||
}
|
||||
|
|
|
@ -403,7 +403,7 @@ class MediaStoreImageProvider : ImageProvider() {
|
|||
MediaScannerConnection.scanFile(context, arrayOf(path), arrayOf(mimeType), null)
|
||||
}
|
||||
|
||||
override suspend fun scanNewPath(context: Context, path: String, mimeType: String): FieldMap =
|
||||
suspend fun scanNewPath(context: Context, path: String, mimeType: String): FieldMap =
|
||||
suspendCoroutine { cont ->
|
||||
MediaScannerConnection.scanFile(context, arrayOf(path), arrayOf(mimeType)) { _, newUri: Uri? ->
|
||||
fun scanUri(uri: Uri?): FieldMap? {
|
||||
|
|
Loading…
Reference in a new issue