<commit_before>var events = require('events');

function Player(player, queue) {
    this.player = player;
    this.isPlaying = false;
    this.queue = queue;

    events.EventEmitter.call(this);

    queue.on("change", function () {
        var newTrack = queue.getCurrentTrack()
        if (newTrack != this.currentTrack) {
            if (newTrack == null) {
                this.stop();
                this.currentTrack = null;
                this.changedCurrent();
            } else {
                this.playTrack(newTrack);
            }
        }
    }.bind(this));
}

Player.prototype = {
    playTrack: function (track) {
        this.player.stop();
        this.queue.loadTrack(track).then(function (track) {
            if ("undefined" === typeof track) {
                this.isPlaying = false;
                this.emit("playState", this.isPlaying)
                this.changedCurrent();
                this.stop();
                return;
            }
            try {
                this.currentTrack = track;
                console.log('Playing: %s - %s', track.artists[0].name, track.name);
                this.player.play(track);
                this.isPlaying = true;
                this.emit("playState", this.isPlaying)
                this.changedCurrent();
            } catch (e) {
                console.error(e);
                this.emit("playError", {e: e, track: this.getCurrentTrack()});
                this.queue.next();
            }
        }.bind(this));
    },
    getPlayingTrack: function () {
        return this.currentTrack;
    },
    play: function () {
        this.resume();
        this.isPlaying = true;
        this.emit("playState", this.isPlaying)
    },
    pause: function () {
        this.player.pause();
        this.isPlaying = false;
        this.emit("playState", this.isPlaying)
    },
    resume: function () {
        this.player.resume();
        this.isPlaying = false;
        this.emit("playState", this.isPlaying)
    },
    stop: function () {
        this.player.seek(0);
        this.player.stop();
        this.currentTrack = null;
        this.isPlaying = false;
        this.emit("playState", this.isPlaying)
    },
    changedCurrent: function () {
        this.emit("changedCurrent", this.getPlayingTrack() == null ? null : this.getPlayingTrack().getJson());
    }<commit_msg>removed unneeded (and broken) function<commit_after>var events = require('events');

function Player(player, queue) {
    this.player = player;
    this.isPlaying = false;
    this.queue = queue;

    events.EventEmitter.call(this);

    queue.on("change", function () {
        var newTrack = queue.getCurrentTrack()
        if (newTrack != this.currentTrack) {
            if (newTrack == null) {
                this.stop();
                this.currentTrack = null;
                this.changedCurrent();
            } else {
                this.playTrack(newTrack);
            }
        }
    }.bind(this));
}

Player.prototype = {
    playTrack: function (track) {
        this.player.stop();
        this.queue.loadTrack(track).then(function (track) {
            if ("undefined" === typeof track) {
                this.isPlaying = false;
                this.emit("playState", this.isPlaying)
                this.changedCurrent();
                this.stop();
                return;
            }
            try {
                this.currentTrack = track;
                console.log('Playing: %s - %s', track.artists[0].name, track.name);
                this.player.play(track);
                this.isPlaying = true;
                this.emit("playState", this.isPlaying)
                this.changedCurrent();
            } catch (e) {
                console.error(e);
                this.emit("playError", {e: e, track: this.getCurrentTrack()});
                this.queue.next();
            }
        }.bind(this));
    },
    getPlayingTrack: function () {
        return this.currentTrack;
    },
    play: function () {
        this.player.resume();
        this.isPlaying = true;
        this.emit("playState", this.isPlaying)
    },
    pause: function () {
        this.player.pause();
        this.isPlaying = false;
        this.emit("playState", this.isPlaying)
    },
    stop: function () {
        this.player.seek(0);
        this.player.stop();
        this.currentTrack = null;
        this.isPlaying = false;
        this.emit("playState", this.isPlaying)
    },
    changedCurrent: function () {
        this.emit("changedCurrent", this.getPlayingTrack() == null ? null : this.getPlayingTrack().getJson());
    }
{'fraction_non_alphanumeric': 0.13734835355285963, 'fraction_numerical': 0.0008665511265164644, 'mean_word_length': 1.665704387990762, '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': '451242', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1248, 'n_words': 227}