<commit_before>(function(){
    function SongPlayer(){
        var SongPlayer = {};
        
        var currentSong = null;
        
        /**
        *@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();
                currentSong.playing = null;
            }
            
            currentBuzzObject = new buzz.sound(song.audioUrl,{
                formats: ['mp3'],
                preload: true     
            });
            
            currentSong = song;
        }
        
        SongPlayer.play = function(song){
            if(currentSong !== song){   
                setSong(song);    
                currentBuzzObject.play();
                song.playing = true;
                
            }else if (currentSong === song){
                if(currentBuzzObject.isPaused()){
                    currentBuzzObject.play();
                }
            }
        };
        
        SongPlayer.pause = function(song){
            currentBuzzObject.pause();
            song.playing = false;
        };
        
        return SongPlayer;
    }
    
    angular
        .module('blocJams')
        .factory('SongPlayer', SongPlayer);
})();<commit_msg>assignment 7 part 2 completed<commit_after>(function(){
    /**
    *@function SongPlayer
    *@desc Makes play/pause methods available to app
    *@returns {Object} SongPlayer
    */
    function SongPlayer(){
        
        /**
        *@desc Holds play/pause functionality of SongPlayer service
        *@type {Object}
        */
        var SongPlayer = {};
        
        /**
        *@desc Current song playing from song object
        *@type {Object}
        */
        var currentSong = null;
        
        /**
        *@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();
                currentSong.playing = null;
            }
            
            currentBuzzObject = new buzz.sound(song.audioUrl,{
                formats: ['mp3'],
                preload: true     
            });
            
            currentSong = song;
        };
        
        /**
        *@function playSong
        *@desc Plays the current song using currentBuzzObject and sets song playing to true
        *@param {Object} song
        */
        var playSong = function(song){
            currentBuzzObject.play();
            song.playing = true;
        };
        
        /**
        *@function SongPlayer.play
        *@desc Checks if song clicked is current song playing and plays song clicked, else current song playing was paused and is played again
        *@param {Object} song
        */  
        SongPlayer.play = function(song){
            if(currentSong !== song){   
                setSong(song);
                playSong(song);
                
            }else if (currentSong === song){
                if(currentBuzzObject.isPaused()){
                    currentBuzzObject.play();
                }
            }
        };
        
        /**
        *@function SongPlayer.pause
        *@desc Pauses the CurrentBuzzObject audio file and sets playing property on song object to false
        *@param {Object} song
        */
        SongPlayer.pause = function(song){
            currentBuzzObject.pause();
            song.playing = false;
        };
        
        return SongPlayer;
    }
    
    angular
        .module('blocJams')
        .factory('SongPlayer', SongPlayer);
})();
{'fraction_non_alphanumeric': 0.09520331141952763, 'fraction_numerical': 0.0009739469198928658, 'mean_word_length': 1.2796892341842396, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3291206', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1004, 'n_words': 256}