Answered Sync Multiple MediaElements To a Single Timeline

  • Thursday, April 12, 2012 1:37 PM
     
     

    I would like to know the best way to sync two media elements and control their playback using a single timeline. So, I would like them to start/stop/seek, etc. in synchrony. I have achieved similar functionality in WPF the past using a Storyboard with multiple MediaTimeline children. I don't see the MediaTimeline class anywhere.

    Regards,

     

    http://babaandthepigman.spaces.live.com/blog/

All Replies

  • Monday, April 16, 2012 7:18 PM
    Moderator
     
     
    Hi Baba - I'll forward this to our media guru.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator

  • Wednesday, April 18, 2012 10:02 PM
    Moderator
     
     Answered

    Hello Baba,

    Unfortunately we don't have a MediaTimeline in Metro style XAML. The simple way of doing this is to bind to the "current position" property on the ME and allow data binding to handle the synchronization. I understand that this is certainly a less than perfect solution. Unfortunately with the nature of the Media Element it is going to be virtually impossible to achieve frame accurate synchronization between two separate MediaElements. The only way to get close to frame accurate synchronization is to create your own implementation using the raw Media Engine components and D3D.

    I hope this helps,

    James


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

  • Wednesday, April 18, 2012 11:03 PM
     
     

    Hi James,

    Thanks for the reply, I had a feeling that would be the case. I have an existing wpf app which I would ideally like to port to metro. i'm guessing that I would be able to use media foundation to achieve the clock synchronisation I am currently considering a re-write using c++ hopefully being able to retain most of the xaml and maybe using swapchainbackgroundpanel. Does that sound to you like a reasonable strategy bearing in mind that I need the synchronisation but would also like to salvage as much as I can from the current app?


    http://babaandthepigman.spaces.live.com/blog/

  • Friday, April 20, 2012 12:08 AM
    Moderator
     
     

    Hello Baba,

    That sounds like a good plan. However, I haven't actually tried using this class. You need to verify that when using this method you are calling "present" and not the XAML framework. If the framework is driving the frame rate you could drop frames. If you are driving the frame rate then you can control what happens when the renderer gets behind.

    -James


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

  • Friday, April 20, 2012 8:10 AM
     
     
    Ok, thanks James - I'll give it a try.

    http://babaandthepigman.spaces.live.com/blog/

  • Monday, July 16, 2012 5:41 PM
     
     

    Hi Baba,

    While there is no MediaTimeLine we do have TimelineMarkersCollection. You can manually add markers that will fire at regular intervals and manually sync the two MediaElements positions.

    Regards,

    Sunil