admin管理员组

文章数量:1127588

I'm using AdaptiveMediaSource to play HLS streamed video, however the player seems to want to download about 4 minutes worth of video segments as soon as it can before calming down and then only downloading new segments at the rate that the player plays them. This will put more pressure on my server than I'd like, is there a way to limit this? None of the properties on that class seem to effect this.

I did try adding a delay into a DownloadRequested event handler to add a delay into the process if the media players position was sufficiently outside of the pending segments range, along the lines of:

private async void MediaSource_DownloadRequested(AdaptiveMediaSource sender, AdaptiveMediaSourceDownloadRequestedEventArgs args)
{
    ...
    if (args.ResourceType == AdaptiveMediaSourceResourceType.MediaSegment)
    {
        ...
        AdaptiveMediaSourceDownloadRequestedDeferral deferral = args.GetDeferral();
        await Task.Delay(TimeSpan.FromSeconds(1.0));
        deferral.Complete();
        ...
    }
}

which did throttle the requests, but also seemed to effect the internal download/playback bitrate calculations and the video quality switches down to the lowest available.

本文标签: cThrottling AdaptiveMediaSourceStack Overflow