Slow Motion using the Smooth Streaming Media Element (SSME)

The week started with really great news from the IIS Team. The IIS Media Services 3.0 streaming was released. Among others features the release includes the RTW bits of Live Smooth Streaming.

Also, in the efforts to bring the Smooth Streaming experience to everyone the IIS team published the IIS Smooth Streaming Player Development Kit 1.0 – Beta 1 which is intended to aid the development of rich Smooth Streaming experiences.

Bunch of posts to review if you are not aware of the new releases:

I’m very excited with this release, as we have been using the Smooth Streaming Media Element almost from its beginning mainly for the work we did for the NBC Sunday Night Football event. (see here & here). I will start sharing with you how to take advantage of the SSME.

In this post I will show you how easy is to bring an Slow Motion experience using the SSME. Vishal blogged a great SSME getting started guide that I encourage you  to review before digging into the details of this post.

Adding support for Slow Motion to your Smooth Player is really easy, and basically what you have to do is getting the playback rates between 0.0 and 1.0, and move across them every time you click your Slow Motion button on the player.

Below you will find a code snippet ready to be used that will help you to implement the Slow Motion logic.

private List<double> slowMotionPlaybackRates;
/// <summary>
/// Toogles the PlaybackRate of the Smooth Streaming Media Element.
/// Uses the PlaybackRates between 0.0 and 1.0 to support Slow Motion.
/// </summary>
public void OnSlowMotion()
    // PlaybackRate index to set on the SSME.
    int newPlaybackRateIndex = 0;
    // Verify the state of the SmoothPlayer
    if (this.SmoothPlayer.CurrentState == MediaElementState.Paused
        || this.SmoothPlayer.CurrentState == MediaElementState.Playing
        || this.SmoothPlayer.CurrentState == MediaElementState.Buffering)
        // Get the current PlaybackRate of the SSME
        double playbackRate = this.SmoothPlayer.PlaybackRate;
        // The first time we get the SlowMotion PlaybackRates from
        // the SSME supported PlayBackRates. SlowMotion PlaybackRates 
        // are between 0.0 and 1.0.
        if (this.slowMotionPlaybackRates == null)
            this.slowMotionPlaybackRates = new List<double>();
            IList<double> supportedPlaybackRates = this.SmoothPlayer.SupportedPlaybackRates;
            for (int i = 0; i < supportedPlaybackRates.Count; i++)
                if (supportedPlaybackRates[i] > 0.0 && supportedPlaybackRates[i] < 1.0)
        // Verify if the current PlaybackRate is within the 
        // allowables values. Get the index of the new 
        // PlaybackRate to set.
        if (playbackRate <= 0.0 || playbackRate >= 1.0)
            newPlaybackRateIndex = 0;
            for (int i = 0; i < this.slowMotionPlaybackRates.Count; i++)
                if (this.slowMotionPlaybackRates[i] == playbackRate)
                    newPlaybackRateIndex = (i + 1) % this.slowMotionPlaybackRates.Count;

Hope you find the code snippet useful. Stay tuned!, new posts are coming.

PS: If you face any issue with the Smooth Streaming Development Kit or if you just want to provide feedback to the IIS team, please use this thread.


Leave a Reply