<commit_before>function MoonshineSeekBar (media_element) {
    MtkSlider.call (this);
    
    this.LiveSeekJitterThreshold = 4;
    this.LiveSeekSpeed = 500;
    
    this.media_element = media_element;
    this.is_tick_updating = false;
    this.allowed_to_seek = false;
    this.live_seek_timeout = null;
    this.last_live_seek_value = -100;
    this.mouse_down = false;
    
    this.SliderEnabled = false;
    
    this.Override ("OnRealize", function () {
        this.$OnRealize$ ();
        if (!this.IsRealized) {
            return;
        }
        
        this.media_element.AddEventListener ("PlayTick", delegate (this, this.OnPlayTick));
        
        this.media_element.AddEventListener ("MediaOpened", delegate (this, function () {
            this.SliderEnabled = this.media_element.CanSeek;
        }));
        
        this.media_element.AddEventListener ("Idle", delegate (this, function () {
            this.SliderEnabled = false;
            this.Value = 0;
        }));
    });
    
    this.Override ("OnValueChanged", function (value) {
        if (this.allowed_to_seek && !this.is_tick_updating) {
            this.$OnValueChanged$ (value);
            
            if (this.media_element.CanSeek && !this.media_element.IsLive) {
                var position = value * this.media_element.NaturalDuration.Seconds;
                this.media_element.Position = "0:0:" + position;
            }
        }
    });
    
    this.Override ("OnDragBegin", function () {
        this.$OnDragBegin$ ();
        this.live_seek_timeout = setInterval (delegate (this, this.OnLiveSeekTimeout), this.LiveSeekSpeed);
    });
    
    this.Override ("OnDragEnd", function () {
        this.$OnDragEnd$ ();
        clearInterval (this.live_seek_timeout);
        this.live_seek_timeout = null;
        this.allowed_to_seek = true;
        this.OnValueChanged (this.Value);
        this.allowed_to_seek = false;
    });
    
    this.Override ("OnMouseDown", function () {
        this.mouse_down = true;
        this.$OnMouseDown$ ();
    });
    
    this.Override ("OnMouseUp", function () {
        this.$OnMouseUp$ ();
        this.allowed_to_seek = true;
        this.OnValueChanged (this.Value);
        this.allowed_to_seek = false;
        this.mouse_down = false;
    });
    <commit_msg>Fixed seek bug<commit_after>function MoonshineSeekBar (media_element) {
    MtkSlider.call (this);
    
    this.LiveSeekJitterThreshold = 4;
    this.LiveSeekSpeed = 500;
    
    this.media_element = media_element;
    this.is_tick_updating = false;
    this.allowed_to_seek = false;
    this.live_seek_timeout = null;
    this.last_live_seek_value = -100;
    this.mouse_down = false;
    
    this.SliderEnabled = false;
    
    this.Override ("OnRealize", function () {
        this.$OnRealize$ ();
        if (!this.IsRealized) {
            return;
        }
        
        this.media_element.AddEventListener ("PlayTick", delegate (this, this.OnPlayTick));
        
        this.media_element.AddEventListener ("MediaOpened", delegate (this, function () {
            this.SliderEnabled = this.media_element.CanSeek;
        }));
        
        this.media_element.AddEventListener ("Idle", delegate (this, function () {
            this.SliderEnabled = false;
            this.Value = 0;
        }));
    });
    
    this.Override ("OnValueChanged", function (value) {
        if (this.allowed_to_seek && !this.is_tick_updating) {
            this.$OnValueChanged$ (value);
            
            if (this.media_element.CanSeek && !this.media_element.IsLive) {
                var position = value * this.media_element.NaturalDuration.Seconds;
                this.media_element.Position = "0:0:" + position;
            }
        }
    });
    
    this.Override ("OnDragBegin", function () {
        this.$OnDragBegin$ ();
        this.live_seek_timeout = setInterval (delegate (this, this.OnLiveSeekTimeout), this.LiveSeekSpeed);
    });
    
    this.Override ("OnDragEnd", function () {
        if (!this.IsDragging) {
            return;
        }
        
        this.$OnDragEnd$ ();
        clearInterval (this.live_seek_timeout);
        this.live_seek_timeout = null;
        this.allowed_to_seek = true;
        this.OnValueChanged (this.Value);
        this.allowed_to_seek = false;
    });
    
    this.Override ("OnMouseDown", function () {
        this.mouse_down = true;
        this.$OnMouseDown$ ();
    });
    
    this.Override ("OnMouseUp", function () {
        this.$OnMouseUp$ ();
        this.allowed_to_seek = true;
        this.OnValueChanged (this.Value);
        this.allowed_to_seek = false;
        this.mouse_down = false;
    });
    
{'fraction_non_alphanumeric': 0.12106382978723404, 'fraction_numerical': 0.00425531914893617, 'mean_word_length': 2.12982689747004, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1436178', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1404, 'n_words': 229}