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