playMode(str) {
    var s = str.toLowerCase().trim();

    // if restart, stop all other sounds from playing
    if (s === 'restart' && this.buffer && this.bufferSourceNode) {
      for (var i = 0; i < this.bufferSourceNodes.length; i++) {
        var now = p5sound.audiocontext.currentTime;
        this.bufferSourceNodes[i].stop(now);
      }
    }

    // set play mode to effect future playback
    if (s === 'restart' || s === 'sustain' || s === 'untildone') {
      this.mode = s;
    } else {
      throw 'Invalid play mode. Must be either "restart" or "sustain"';
    }
  }
p5.SoundFile has two play modes: <code>restart</code> and
 <code>sustain</code>. Play Mode determines what happens to a
 p5.SoundFile if it is triggered while in the middle of playback.
 In sustain mode, playback will continue simultaneous to the
 new playback. In restart mode, play() will stop playback
 and start over. With untilDone, a sound will play only if it's
 not already playing. Sustain is the default mode.

 @method  playMode
 @for p5.SoundFile
 @param  {String} str 'restart' or 'sustain' or 'untilDone'
 @example
 <div><code>
 let mySound;
 function preload(){
   mySound = loadSound('assets/Damscray_DancingTiger.mp3');
 }
 function setup() {
   let cnv = createCanvas(100, 100);
   cnv.mousePressed(canvasPressed);
   noFill();
   rect(0, height/2, width - 1, height/2 - 1);
   rect(0, 0, width - 1, height/2);
   textAlign(CENTER, CENTER);
   fill(20);
   text('restart', width/2, 1 * height/4);
   text('sustain', width/2, 3 * height/4);
 }
 function canvasPressed() {
   if (mouseX < height/2) {
     mySound.playMode('restart');
   } else {
     mySound.playMode('sustain');
   }
   mySound.play();
 }

</code></div>