MediaEnded, set starting frame, Position never updated

Nov 17, 2010 at 7:56 AM
Edited Nov 17, 2010 at 2:39 PM

i have a wmv and an mp4 that i'm playing with the MediaUriElement. when the video is done, the MediaEnded event fires, running the following:

player.MediaPosition = 10000000 / 2;                
player.Pause();

i need to reset the player to a certain position, which it does, and it pauses there. however, when i start playback again, the MediaPosition is now always reported back as 10000000 / 2 (= 5000000), even though the video is clearly being played through.

has anyone run into this before, and/or know of a way to fix it? (it happens with both the wmv and the mp4)

thanks!

jon

----

UPDATE: it seems once mediaended has fired, even if i don't do anything else, the position is never updated (when reading it) once i set it. not sure what i'm doing different in this project than in previous ones :\ (it must be something simple...)

Nov 19, 2010 at 8:31 PM

ok, i think i may have solved it, but i'm not sure i did The Right Thing -- in any case, i can get it to fire the positionchanged event after the media has ended by restarting the graph poll timer, which gets stopped, but apparently never restarted, in OnMediaEvent when the event code is Complete (StopGraphPollTimer() is called, stopping and disposing of the timer). (wow that was a long sentence.)

in BaseClasses.cs, i just added StartGraphPollTimer(); 

        /// <summary>
        /// Plays the media
        /// </summary>
        public virtual void Play()
        {
            VerifyAccess();

            StartGraphPollTimer();

            if (m_basicAudio != null)
            {
                //Balance = Balance;
                //Volume = Volume;
            }

            if (m_mediaControl != null)
                m_mediaControl.Run();
        }

Mar 3, 2014 at 12:52 PM
had the same problem. Worked for me too. thx :)