HOW TO SET POSITION OF MEDIAELEMENT?

Ankita Pandey

Total Post:183

Points:1285
Posted by  Ankita Pandey
C# 
C#
 1239  View(s)
Ratings:
Rate this:

I have this button:

private void Answer1_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)

{

    MediaElement1.Play();

}

The problem is that if I click it and then quickly click it again the sound will just continue to play from the position it was when I pressed it again.

What I want is to make the sound replay from the start 0,0. So I thought I may could do it by maybe setting the sound position to 0,0 in the button in the previous line of MediaElement1.Play();.

If you know any better solution is good too.

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: How to set position of MediaElement?

    Hi Ankita.

    Yes, just set the Position property:

    MediaElement1.Position = TimeSpan.Zero;

    MediaElement1.Play();

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!