BXIA
BXIA

Reputation: 61

How to play a video in TVML with specific HTTP header?

I'm writing a tvOS app using TVJS and TVML. But it seems cannot play videos with specific HTTP header.

Is there any way to do that?

Upvotes: 0

Views: 268

Answers (1)

Maxime
Maxime

Reputation: 1392

You can add header to AVPlayer when you set the AssetURL like that :

var headers: [String:String] = ["HeaderKey": "HeaderValue"]
let asset: AVURLAsset = AVURLAsset.URLAssetWithURL(url!, options: ["AVURLAssetHTTPHeaderFieldsKey": headers])
let playerItem = AVPlayerItem(asset)
player.replaceCurrentItemWithPlayerItem(playerItem)
player.play()

Upvotes: 1

Related Questions