I am using silverlight 4 with smf and I want to create a play , pause toggle button. So if the media is playing and if the button is clicked it will pause the video. But if the media is paused, it will restart playing video. How can I do that

 private void btnPlay_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {



        }
有帮助吗?

解决方案

I don't know anything about silverlight, but you could use a boolean.

private void btnPlay_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
     if(isPlaying)
     {
         music.pause();
         isPlaying = FALSE;
         return;
     }

     music.play();
     isPlaying = TRUE;
     return;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top