Lyncix Company
Lyncix Company

Reputation: 21

Some example using webVTT for AVPlayer in Swift including headers?

I need some example using webVTT for AVPlayer in Swift including headers.

Thanks.

Upvotes: 0

Views: 283

Answers (1)

skantus
skantus

Reputation: 1033

Following should work:

    let token: String = "xyz"

    let videoUrl = URL(string: "...url/video.mp4")!
    let vttURL = URL(string: "...url/subtitle.vtt")!

    let videoPlusSubtitles = AVMutableComposition()

    let headers: [AnyHashable : Any] = [
        "content-type": "application/json",
        "authorization": "Bearer \(token)"
    ]
    let videoAsset = AVURLAsset(url: videoUrl)
    let subtitleAsset = AVURLAsset(url: vttURL, options: ["AVURLAssetHTTPHeaderFieldsKey": headers])

Upvotes: 2

Related Questions