0

I've been trying to loop a soundtrack using this:

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Music();

            MediaClock Repeater = new MediaClock(Timeline);

            AudioOutput.Clock = Repeater;

        }
        internal static MediaTimeline Timeline;

        public static void Music()
        {
            double numbers = 999999999999999999;
            RepeatBehavior repeatAlmostInfinitely = new RepeatBehavior(numbers);
            TimeSpan Duration = new TimeSpan(0, 0, 58);
            Duration duration = new Duration(Duration);
            TimeSpan? beginTime = new TimeSpan?();
            MediaTimeline mediatimeline = new MediaTimeline(beginTime, duration, repeatAlmostInfinitely);
            Timeline = mediatimeline;
        }

    }

But it says that " 'MediaClock.MediaClock(MediaTimeline)' is inaccessible due to its protection level. Is there a way to fix this?

1 Answers1

0

I suggest you use

private void mediaElement_OnMediaEnded(object sender, RoutedEventArgs e)
{
    mediaElement.Position = new TimeSpan(0,0,1);
    mediaElement.Play();
}

as someone stated here

Community
  • 1
  • 1
lokusking
  • 7,396
  • 13
  • 38
  • 57