AVPlayer Video Subtitle not coming when build uploaded from Xcode 11.4

When I have uploaded the Build from Xcode 11.3.4 to Appstore(testflight). I was able to see the Video Subtitles in that build.

But after updating the Xcode 11.3.4 to Xcode 11.4, I uploaded the build with same code again. Now I am not able to see the Video Subtitle in this build.

Can you guys help me on this.

There is not change in code.


func createPlayerandPlayVideo(with videoURL: String, and webVTTURL: String = "", shouldPreDownload: Bool = false, with pageId: Int? = -1) {

if let aVideoURL = URL(string: videoURL) {

let videoAsset = AVURLAsset(url: aVideoURL)

let composition = AVMutableComposition()


let composedVideoTrack: AVMutableCompositionTrack? = composition.addMutableTrack(withMediaType: .video, preferredTrackID: kCMPersistentTrackID_Invalid)

let composedAudioTrack: AVMutableCompositionTrack? = composition.addMutableTrack(withMediaType: .audio, preferredTrackID: kCMPersistentTrackID_Invalid)



if videoAsset.tracks(withMediaType: .video).count > 0 {

do {

try composedVideoTrack?.insertTimeRange(CMTimeRangeMake(start: CMTime.zero, duration: videoAsset.duration), of: videoAsset.tracks (withMediaType: .video)[0], at: CMTime.zero)

} catch let error { print("Error: ", error.localizedDescription) }

}

if videoAsset.tracks(withMediaType: .audio).count > 0 {

do {

try composedAudioTrack?.insertTimeRange(CMTimeRangeMake(start: CMTime.zero, duration: videoAsset.duration), of: videoAsset.tracks (withMediaType: .audio)[0], at: CMTime.zero)

} catch let error { print("Error: ", error.localizedDescription) }

}

var subtitleAsset: AVURLAsset!

if let aVTTURL = URL(string: webVTTURL) {

subtitleAsset = AVURLAsset(url: aVTTURL)

let subtitleTrack = composition.addMutableTrack(withMediaType: .text, preferredTrackID: kCMPersistentTrackID_Invalid)

if let assetTrack = subtitleAsset.tracks(withMediaType: .text).first {

do {

try subtitleTrack?.insertTimeRange(CMTimeRange(start: CMTime.zero, duration: videoAsset.duration), of: assetTrack, at: CMTime.zero)

} catch let error {

print(error.localizedDescription)

}

}

}

playerController?.player = AVPlayer(playerItem: AVPlayerItem(asset: composition))

NotificationCenter.default.addObserver(self, selector: #selector(VideoTVCell.didfinishplaying(note:)),name:NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: playerController?.player?.currentItem)

if shouldPreDownload {

self.downloadFile(url: aVideoURL, for: pageId ?? -1)

} else {

playerController?.player!.play()

}

}

}


This is the code to create the player

AVPlayer Video Subtitle not coming when build uploaded from Xcode 11.4
 
 
Q