Load higher quality smooth streaming bitrate on start

馋奶兔 提交于 2019-12-14 02:35:57

问题


Is it possible to adjust the way in which smooth streaming xap bitrate is first started? As it is right now, the player shows a low quality stream until is has buffered the higher quality. Can I change this to allow for the higher quality on start? If so, how?

(I've already seen this question, but I am not using the media platform player.)

IIS Smooth streaming low quality on start


回答1:


The answer on you link answers your question. All that you need is to replace the plugin by properties and events of the SmoothStreamingMediaElement class.

Though I don't like that implementation and msdn has a better example Select and Monitor Bitrate

So in order to set the quality above average use this code:

public MainPage()
{
    InitializeComponent();
    mediaElement.ManifestReady += OnManifestReady;
}

void OnManifestReady(object sender, EventArgs e)
{
    foreach (SegmentInfo segment in mediaElement.ManifestInfo.Segments)
    {
        var videoStream = segment.AvailableStreams.First(i => i.Type == MediaStreamType.Video);
        var averageBitrate = videoStream.AvailableTracks.Average(t => (double)t.Bitrate); // you can use Max as well

        var allowedTracks = videoStream.AvailableTracks.Where(ti => ti.Bitrate >= averageBitrate).ToList();
        videoStream.SelectTracks(allowedTracks, false);
    }
}


来源:https://stackoverflow.com/questions/19380959/load-higher-quality-smooth-streaming-bitrate-on-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!