none
MediaElement fastForward problem...

    Question

  • Hi All,

    I have implemented some functions below to control video playback of MediaElement:

            public void Play(string filePath)
            {
                    if (this.playbackStatus != PlaybackStatus.Pause && filePath.Length > 0)
                    {
                        Stop();
                        this.mediaTimeLine = new MediaTimeline(new Uri(filePath, UriKind.RelativeOrAbsolute));

                        try
                        {
                            this.mElement.Source = new Uri(filePath);
                            this.prePlaybackFilePath = filePath;
                            this.mElement.Clock = this.mediaTimeLine.CreateClock();
                        }
                        catch (System.Runtime.InteropServices.COMException cex)
                        {
                            System.Diagnostics.Debug.WriteLine(cex.ToString());
                        }
                        catch (Exception ex)
                        {
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
                            this.mElement.Source = null;
                        }
                    }
                    if (this.mElement.Clock != null)
                    {
                        if (this.playbackStatus == PlaybackStatus.Pause)
                            this.mElement.Clock.Controller.Resume();
                        else
                            this.mElement.Clock.Controller.Begin();
                    }
            }

           public void FastForward()
           {
                ChangePlaybackSpeedRatio();
           }


           double[] speedRatioArray = new double[] { 1.0, 2.0, 4.0, 8.0, 20.0, 30.0 };

            private bool ChangePlaybackSpeedRatio()
            {
                    for (int i=0; i < this.speedRatioArray.Length; i++)
                    {
                        if (this.mElement.Clock.Controller.SpeedRatio == this.speedRatioArrayIdea)
                        {
                            this.mElement.Clock.Controller.SpeedRatio = ((i + 1) == this.speedRatioArray.Length) ?    this.speedRatioArray[0] : this.speedRatioArray[i + 1];
                            return true;
                        }
                    }
                }
                return false;
            }

    When I change the SpeedRatio from 1.0 to 2.0: the fastforward function works fine. However, if i increase SpeedRatio to 4.0, 8.0...step by step. The fastforward function seems work failed. (The video frame seems paused). Any one meet this kind of problem about MediaElement? BTW, how can i implement function FastBackward also?

     

    Any response is welcome!

    Thanks,

    Kimi

     

    Tuesday, July 25, 2006 4:11 AM

Answers

  • Unfortunately, increasing the speed ratio beyond 2 or 3 may yield unexpected results. There are many issues at play here… for example some video/audio CODECs don’t support smooth fast forwarding, some will just jump around between frames, and some (when playing a short video) may just jump to the end.



    One way to check what happens is using WMP, goto the View menu, under Enhancements, enable the Play Speed Settings. You should see similar results here.
    Tuesday, July 25, 2006 2:24 PM
    Moderator

All replies

  • Unfortunately, increasing the speed ratio beyond 2 or 3 may yield unexpected results. There are many issues at play here… for example some video/audio CODECs don’t support smooth fast forwarding, some will just jump around between frames, and some (when playing a short video) may just jump to the end.



    One way to check what happens is using WMP, goto the View menu, under Enhancements, enable the Play Speed Settings. You should see similar results here.
    Tuesday, July 25, 2006 2:24 PM
    Moderator
  • I asked this question also on StackOverflow: http://stackoverflow.com/questions/6957742/mediaelement-speedratio-not-linear/6960765#6960765

    Are there any codecs delivered with Windows 7 that do run smoothly and at the appropriate speed?

    Monday, August 08, 2011 7:17 AM