ozdemirburak / morse-code-translator

Translate text to Morse code and vice versa, with the option to play Morse code audio.
https://morsecodetranslator.com
MIT License
216 stars 57 forks source link

End of audio detection #12

Closed Oppenjaimer closed 5 years ago

Oppenjaimer commented 5 years ago

Is there any way to detect when a morse audio has ended? What I want to do is to change the class of a button after the audio has ended. Thank you

ozdemirburak commented 5 years ago

See the onended event below.

const arabicAudio = morsify.audio('البراق', { // generates the morse .- .-.. -... .-. .- --.- then generates the audio from it
  unit: 0.1, // period of one unit, in seconds, 1.2 / c where c is speed of transmission, in words per minute
  oscillator: {
    type: 'sine', // sine, square, sawtooth, triangle
    frequency: 500,  // value in hertz
    onended: function () { // event that fires when the tone has stopped playing
      console.log('ended');
    }
  }
});