开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜