diff --git a/examples/exampletvOS/App.tsx b/examples/exampletvOS/App.tsx
index f7ef3f7c..395bbe5b 100644
--- a/examples/exampletvOS/App.tsx
+++ b/examples/exampletvOS/App.tsx
@@ -10,9 +10,8 @@ export default function App() {
diff --git a/ios/Video/DataStructures/Chapter.swift b/ios/Video/DataStructures/Chapter.swift
index 8d0d6fdd..398122b5 100644
--- a/ios/Video/DataStructures/Chapter.swift
+++ b/ios/Video/DataStructures/Chapter.swift
@@ -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
}
diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift
index 6ad51613..369ef64a 100644
--- a/ios/Video/RCTVideo.swift
+++ b/ios/Video/RCTVideo.swift
@@ -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)
}