<commit_before>(function() {
  function SongPlayer(Fixtures) {
    var SongPlayer = {};
    var currentAlbum = Fixtures.getAlbum();
    /**
    * @desc Buzz object audio file
    * @type {Object}
    */
    var currentBuzzObject = null;

    /**
    * @function setSong
    * @desc Stops currently playing song and loads new audio file as currentBuzzObject
    * @param {Object} song
    */
    var setSong = function(song) {
      if (currentBuzzObject) {
        currentBuzzObject.stop();
        SongPlayer.currentSong.playing = null;
      }
      currentBuzzObject = new buzz.sound(song.audioUrl, {
        formats: ['mp3'],
        preload: true
      });
      SongPlayer.currentSong = song;
    };

    function stopSong(song) {
      currentBuzzObject.stop();
      song.playing = null;
    };
    /**
    * @function getSongIndex
    * @desc Finds the current index of the song thats playing
    * @param {Object} song
    */

    var getSongIndex = function(song) {
        return currentAlbum.songs.indexOf(song);
    };

    SongPlayer.currentSong = null;
    /**
    * @function playSong
    * @desc plays the current song
    * @param {Object} song
    */
    function playSong(song) {
      currentBuzzObject.play();
      song.playing = true;

    };
    /**
    * @function SongPlayer.play
    * @desc checks to see if a song is currently playing and if not will play the current song
    * @param {Object} song
    */
    SongPlayer.play = function(song) {
      song = song || SongPlayer.currentSong;
      if (SongPlayer.currentSong !== song) {
        setSong(song);
        playSong(song);
      } else if (SongPlayer.currentSong === song) {
        if (currentBuzzObject.isPaused()) {
          playSong(song);
        }
      }
    };
    /**
    * @function SongPlayer.pause
    * @desc checks to see if a song is playing and if it is, paused the current song
    * @param {Object} song
    */
    SongPlayer.pause = function(song) {
      song = song || SongPlayer.currentSong;
      currentBuzzObject.pause();
      song.playing = false;
    }

  /**
  * @function SongPlayer.previous
  * @desc goes to the previous song in the array
  * @param {Object} song
  */
  SongPlayer.previous = function() {
    var currentSongIndex = getSongIndex(SongPlayer.currentSong);
    currentSongIndex--;

    if (currentSongIndex < 0) {
      stopSong();
  } else {
      var song = currentAlbum.songs[currentSongIndex];
      setSong(song);
      playSong(song);
    }
  };

  SongPlayer.next = function() {
    var currentSongIndex = getSongIndex(SongPlayer.currentSong);
    currentSongIndex++;

    if (currentSongIndex > 4) {
        stopSong(song);
  } else {
      var song = currentAlbum.songs[currentSongIndex];
      setSong(song);
      playSong(song);
    }
  };
  return SongPlayer;
};




  angular
  .module('blocJams')<commit_msg>fixed checkpoint 8 merge conflict<commit_after>(function() {
  function SongPlayer(Fixtures) {
    var SongPlayer = {};
    var currentAlbum = Fixtures.getAlbum();
    /**
    * @desc Buzz object audio file
    * @type {Object}
    */
    var currentBuzzObject = null;

    /**
    * @function setSong
    * @desc Stops currently playing song and loads new audio file as currentBuzzObject
    * @param {Object} song
    */
    var setSong = function(song) {
      if (currentBuzzObject) {
        currentBuzzObject.stop();
        SongPlayer.currentSong.playing = null;
      }
      currentBuzzObject = new buzz.sound(song.audioUrl, {
        formats: ['mp3'],
        preload: true
      });
      SongPlayer.currentSong = song;
    };

    function stopSong(song) {
      currentBuzzObject.stop();
      song.playing = null;
    };
    /**
    * @function getSongIndex
    * @desc Finds the current index of the song thats playing
    * @param {Object} song
    */

    var getSongIndex = function(song) {
        return currentAlbum.songs.indexOf(song);
    };

    SongPlayer.currentSong = null;
    /**
    * @function playSong
    * @desc plays the current song
    * @param {Object} song
    */
    function playSong(song) {
      currentBuzzObject.play();
      song.playing = true;

    };
    /**
    * @function SongPlayer.play
    * @desc checks to see if a song is currently playing and if not will play the current song
    * @param {Object} song
    */
    SongPlayer.play = function(song) {
      song = song || SongPlayer.currentSong;
      if (SongPlayer.currentSong !== song) {
        setSong(song);
        playSong(song);
      } else if (SongPlayer.currentSong === song) {
        if (currentBuzzObject.isPaused()) {
          playSong(song);
        }
      }
    /**
    * @function SongPlayer.pause
    * @desc checks to see if a song is playing and if it is, paused the current song
    * @param {Object} song
    */
    SongPlayer.pause = function(song) {
      song = song || SongPlayer.currentSong;
      currentBuzzObject.pause();
      song.playing = false;
    }

  /**
  * @function SongPlayer.previous
  * @desc goes to the previous song in the array
  * @param {Object} song
  */
  SongPlayer.previous = function() {
    var currentSongIndex = getSongIndex(SongPlayer.currentSong);
    currentSongIndex--;

    if (currentSongIndex < 0) {
      stopSong();
  } else {
      var song = currentAlbum.songs[currentSongIndex];
      setSong(song);
      playSong(song);
    }
  };
  return SongPlayer;
};

  SongPlayer.next = function() {
    var currentSongIndex = getSongIndex(SongPlayer.currentSong);
    currentSongIndex++;

    if (currentSongIndex > 4) {
        stopSong(song);
  } else {
      var song = currentAlbum.songs[currentSongIndex];
      setSong(song);
      playSong(song);
    }
  };
  return SongPlayer;
};




  angular
  .module('blocJams')
{'fraction_non_alphanumeric': 0.11516414799374675, 'fraction_numerical': 0.0012159110647906896, 'mean_word_length': 2.3970501474926253, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4649336', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1697, 'n_words': 433}