Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASVideoNode] Video node does not support HLS video #2118

Open
abbasnaqvi200 opened this issue Dec 12, 2024 · 0 comments
Open

[ASVideoNode] Video node does not support HLS video #2118

abbasnaqvi200 opened this issue Dec 12, 2024 · 0 comments

Comments

@abbasnaqvi200
Copy link

I encountered an issue with ASVideoNode where it does not handle HLS video streams properly. Instead of streaming the video in chunks (as expected with HLS), it attempts to load the entire video first, leading to significant delays before playback begins, especially on slower internet connections. The behavior is similar to loading an MP4 file, rather than a stream.

// Get the reverse proxy URL
let cachedVideoURL = HLSVideoCache.shared.reverseProxyURL(from: vURL) ?? vURL

// Create AVURLAsset
let asset = AVURLAsset(url: cachedVideoURL)

// Assign the asset to ASVideoPlayerNode
self.videoPlayerNode.videoNode.asset = asset

self.setupPlayer()

func setupPlayer() {
if let player = videoPlayerNode.videoNode.player {
if player.currentItem?.preferredForwardBufferDuration == 0.0 {
player.automaticallyWaitsToMinimizeStalling = true
if let currentItem = player.currentItem {
currentItem.preferredForwardBufferDuration = 2
currentItem.canUseNetworkResourcesForLiveStreamingWhilePaused = true
currentItem.cancelPendingSeeks()
currentItem.asset.cancelLoading()
}
player.playImmediately(atRate: 1.0)
player.play()
}
}
}

Expected Behavior:
The video should start playing immediately after loading the initial chunks, streaming the rest dynamically as needed (true HLS behavior).

Actual Behavior:
The video does not start playing until the entire content is loaded, resulting in long delays before playback begins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant