Media Element Issues with Migration to Consumer Preview


  • Hello,

    I had an app working on the Developer Preview, and now that it's on the Consumer Preview, things have changed.

    My app is very heavily based on playing videos and swapping seamlessly between those videos. In the DP, there were no issues with this but now in CP I'm having issues with a frame of grey in between the two videos as I swap them, and also if I wanted to start a video not at the beginning (say 150 frames in), it flashes the first frame of the video. So, when I change a video I get a flash of grey and then a flash of the first frame of the video. After that there are no problems.

    The method I'm using to change videos is: MediaElement->Source = this->BaseUri->CombineUri( "String that references new video file on system" );

    I would appreciate any help in this issue. Thanks.

    EDIT: I've looked more into the issue by creating a basic media element project, and I believe that they grey frame flash is just an optimization issue. I need to do less between videos so that the next video can load in faster. When I have just two videos switching between each other at the end of the video they transition as I need them to. The first frame is still not working however, I still get the flash of the first frame. Anyone know how to start a video at a certain point rather than the beginning?
    • Edited by DLAlex Thursday, April 12, 2012 7:29 PM Update
    Thursday, April 12, 2012 5:16 PM

All replies

  • Hello DLAlex,

    Every time you set the Media Element's source you are rebuilding the underlying Media Foundation topology. Doing this naturally invalidates the D3D surface that was being used by the frame server. It sounds like the swap is occuring before the first frame of video is queued. This is likely just the way the XAML rich compositor is interacting with the Media Engine's frame server. I honestly can't think of an easy way to fix this if the problem is in the swap chain.

    That said I don't know why you would be seeing grey. I would assume that the surface would default to all black on initialization.

    Does this in any way answer your question or am I just off in the weeds?

    I hope this helps,


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Friday, April 13, 2012 12:50 AM
  • It helps me understand what's happening. So I do appreciate that. I'm guessing it's grey because of the fact that my theme colours that I've set has the Metro UI background as grey. Could that be correct?

    As for the help, I've said in my edit that I just need to cut down on my activity between the video swap because it doesn't seem to have any flash when I use a skeleton version of my code, that just swaps between two videos.

    My main issue is now more about the starting a video at a frame other than 0 and not having the first frame of the video flash before the video seeks forward. Any way you can think to do this?

    At the moment I'm waiting for a video to end, then stopping the MediaElement, then I open the next video, wait for the mediaOpened event. Once I get that event I set the position to where I want it to start from and wait for the SeekCompleted event, where I start the video again. Is this a correct method or am I doing too much?

    Thanks for your help James, it's really appreciated.

    Friday, April 13, 2012 12:28 PM
  • Hello DLAlex,

    I think that you are doing everything correctly. I don't know of any way off the top of my head to improve what you are already doing.



    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, April 17, 2012 12:29 AM