add video duration attribute in Medium
This commit is contained in:
parent
e950e7f6bb
commit
32129c5e9e
@ -63,6 +63,7 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
||||
MediaStore.Video.Media._ID,
|
||||
MediaStore.Video.Media.WIDTH,
|
||||
MediaStore.Video.Media.HEIGHT,
|
||||
MediaStore.Video.Media.DURATION,
|
||||
MediaStore.Video.Media.DATE_TAKEN,
|
||||
MediaStore.Video.Media.DATE_MODIFIED
|
||||
)
|
||||
@ -580,12 +581,14 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
||||
val idColumn = cursor.getColumnIndex(MediaStore.Video.Media._ID)
|
||||
val widthColumn = cursor.getColumnIndex(MediaStore.Video.Media.WIDTH)
|
||||
val heightColumn = cursor.getColumnIndex(MediaStore.Video.Media.HEIGHT)
|
||||
val durationColumn = cursor.getColumnIndex(MediaStore.Video.Media.DURATION)
|
||||
val dateTakenColumn = cursor.getColumnIndex(MediaStore.Video.Media.DATE_TAKEN)
|
||||
val dateModifiedColumn = cursor.getColumnIndex(MediaStore.Video.Media.DATE_MODIFIED)
|
||||
|
||||
val id = cursor.getLong(idColumn)
|
||||
val width = cursor.getLong(widthColumn)
|
||||
val height = cursor.getLong(heightColumn)
|
||||
val duration = cursor.getLong(durationColumn)
|
||||
var dateTaken: Long? = null
|
||||
if (cursor.getType(dateTakenColumn) == FIELD_TYPE_INTEGER) {
|
||||
dateTaken = cursor.getLong(dateTakenColumn)
|
||||
@ -600,6 +603,7 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
||||
"mediumType" to videoType,
|
||||
"width" to width,
|
||||
"height" to height,
|
||||
"duration" to duration,
|
||||
"creationDate" to dateTaken,
|
||||
"modifiedDate" to dateModified
|
||||
)
|
||||
|
@ -371,6 +371,7 @@ public class SwiftPhotoGalleryPlugin: NSObject, FlutterPlugin {
|
||||
"mediumType": toDartMediumType(value: asset.mediaType),
|
||||
"height": asset.pixelHeight,
|
||||
"width": asset.pixelWidth,
|
||||
"duration": NSInteger(asset.duration * 1000),
|
||||
"creationDate": (asset.creationDate != nil) ? NSInteger(asset.creationDate!.timeIntervalSince1970) * 1000 : nil,
|
||||
"modifiedDate": (asset.modificationDate != nil) ? NSInteger(asset.modificationDate!.timeIntervalSince1970) * 1000 : nil
|
||||
]
|
||||
|
@ -17,6 +17,9 @@ class Medium {
|
||||
/// The medium height.
|
||||
final int height;
|
||||
|
||||
/// The duration of video
|
||||
final int duration;
|
||||
|
||||
/// The date at which the photo or video was taken.
|
||||
final DateTime creationDate;
|
||||
|
||||
@ -28,6 +31,7 @@ class Medium {
|
||||
this.mediumType,
|
||||
this.width,
|
||||
this.height,
|
||||
this.duration,
|
||||
this.creationDate,
|
||||
this.modifiedDate,
|
||||
});
|
||||
@ -38,6 +42,7 @@ class Medium {
|
||||
mediumType = jsonToMediumType(json["mediumType"]),
|
||||
width = json["width"],
|
||||
height = json["height"],
|
||||
duration = json['duration'] ?? 0,
|
||||
creationDate = json['creationDate'] != null
|
||||
? DateTime.fromMillisecondsSinceEpoch(json['creationDate'])
|
||||
: null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user