<commit_before>//  Exposed globally so that Chrome Extension's foreground can access through chrome.extension.getBackgroundPage()
var YouTubePlayer = null;

define([
    'youTubePlayerAPI',
    'settings',
    'playerState'
], function (YouTubePlayerAPI, Settings, PlayerState) {
    'use strict';

    //  This is the actual YouTube Player API object housed within the iframe.
    var youTubePlayer = null;

    var youTubePlayerModel = Backbone.Model.extend({
        defaults: {
            //  Returns the elapsed time of the currently loaded video. Returns 0 if no video is playing
            currentTime: 0,
            //  API will fire a 'ready' event after initialization which indicates the player can now respond accept commands
            ready: false,
            state: PlayerState.UNSTARTED,
            //  This will be set after the player is ready and can communicate its true value.
            //  Default to 50 because having the music on and audible, but not blasting, seems like the best default if we fail for some reason.
            volume: 50,
            //  This will be set after the player is ready and can communicate its true value.
            muted: false,
            loadedVideoId: ''
        },
        
        //  Initialize the player by creating a YouTube Player IFrame hosting an HTML5 player
        initialize: function () {
            var self = this;
   
            //  Update the volume whenever the UI modifies the volume property.
            this.on('change:volume', function (model, volume) {
                self.set('muted', false);
                //  We want to update the youtube player's volume no matter what because it persists between browser sessions
                //  thanks to YouTube saving it -- so should keep it always sync'ed.
                youTubePlayer.setVolume(volume);
            });

            this.on('change:muted', function (model, isMuted) {

                //  Same logic here as with the volume
                if (isMuted) {
                    youTubePlayer.mute();
                } else {
                    youTubePlayer.unMute();
                }

            });

            var refreshPausedVideoInterval = null;
            this.on('change:state', function (model, state) {

                clearInterval(refreshPausedVideoInterval);
       
                if (state === PlayerState.PAUSED) {

                    //  Start a long running timer when the player becomes paused. This is because a YouTube video
                    //  will expire after ~8+ hours of being loaded. This only happens if the player is paused.
                    //  Refresh videos after every 8 hours.
                    var eightHoursInMilliseconds = 28800000;

                    refreshPausedVideoInterval = setInterval(function () {
                        
                        self.loadVideoById(self.get('loadedVideoId'), self.get('currentTime'));

                    }, eightHoursInMilliseconds);

                }

            });
            
            chrome.runtime.onConnect.addListener(function(port) {
<commit_msg>Was loading when should've been cueing.<commit_after>//  Exposed globally so that Chrome Extension's foreground can access through chrome.extension.getBackgroundPage()
var YouTubePlayer = null;

define([
    'youTubePlayerAPI',
    'settings',
    'playerState'
], function (YouTubePlayerAPI, Settings, PlayerState) {
    'use strict';

    //  This is the actual YouTube Player API object housed within the iframe.
    var youTubePlayer = null;

    var youTubePlayerModel = Backbone.Model.extend({
        defaults: {
            //  Returns the elapsed time of the currently loaded video. Returns 0 if no video is playing
            currentTime: 0,
            //  API will fire a 'ready' event after initialization which indicates the player can now respond accept commands
            ready: false,
            state: PlayerState.UNSTARTED,
            //  This will be set after the player is ready and can communicate its true value.
            //  Default to 50 because having the music on and audible, but not blasting, seems like the best default if we fail for some reason.
            volume: 50,
            //  This will be set after the player is ready and can communicate its true value.
            muted: false,
            loadedVideoId: ''
        },
        
        //  Initialize the player by creating a YouTube Player IFrame hosting an HTML5 player
        initialize: function () {
            var self = this;
   
            //  Update the volume whenever the UI modifies the volume property.
            this.on('change:volume', function (model, volume) {
                self.set('muted', false);
                //  We want to update the youtube player's volume no matter what because it persists between browser sessions
                //  thanks to YouTube saving it -- so should keep it always sync'ed.
                youTubePlayer.setVolume(volume);
            });

            this.on('change:muted', function (model, isMuted) {

                //  Same logic here as with the volume
                if (isMuted) {
                    youTubePlayer.mute();
                } else {
                    youTubePlayer.unMute();
                }

            });

            var refreshPausedVideoInterval = null;
            this.on('change:state', function (model, state) {

                clearInterval(refreshPausedVideoInterval);
       
                if (state === PlayerState.PAUSED) {

                    //  Start a long running timer when the player becomes paused. This is because a YouTube video
                    //  will expire after ~8+ hours of being loaded. This only happens if the player is paused.
                    //  Refresh videos after every 8 hours.
                    var eightHoursInMilliseconds = 28800000;

                    refreshPausedVideoInterval = setInterval(function () {
                        
                        self.cueVideoById(self.get('loadedVideoId'), self.get('currentTime'));

                    }, eightHoursInMilliseconds);

                }

            });
            
            chrome.runtime.onConnect.addListener(function(port) {

{'fraction_non_alphanumeric': 0.07112103332801786, 'fraction_numerical': 0.005421782809759209, 'mean_word_length': 1.7281426707264027, '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': '4797203', 'n_tokens_mistral': 1531, 'n_tokens_neox': 1399, 'n_words': 563}