Reputation: 574
I'm trying to secure my m3u8 streaming link with a token.I am using flussonic cdn To achieve this, I'm using AVAssetResourceLoaderDelegate in my SwiftUI app. However, the video is playing but when existing token is invalid and i update the token via resourceloader the player is paused for few seconds.
if var urlComponents = URLComponents(url: redirectURL, resolvingAgainstBaseURL: false) {
var queryItems = urlComponents.queryItems ?? []
// Check if the token already exists
if let existingTokenIndex = queryItems.firstIndex(where: { $0.name == "token" }) {
// Update the existing token
queryItems[existingTokenIndex].value = token
} else {
// Add the token if it doesn't exist
queryItems.append(URLQueryItem(name: "token", value: token))
}
urlComponents.queryItems = queryItems
redirectURL = urlComponents.url!
}
Upvotes: 0
Views: 412