Avkit
AVKit
Libraries involved
AVKit
AVFoundation
AVPlayer
Video Terminologies
SwiftUI POC
SwiftUI + Video player to stream.
hls-streaming-with-avkit-and-swiftui
DRM
HLS
AVPlayer
AVAsset
avPlayerItem
Guides
Video thumbnail
This below snippet code should be able to extract the thumbnail image from the given video source. We can also create random time value to generate different thumbnails but we have ensure that the video is at least 13 secs long in this code snippet. You can safe guard yourself with a range of video duration and generate random thumbnail out of it.
let asset = AVAsset(url: url)
let avAssetImageGen = AVAssetImageGenerator(asset: asset)
avAssetImageGen.appliesPreferredTrackTransform = true
let thumbnailSnapTime = CMTimeMake(value: 13, timescale: 1)
do {
let thumbCGImage = try avAssetImageGen
.copyCGImage(at: thumbanailSnaptime, actualTime: nil)
let thumbImage = UIImage(cgImage: thumbCGImage)
} catch {
print(error)
}
Multiple Tracks
apple dev | selecting_subtitles_and_alternative_audio_tracks
Loading media data async
apple dev | Loading media data asynchronously
Interview Questions
Video Geeking
Video Toolbox
Reference
Using AVFoundation to Play and Persist HTTP Live Streams
Video article ios-fairplay-drm-integration
github project | drm-sample-player-ios
youtube | Video Kit UIKit delegate and public functions