i have a page transition control in the MainWindow ( theres few buttons and a home button that leads to the homepage), so i click a button on the MainWindow that brings a user control page inside the page transition within the MainWindow , theres an audio to be played in that user control page , ok fine but when i click the home button to show the homepage , the audio from that user control page is still playing . How can i stop the user control page from running in the background?
this is how i call the user control page into the page transition control in the mainwindow :
private void button2_Click(object sender, RoutedEventArgs e) // Story
{
Story page = new Story();
pageTransition1.IsEnabled = true;
pageTransition1.Visibility = System.Windows.Visibility.Visible;
grid1.Visibility = System.Windows.Visibility.Hidden;
pageTransition1.ShowPage(page);
}
private void button5_Click(object sender, RoutedEventArgs e) // Home Button
{
pageTransition1.Visibility = System.Windows.Visibility.Hidden;
pageTransition1.IsEnabled = false;
grid1.Visibility = System.Windows.Visibility.Visible;
}
Basically i just want the user control page to stop running ( cos its running in the background) when i click the home button.
How i play my sound in my user control page ::
mediaElement1.LoadedBehavior = MediaState.Manual;
mediaElement1.Source = new Uri(audioNames[iCurrentImageCount], UriKind.RelativeOrAbsolute);
mediaElement1.Play();
and
MediaPlayer ap = new MediaPlayer();
recordedaudio = System.IO.Directory.GetFiles(@"../../Audio/", "*.wav");
if (recordedaudio == null)
{ MessageBox.Show("No Recorded Files!"); }
else
{
ap.Open(new Uri(recordedaudio[iCurrentImageCount], UriKind.RelativeOrAbsolute));
ap.Play();
}