How to Set MediaElement Position Dynamically in Silverlight?
I am trying to set the Media Elements position by following code:
MediaElement musicPlayer = new MediaElement();
musicPlayer.Position = new TimeSpan(0, 0开发者_开发技巧, 30);
musicPlayer.Source = new Uri(strMediaFileURL, UriKind.RelativeOrAbsolute);
LayoutRoot.Children.Add(musicPlayer);
To Surprise, musicPlayer.Position remains unchanged while debugging , any help please?
Thanks, Subhendu
Try it like this:-
MediaElement musicPlayer = new MediaElement();
musicPlayer.MediaOpened += (s, args) =>
{
var player = (MediaElement)s;
if (player.CanSeek)
player.Position = new TimeSpan(0, 0, 30);
}
musicPlayer.Source = new Uri(strMediaFileURL, UriKind.RelativeOrAbsolute);
LayoutRoot.Children.Add(musicPlayer);
精彩评论