Yep I am having the same problem, but I did not yet have any answers... Does anyone here can help us?
mneves
2010-03-17 00:48:22
Yep I am having the same problem, but I did not yet have any answers... Does anyone here can help us?
I had a similar problem too, found the only way around it was to create the media element dynamically. Heres the code, I had a MediaElement in the XAML called mePlayClick but you may not need or want that.
private void Play_MediaSound()
{
// Create new media element dynamically
MediaElement mediaElement = new MediaElement();
// Reuse settings in XAML
mediaElement.Volume = mePlayClick.Volume;
mediaElement.Source = mePlayClick.Source;
mediaElement.AutoPlay = mePlayClick.AutoPlay;
// WHen the media ends, remove the media element
mediaElement.MediaEnded += (sender, args) =>
{
LayoutRoot.Children.Remove(mediaElement);
mediaElement = null;
};
// Add the media element, must be in visual ui tree
LayoutRoot.Children.Add(mediaElement);
// When opened, play
mediaElement.MediaOpened += (sender, args) =>
{
mediaElement.Play();
};
}