问题
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