Stopping video on the last frame?

Jun 28, 2011 at 8:59 PM

Hi there,

What would be the best way to stop/pause video footage on the last frame using smooth streaming?  I'm using 2.5 and I've looked through the API but there was very little documentation so it did not help me too much.

The current behaviour of the player is it will play the whole video and then show the very first frame once the video ends.  What I want is for the video to go to or stop at the last frame once the video ends.

Thanks!

Jun 28, 2011 at 9:11 PM

I've done a similar thing with a player, having the video stop right before it would cause a MediaEnded event. I found (using Smooth Streaming) that resolution of around 100ms works

What you'll have to do is subclass the SmfPlayer control and do an override on the OnPlayBackPositionChanged function. One thing you will have to look out for is this function gets called constantly and may increase CPU usage.

 

public class MyPlayer:SMFPlayer
{
                protected override void OnPlaybackPositionChanged()
		{
                        base.OnPlaybackPositionChanged();

			if (PlaybackPosition.Add(TimeSpan.FromMilliseconds(100)) > EndPosition)
			{
				Pause();				
			}
		}

}

Jun 29, 2011 at 2:43 PM

That worked awesomely.

Thanks!