SMF v2 - SeekCompleted Event

Jun 24, 2010 at 11:52 PM

Hello,

I'm trying to create a new action on the SeekCompleted event but am having a hard time figuring out how to access it. I was successful with the PlayStateChanged and MediaOpened events, but I'm not sure how to get to the IMediaPlugin events.

Here's the SMFPlayer line I have in my XAML:

 

<Core:SMFPlayer AutoPlay="False" ChaptersVisibility="Visible" Name="videoPlayer">

 

And here's how I did PlayStateChanged and MediaOpened:

 

            videoPlayer.PlayStateChanged += new Action<SMFPlayer, Microsoft.SilverlightMediaFramework.Plugins.Primitives.MediaPluginState>(videoPlayer_PlayStateChanged);
            videoPlayer.MediaOpened += new Action<SMFPlayer>(videoPlayer_MediaOpened);

Any assistance would be appreciated. Thank you!

 

Coordinator
Jul 1, 2010 at 12:49 AM

Just to make sure I understand, you want an event that tells you when the user has finished seeking?  Admittedly there's no good event to hook into that gives you that information.  Is this important to your application?  Are we missing a use case here?

Jul 1, 2010 at 1:19 AM

Thank you for your response. Yes, I was looking for an event that would tell me when the user has finished seeking. It's no longer important to my application as I've thought of a workaround.

I'm building a client that is Pay-Per-Minute friendly so I need to track (as accurately as possible) how long the user has watched the video. Instead of using SeekCompleted, I'm now using a timer that fires every 250ms and triggers this:

void myTimer_Tick(object sender, EventArgs e)
{

    if (lastKnownPosition < videoPlayer.PlaybackPosition.TotalSeconds)
    {

        if ((videoPlayer.PlaybackPosition.TotalSeconds - lastKnownPosition) > 1)
        {
            // fast-forward detected
            lastKnownPosition = videoPlayer.PlaybackPosition.TotalSeconds;
        }
        else
        {
            secondsUsed += (videoPlayer.PlaybackPosition.TotalSeconds - lastKnownPosition);
            lastKnownPosition = videoPlayer.PlaybackPosition.TotalSeconds;
        }

    }
    else if (lastKnownPosition > videoPlayer.PlaybackPosition.TotalSeconds)
    {
        // rewind detected
        lastKnownPosition = videoPlayer.PlaybackPosition.TotalSeconds;
    }

}
I'm still pretty new to Silverlight, and very new to SMF. If there would be a better way to accomplish all of this, I'd appreciate any information. Thanks again for getting back to me.

Jul 1, 2010 at 10:00 AM

I was using the onSeekCompleted with the previous version of SMF.

I'm currently using the PlayStateChanged event instead but it seems to be somewhat slow to fire after seeking.

I would like to see this event back in future versions of SMF.

Coordinator
Jul 2, 2010 at 12:49 AM

This will be available in the next drop of SMF v2.  Thanks for the feedback.