                 @nextSong = song
                 return song
 
-        add: (song) =>
-                @queuedSongs.push song
+        _removeRandom: =>
                 # Replace current random song with the first queued song.
                 if @nextSong != null and @nextLength == 0
                         @nextSong = null
                         @peek()
+
+        add: (song) =>
+                @queuedSongs.push song
+                @_removeRandom()
                 @trigger "add", song
                 return @queuedSongs.length
 


        table = playlistElement.dataTable tableProperties

        hashChange = (songName) ->
                if (not player.isPlaying()) and (not songName?)
                        queue.next()


        updateVisible: (@visibleSongs) ->
                @playbackFiles = []
                @_removeRandom()
                @trigger "updateVisible", @visibleSongs

        length: =>
