caguiclajmg / platelet-clicker

くすぐったいよ
https://platelets.fun
26 stars 6 forks source link

Use Javascript to create audio elements #6

Closed ruiokada closed 5 years ago

ruiokada commented 5 years ago

As per the concerns raised in comment:

Partially fixed by f741b03, didn't move the reactions into <audio> tags as it could easily get ugly if a lot of reactions are added; in that case loading the audio via a loop in js would be a cleaner solution.

This is a proposed way of dealing with multiple reaction audios. The idea behind this commit is to create audio elements via Javascript but avoid inserting them into the DOM and hard-coding audio elements in HTML.

caguiclajmg commented 5 years ago

Looks good, very elegant solution.

Just 2 more things:

  1. Change snd_react to audioReact so as to be consistent with other variables.
  2. Load the reaction audio fallbacks as well, based on createAudioElement this should do it:
    var reactionFiles = [
    {
        'audio/ogg': 'public/sounds/react1.ogg',
        'audio/mpeg': 'public/sounds/react1.mp3',
    },
    {
        'audio/ogg': 'public/sounds/react2.ogg',
        'audio/mpeg': 'public/sounds/react2.mp3',
    }
    ]
ruiokada commented 5 years ago

Fixed:

  1. Change snd_react to audioReact so as to be consistent with other variables.
  2. Load the reaction audio fallbacks as well, based on createAudioElement this should do it:
caguiclajmg commented 5 years ago

Everything seems to be in order, merging.