locked
Windows Media Player 9 vs WMP12 RRS feed

  • Question

  •  

    We have integrated Windows Media Player control in our application. We were using Windows Media Player 9, on Windows XP. In application it had to play video materials at faster rate and was supporting rates of x1.8, x2, x4 and x8 for WMV files. It worked well having continuous display of video material, but problems are occurring with Widows Media Player versions above version 9. Keeping Windows Media Payer 9 on Windows XP solves issues on that platform but problem is with Windows 7 on witch installing it is impossible and thus having to use Windows Media Player 12.The problem we are facing is that when play speed is set to higher than x2 video reproduction is not continuous. As to my knowledge, please correct me if I am wrong, on higher reproduction speed player starts thinning, discarding delta frames, and only showing key frames of video which results in keeping shown frames for longer period than they should (around 1 second). This behavior is demonstrating while reproduction of MPEG-4 and WMV videos but not for MPEG-2 videos. MPEG-2 videos have continuous reproduction even on x8 rate what is wanted behavior. Code that we used for setting rate is added at the end of document. Also there is problem with time skipping in WMV files. Even thou it is set to jump for i.e. 5 seconds video do jump for that amount but than it goes back for 2 to 3 seconds, and if it’s set to jump for 1 second due to going back for those 2-3 seconds it will rewind back for 1-2 seconds what is inconvenient feature.Application is written in C#.Net using .Net framework 3.5 and Windows Media Player ActiveX control, and, just to mention, described problems also occurs in stand alone Windows Media Player.We are interested if it possible to have continuous video reproduction with speed faster than x2, with minimum of x4, for MPEG-4 and WMV videos and, if it is, by what condition it is possible, and how to set precise time skipping without rewinds.

     

    Tuesday, January 31, 2012 6:49 PM

All replies

  • Code used for setting video playback speed.
    
    private void trackBarControl1_ValueChanged(object sender, EventArgs e)
            {
                // Test whether playback rate can be set. 
                if(axCompositeWindowsMediaPlayer.settings.get_isAvailable("Rate"))
                {
                    int value = ((TrackBarControl)sender).Value;
                    double newRate = 1;
      
                    switch (value)
                    {
                        case 0:
                            newRate = 0.5;
                            break;
                        case 1:
                            newRate = 1;
                            break;
                        case 2:
                            newRate = 1.5;
                            break;
                        case 3:
                            newRate = 1.8;
                            break;
                        case 4:
                            newRate = 2;
                            break;
                        case 5:
                            newRate = 2.5;
                            break;
                        case 6:
                            newRate = 3;
                            break;
                        case 7:
                            newRate = 4;
                            break;
                        case 8:
                            newRate = 8;
                            break;
                        case 9:
                            newRate = 12;
                            break;
                        case 10:
                            newRate = 16;
                            break;
                        case 11:
                            newRate = 32;
                            break;
                    }
                     // Set the playback rate to the new value.
                    axCompositeWindowsMediaPlayer.settings.rate = newRate;
                }
            }
    
    private WMPExt axCompositeWindowsMediaPlayer;
    
    public class WMPExt : AxWMPLib.AxWindowsMediaPlayer
        {
            public WMPExt()
                : base()
            {
                this.SetStyle(ControlStyles.Selectable, false);
            }
        }
    
    
    Code used for time skipping:
    
    private void CompositeWMP_KeyUp(object sender, KeyEventArgs e)
            {
                //Novo
     
                if (e.Control == true && e.Alt == false && e.Shift == false)
                {
                    if (e.KeyCode == Keys.E)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        MakeSnapshot();
                        return;
                    }
                    else if (e.KeyCode == Keys.Space)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        Stop();
                        return;
                    }
                    else if (e.KeyCode == Keys.Left)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        if (axCompositeWindowsMediaPlayer.playState != WMPLib.WMPPlayState.wmppsPaused)
                        {
                            SkipBackward(CtrlJump);
                        }
                        else
                        {
                            SkipBackward(CtrlJump);
                            Play();
                            Pause();
                        }
                        return;
                    }
                    else if (e.KeyCode == Keys.Right)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        if (axCompositeWindowsMediaPlayer.playState != WMPLib.WMPPlayState.wmppsPaused)
                        {
                            SkipForward(CtrlJump);
                        }
                        else
                        {
                            SkipForward(CtrlJump);
                            Play();
                            Pause();
                        }
                        return;
                    }
                }
                else if (e.Control == false && e.Alt == false && e.Shift == true)
                {
                    if (e.KeyCode == Keys.Left)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        if (axCompositeWindowsMediaPlayer.playState != WMPLib.WMPPlayState.wmppsPaused)
                        {
                            SkipBackward(ShiftJump);
                        }
                        else
                        {
                            SkipBackward(ShiftJump);
                            Play();
                            Pause();
                        }
                        return;
                    }
                    else if (e.KeyCode == Keys.Right)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        if (axCompositeWindowsMediaPlayer.playState != WMPLib.WMPPlayState.wmppsPaused)
                        {
                            SkipForward(ShiftJump);
                        }
                        else
                        {
                            SkipForward(ShiftJump);
                            Play();
                            Pause();
                        }
                        return;
                    }
                }
                else if (e.Control == false && e.Alt == false && e.Shift == false)
                {
                    if (e.KeyCode == Keys.Space)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        PlayPause();
                        return;
                    }
                    else if (e.KeyCode == Keys.Left)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        if (engageFastForward == false)
                        {
                            timerFastForward.Enabled = false;
                            if (axCompositeWindowsMediaPlayer.playState != WMPLib.WMPPlayState.wmppsPaused)
                            {
                                SkipBackward();
                            }
                            else
                            {
                                SkipBackward();
                                Play();
                                Pause();
                            }
                        }
                        else
                        {
                            timerFastForward.Enabled = false;
                            engageFastForward = false;
                            timerInverse.Enabled = false;
                            FFDirection = 0;
                            trackBarControl1_ValueChanged(trackBarControl1, null);//Vrati na "normalnu" brzinu
                            
                        }
                        return;
                    }
                    else if (e.KeyCode == Keys.Right)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        if (engageFastForward == false)
                        {
                            //EventLog.WriteEntry("RRATEST", DateTime.Now.ToString("dd.MM.yyyy. hh:mm:ss.fff"), EventLogEntryType.Information, 0, 2);
                            timerFastForward.Enabled = false;
                            trackBarControl1_ValueChanged(trackBarControl1, null);
                            if (axCompositeWindowsMediaPlayer.playState != WMPLib.WMPPlayState.wmppsPaused)
                            {
                                SkipForward();
                            }
                            else
                            {
                                SkipForward();
                                Play();
                                Pause();
                            }
                        }
                        else
                        {
                            //EventLog.WriteEntry("RRATEST", DateTime.Now.ToString("dd.MM.yyyy. hh:mm:ss.fff"), EventLogEntryType.Information, 0, 3);
                            timerFastForward.Enabled = false;
                            engageFastForward = false;
                            FFDirection = 0;
                            double normalSpeed = GetTrackBarSpeed();
                            trackBarControl1_ValueChanged(trackBarControl1, null);
    
                            while (Speed != normalSpeed)
                            {
                                axCompositeWindowsMediaPlayer.settings.rate = normalSpeed;
                                return;
                    }
                    else if (e.KeyCode == Keys.Up)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        IncreaseVolume(10);
                        return;
                    }
                    else if (e.KeyCode == Keys.Down)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        DecreaseVolume(10);
                        return;
                    }
                    else if (e.KeyCode == Keys.F10)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        Open();
                        return;
                    }
                    else if (e.KeyCode == Keys.C)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        IncreaseSpeed();
                        return;
                    }
                    else if (e.KeyCode == Keys.X)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        DecreaseSpeed();
                        return;
                    }
                    else if (e.KeyCode == Keys.Z)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        SetNormalSpeed();
                        return;
                    }
                    else if (e.KeyCode == Keys.M)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        if (trackBarControl3.Value != trackBarControl3.Properties.Minimum)
                            trackBarControl3.Value -= 1;
                        //IncreaseSpeed();
                        return;
                    }
                    else if (e.KeyCode == Keys.N)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        if (trackBarControl3.Value != trackBarControl3.Properties.Maximum)
                            trackBarControl3.Value += 1;
                        //DecreaseSpeed();
                        return;
                    }
                    else if (e.KeyCode == Keys.B)
                    {
                        e.SuppressKeyPress = true;
                        e.Handled = true;
                        trackBarControl3.Value = trackBarControl3.Properties.Maximum;
                        return;
                    }
                }
                else if(e.Control==true && e.Alt==true && e.KeyCode==Keys.F12)
                {
                    if (axCompositeWindowsMediaPlayer.playState != WMPLib.WMPPlayState.wmppsPlaying && axCompositeWindowsMediaPlayer.playState != WMPLib.WMPPlayState.wmppsPaused && axCompositeWindowsMediaPlayer.playState != WMPLib.WMPPlayState.wmppsScanForward && axCompositeWindowsMediaPlayer.playState != WMPLib.WMPPlayState.wmppsScanReverse)
                    {
                        panelOptions.Visible = true;
                    }
                }
     
     
            }
     
    	/// <summary>
            /// Skips the backward in seconds
            /// </summary>
            /// <param name="i">The number of seconds.</param>
            public void SkipBackward()
            {
                if (axCompositeWindowsMediaPlayer.currentMedia != null)
                {
                    if ((int)axCompositeWindowsMediaPlayer.Ctlcontrols.currentPosition >= jumpInterval)
                    {
                        axCompositeWindowsMediaPlayer.Ctlcontrols.currentPosition = (int)axCompositeWindowsMediaPlayer.Ctlcontrols.currentPosition - jumpInterval;
                    }
                }
            }
     
            /// <summary>
            /// Skips the forward in seconds.
            /// </summary>
            /// <param name="i">The number of seconds</param>
            public void SkipForward(int i)
            {
                if (axCompositeWindowsMediaPlayer.currentMedia != null)
                {
                    if ((int)axCompositeWindowsMediaPlayer.Ctlcontrols.currentPosition + i <= axCompositeWindowsMediaPlayer.currentMedia.duration)
                    {
                        axCompositeWindowsMediaPlayer.Ctlcontrols.currentPosition = (int)axCompositeWindowsMediaPlayer.Ctlcontrols.currentPosition + i;
                    }
                }
            }
    
    

     


    BB
    Thursday, February 2, 2012 12:33 PM