WPF Storyboard delay in playing wma files
Posted
by Rita
on Stack Overflow
See other posts from Stack Overflow
or by Rita
Published on 2010-06-18T15:53:17Z
Indexed on
2010/06/18
16:23 UTC
Read the original article
Hit count: 486
I'm a complete beginner in WPF and have an app that uses StoryBoard to play a sound.
public void PlaySound()
{
MediaElement m = (MediaElement)audio.FindName("MySound.wma");
m.IsMuted = false;
FrameworkElement audioKey = (FrameworkElement)keys.FindName("MySound");
Storyboard s = (Storyboard)audioKey.FindResource("MySound.wma");
s.Begin(audioKey);
}
<Storyboard x:Key="MySound.wma">
<MediaTimeline d:DesignTimeNaturalDuration="1.615" BeginTime="00:00:00" Storyboard.TargetName="MySound.wma" Source="Audio\MySound.wma"/>
</Storyboard>
I have a horrible lag and sometimes it takes good 10 seconds for the sound to be played. I suspect this has something to do with the fact that no matter how long I wait - The sound doesn't get played until after I leave the function. I don't understand it. I call Begin, and nothing happens. Is there a way to replace this method, or StoryBoard object with something that plays instantly and without a lag?
© Stack Overflow or respective owner