chore: add chapter images
This commit is contained in:
parent
b225b0f800
commit
6cbc7cdc89
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
||||
|
||||
struct Chapter {
|
||||
let title: String
|
||||
let uri: String
|
||||
let uri: String?
|
||||
let startTime: Double
|
||||
let endTime: Double
|
||||
|
||||
@ -11,14 +11,14 @@ struct Chapter {
|
||||
guard json != nil else {
|
||||
self.json = nil
|
||||
self.title = ""
|
||||
self.uri = ""
|
||||
self.uri = nil
|
||||
self.startTime = 0
|
||||
self.endTime = 0
|
||||
return
|
||||
}
|
||||
self.json = json
|
||||
self.title = json["title"] as? String ?? ""
|
||||
self.uri = json["uri"] as? String ?? ""
|
||||
self.uri = json["uri"] as? String
|
||||
self.startTime = json["startTime"] as? Double ?? 0
|
||||
self.endTime = json["endTime"] as? Double ?? 0
|
||||
}
|
||||
|
@ -429,6 +429,20 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
let endTime = CMTime(seconds: chapter.endTime, preferredTimescale: timescale)
|
||||
let timeRange = CMTimeRangeFromTimeToTime(start: startTime, end: endTime)
|
||||
|
||||
// Image
|
||||
if let imgUri = chapter.uri,
|
||||
let uri = URL(string: imgUri),
|
||||
let imgData = try? Data(contentsOf: uri),
|
||||
let image = UIImage(data: imgData),
|
||||
let pngData = image.pngData()
|
||||
{
|
||||
let imageItem = createMetadataItem(for: .commonIdentifierArtwork, value: pngData)
|
||||
metadata.append(imageItem)
|
||||
print("Image added")
|
||||
} else {
|
||||
print("Something went wrong")
|
||||
}
|
||||
|
||||
return AVTimedMetadataGroup(items: metadata, timeRange: timeRange)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user