How to control MediaElement playback with a Storyboard?
-
Monday, April 16, 2012 1:55 PMIn Silverlight/WPF we had the MediaTimeLine, which allowed us to control a MediaElement's playback using a storyboard. How can we accomplish this in a Metro app? I want to control playback without using code-behind, strictly using binding. Is this possible?
- Moved by Rob CaplanMicrosoft Employee, Moderator Monday, April 16, 2012 8:35 PM (From:UI Design for Metro style apps)
All Replies
-
Tuesday, April 17, 2012 12:27 PMThis topic was moved by the moderator to the C#/VB forum, but I would like to reiterate that I am looking for a XAML-only approach to playing a sound, e.g. as part of a Storyboard.
-
Tuesday, April 17, 2012 9:55 PMModerator
Hello Gspence,
You should be able to accomplish this by binding the position property of the timeline to the position property of the MediaElement. I seem to remember on the engineers I worked with in the past doing this successfully in SL. Please give this a try and let me know if you have any specific questions about the implementation and I will try to help you out.
Thanks,
James
Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
- Proposed As Answer by James Dailey - MSFTMicrosoft Employee, Moderator Tuesday, April 17, 2012 9:55 PM
- Unproposed As Answer by gspence Wednesday, April 18, 2012 11:41 AM
-
Wednesday, April 18, 2012 2:11 AM
James,
The MediaTimeLine that we had in Silverlight is not present in Metro, so I don't think there's anything to bind with the MediaElement's Position property.
Thanks,
gspence
-
Wednesday, April 18, 2012 7:43 PMYou probably would have to create separate component (something like a behaviour) with dependency property that can be manipulated from story board and drive sound playback.
-
Thursday, April 19, 2012 10:57 PMModerator
If you can figure out how to get the current position of the timeline you should be able to do something like this to bind to the MediaElement. Keep in mind that the ME current position is defined as a "TimeSpan" so you might need to write a converter.
<MediaElement x:Name="_me" Position="{Binding Value}"/>I hope this helps,
James
Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
- Proposed As Answer by James Dailey - MSFTMicrosoft Employee, Moderator Thursday, April 19, 2012 10:57 PM
- Marked As Answer by Min ZhuMicrosoft Contingent Staff, Moderator Tuesday, May 01, 2012 2:14 AM


