<commit_before>﻿namespace Gu.Wpf.Media
{
    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Input;
    using System.Windows.Threading;

    public partial class MediaElementWrapper : Decorator
    {
        private readonly DispatcherTimer updatePositionTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.1) };
        private readonly DispatcherTimer updateProgressTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
        private readonly MediaElement mediaElement;

        /// <summary>Initializes a new instance of the <see cref="MediaElementWrapper"/> class.</summary>
        public MediaElementWrapper()
        {
            this.mediaElement = new MediaElement
            {
                LoadedBehavior = MediaState.Manual,
                UnloadedBehavior = MediaState.Manual,
            };

            this.mediaElement.MediaFailed += this.ReRaiseEvent;
            this.mediaElement.MediaEnded += this.ReRaiseEvent;
            this.mediaElement.BufferingStarted += (o, e) =>
                {
                    this.IsBuffering = true;
                    this.updateProgressTimer.Start();
                    this.ReRaiseEvent(o, e);
                };
            this.mediaElement.BufferingEnded += (o, e) =>
                {
                    this.IsBuffering = true;
                    this.updateProgressTimer.Start();
                    this.ReRaiseEvent(o, e);
                };
            this.mediaElement.ScriptCommand += this.ReRaiseEvent;
            this.mediaElement.MediaOpened += (o, e) =>
            {
                this.Pause();
                this.Length = this.mediaElement.NaturalDuration.TimeSpan;
                this.CanPauseMedia = this.mediaElement.CanPause;<commit_msg>BUGFIX: start and stop updateProgressTimer correctly.<commit_after>﻿namespace Gu.Wpf.Media
{
    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Input;
    using System.Windows.Threading;

    public partial class MediaElementWrapper : Decorator
    {
        private readonly DispatcherTimer updatePositionTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.1) };
        private readonly DispatcherTimer updateProgressTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
        private readonly MediaElement mediaElement;

        /// <summary>Initializes a new instance of the <see cref="MediaElementWrapper"/> class.</summary>
        public MediaElementWrapper()
        {
            this.mediaElement = new MediaElement
            {
                LoadedBehavior = MediaState.Manual,
                UnloadedBehavior = MediaState.Manual,
            };

            this.mediaElement.MediaFailed += this.ReRaiseEvent;
            this.mediaElement.MediaEnded += this.ReRaiseEvent;
            this.mediaElement.BufferingStarted += (o, e) =>
                {
                    this.IsBuffering = true;
                    this.updateProgressTimer.Start();
                    this.ReRaiseEvent(o, e);
                };
            this.mediaElement.BufferingEnded += (o, e) =>
                {
                    this.IsBuffering = true;
                    this.updateProgressTimer.Stop();
                    this.ReRaiseEvent(o, e);
                };
            this.mediaElement.ScriptCommand += this.ReRaiseEvent;
            this.mediaElement.MediaOpened += (o, e) =>
            {
                this.Pause();
                this.Length = this.mediaElement.NaturalDuration.TimeSpan;
                this.CanPauseMedia = this.mediaElement.CanPause;
{'fraction_non_alphanumeric': 0.08854306412664341, 'fraction_numerical': 0.0016098738932116983, 'mean_word_length': 1.883217324052591, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7039931', 'n_tokens_mistral': 960, 'n_tokens_neox': 911, 'n_words': 178}