text: (function() {
      function SongPlayer($rootScope, Fixtures) {
          var SongPlayer = {};
          
          /**
          * @desc Loads album information
          * @type {Object}
          */
          SongPlayer.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) {
                  stopSong(SongPlayer.currentSong);
              }
   
              currentBuzzObject = new buzz.sound(song.audioUrl, {
                  formats: ['mp3'],
                  preload: true
              });
              
              currentBuzzObject.bind('timeupdate', function() {
                  $rootScope.$apply(function() {
                      SongPlayer.currentTime = currentBuzzObject.getTime();
                  });
              });
              
              SongPlayer.currentSong = song;
          };
          
          /**
          * @function playSong
          * @desc Plays new audio file as currentBuzzObject if it is not the currently playing song
          * @param {Object} song 
          */
          var playSong = function(song) {
              if (currentBuzzObject) {
                  currentBuzzObject.play();
                  song.playing = true;
              }
          };
          
          /**
          * @function stopSong
          * @desc Stops currently playing song
          * @param {Object} song
          */
          var stopSong = function(song) {
              if (currentBuzzObject) {
                  currentBuzzObject.stop();
                  song.playing = null;
              }
          };
          
          /**
          * @function getSongIndex
          * @desc Gets the index of the currently playing song in the songs array from the current album
          * @param {Object} song
          */
          var getSongIndex = function(song) {
              return SongPlayer.currentAlbum.songs.indexOf(song);
          };
          
          /**
          * @desc chosen song
          * @type {Object}
          */
          SongPlayer.currentSong = null;
          
          /**
          * @desc Current playback time (in seconds) of currently playing song
          * @type {Number}
          */
          SongPlayer.currentTime = null;
          
          /**
          * @desc volume of currently playing song
          * @type {Object}
          */
          SongPlayer.volume = null;
          
          /**
          * @function play
          * @desc Play current or new 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 pause
          * @desc Pause current song
          * @param {Object} song
          */
          SongPlayer.pause = function(song) {
              song = song || SongPlayer.currentSong;
              currentBuzzObject.pause();
              song.playing = false;
          };
      
          /**
          * @function get previous song
          * @desc Get previous song index in songs array from current album
          */
          SongPlayer.previous = function() {
              var currentSongIndex = getSongIndex(SongPlayer.currentSong);
              currentSongIndex--;
              
              if (currentSongIndex < 0) {
                  stopSong(SongPlayer.currentSong);
              } else {
                  var song = SongPlayer.currentAlbum.songs[currentSongIndex];
                  setSong(song);
                  playSong(song);
                  
              }
          };
          
          /**
          * @function plays next song
          * @desc Get next song index in songs array from current album
          */
          SongPlayer.next = function() {
              var currentSongIndex = getSongIndex(SongPlayer.currentSong);
              currentSongIndex++;
              
              if (currentSongIndex >= currentAlbum.songs.length) {
                  currentSongIndex = 0;
              }
                  var song = SongPlayer.currentAlbum.songs[currentSongIndex];
                  setSong(song);
                  playSong(song);
          };
          
          /**
          * @function setCurrentTime
          * @desc Set current time (in seconds) of currently playing song
          * @param {Number} time
          */
          SongPlayer.setCurrentTime = function(time) {
              if (currentBuzzObject) {
                  currentBuzzObject.setTime(time);
              }
          };
          
          /**
          * @function setVolume
          * @desc Sets volume of current song
          * @param {Object} volume
          */
          SongPlayer.setVolume = function(volume) {
              if (currentBuzzObject) {
                  currentBuzzObject.setVolume(volume);
              }
          };
              
          return SongPlayer;
          
      };              
      
      angular
          .module('blocJams')
          .factory('SongPlayer', ['$rootScope', 'Fixtures', SongPlayer]);
  })();