• Slow Motion using the Smooth Streaming Media Element (SSME)

    Published by on October 16th, 2009 11:59 pm under Adaptive Streaming, IIS7, Live Smooth Streaming, Silverlight 3, Smooth Streaming, Smooth Streaming Media Element, Smooth Streaming Player Development Kit, 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.

    Tags: , , , , , , ,

    • http://www.vsworld.com Video optimization webcasting & bandwidth: how many viewers can you reach?

      Web casting, or broadcasting over the internet, is a media file (audio-video mostly) distributed over the internet using streaming media technology. Streaming implies media played as a continuous stream and received real time by the browser (end user). Streaming technology enables a single content source to be distributed to many simultaneous viewers. Streaming video bandwidth is typically calculated in gigabytes of data transferred. It is important to estimate how many viewers you can reach, for example in a live webcast, given your bandwidth constraints or conversely, if you are expecting a certain audience size, what bandwidth resources you need to deploy.

    • http://www.ovationcredit.com Tipquadia

      Very nice Blog, I will tell my friends about it.