Question

I'm developing a custom player (s) for Silverlight, one based with MediaElement and other with SmootStreamingMediaElement. For the moment I'm using the latest version of the SDK 5.0 but I would like to support previous versions once all my issues are resolved.

All is working fine (playback) and now I've got a basic understanding about the platform and APIs, but I'm stucked with a (non) trivial feature: I want to get the Bitrate information for the current playing video, no matter if its a single bitrate or multibitrate file... must work on both cases.

As far as I know I have the following properties and methods for the MediaElement API that are useful but not enough: DownloadProgress and BufferProgress. No method for getting the Bitrate or similar information found in the specification except TotalBytesDownloaded property for SmoothStreamingMediaElement Class.

Using the MediaElement and SmootStreamingMediaElement APIs is possible to get the average or instant bitrate of a video file?

If not, there is any workaround to handle it?

Do I have access to MediaItem (from within a MediaElement instance) in order to get some more information about the video?

Was it helpful?

Solution

The built-in MediaElement class doesn't have such functionality. But you can detect the current bitrate by using the more advanced SmoothStreamingMediaElement class.

Here is a msdn article that explains how to use this class: Select and Monitor Bitrate

The complete code that watchs the current bitrate:

public MainPage()
{
    InitializeComponent();
    media.PlaybackTrackChanged += OnPlaybackTrackChanged;
}

void OnPlaybackTrackChanged(object sender, TrackChangedEventArgs e)
{
    Debug.WriteLine("Current bitrate: " + e.NewTrack.Bitrate.ToString());
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top