Skip to content

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

@abbasnaqvi200

Description

@abbasnaqvi200

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions