& # 39; MediaClock.MediaClock (MediaTimeline) & # 39;由于其保护级别

本文关键字:MediaClock 保护 于其 MediaTimeline | 更新日期: 2023-09-27 17:51:20

我一直在尝试使用这个来循环配乐:

    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;
        }
    }

但是它说" 'MediaClock.MediaClock(mediatiline)'由于其保护级别而无法访问。有办法解决这个问题吗?

& # 39; MediaClock.MediaClock (MediaTimeline) & # 39;由于其保护级别

我建议你使用

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

就像有人在这里说的