2 Replies
      Latest reply on Mar 5, 2020 7:17 AM by eddieli
      jboisjo Level 1 Level 1 (0 points)

        Hi guys,


        I'm currently unable to play my encrypted streams thru AirPlay because i need to add some headers in it. I'm currently doing it in AVPlayer but i have no idea how to add them in the AirPlay receiver or player...


        Is there a way to add headers for AirPlay?


        This is my code to add headers on AVPlayer.


        let fileURL = NSURL(string: self.connexionSources.getPlaylistChannel(numChan: index)) 
                    self.headers = ["Authorization": "myAuth"] 
                    let avAsset = AVURLAsset(url: fileURL! as URL, options: ["AVURLAssetHTTPHeaderFieldsKey": self.headers]) 
                    let playerItem = AVPlayerItem(asset: avAsset) 
                    self.playerView.playerLayer.player = AVPlayer(playerItem: playerItem) 
                    //This is for AirPlay support 
                    self.playerView.playerLayer.player?.allowsExternalPlayback = true 
                    self.playerView.playerLayer.player?.usesExternalPlaybackWhileExternalScreenIsActive = false 
                    //We start the player