How do you freeze by reference, create sound

I have a client who requested piano keys as links, and he wants them to sound when the mouse hangs over the keys. How can this be done without using a flash?

+3
source share
4 answers

Browsers have very poor sound support, so most of the time a flash is used to make sound possible. I would suggest looking for an mp3 player that allows you to create your own html interface. In such cases, you can name different parts of the player using JS. Then you will need to have an mp3 file for each of the keys and play right when you press the key. At the heart of such a tool, although there would be a flash component running in the background to play sound, you did not need to display anything using flash.

I suggest using jPlayer:

http://plugins.jquery.com/project/jPlayer

+1
source

SoundManager2 is a good tool for creating Javascript interfaces with sound.

, , - . , SoundManager2 ( Javascript, ), Flash .

+2

- :

<img src="key.gif" onMouseOver="javascript:document.awav.play();">
<embed src="a.wav" hidden=true autostart=false name="awav" mastersound>

IE, Windows Media wav .

, , -, , wav. Flash - .

javascript-, .

0

soundmanager2. Soundmanager , .

<script src="soundmanager2.js"></script>
<script>
  function onReadyFunc()
  {
    var soundFile = {};
    soundFile.id = 'aSound';
    soundFile.url = '/tech/js/sound/s.mp3';
    var mySound = soundManager.createSound(soundFile);
    return mySound;
  }
  soundManager.url = '/tech/js/sound/';
  mySound = soundManager.onready(onReadyFunc);

  function onHover(){ mySound.play() };

ohHover onMouseover.

0
source

Source: https://habr.com/ru/post/1740494/


All Articles