1

13 枚の写真を 1 つのスライダーに入れます。各画像にサウンドを付けたいと思います。たとえば、画像 10 に到達すると、サウンド 10 が再生されます。

私は jQuery をまったく初めて使用し、 Orbitをスライダーとして使用することを考えましたが、サウンドを統合する方法がわかりません。

それを行う簡単なアイデアはありますか?

4

1 に答える 1

2

レガシー ブラウザのサポートが必要ない場合は、Web Audio API をご覧ください。 https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html

例を次に示します: http://www.html5rocks.com/en/tutorials/webaudio/intro/

//call the init function on window load
window.onload = init;
var context;
var bufferLoader;
//create 2 audio sources... as there were 2 in the example linked above
var source1 = context.createBufferSource();
var source2 = context.createBufferSource();

function init() {
  //initialise the audio context
  context = new webkitAudioContext();

  //init preloading of sounds
  bufferLoader = new BufferLoader(
    context,
    [
      '../sounds/br-jam-loop.wav',
      '../sounds/laughter.wav',
    ],
    finishedLoading  // <- callback function when finished loading
    );

  bufferLoader.load();
}

function finishedLoading(bufferList) {
  //set the buffers of the sources from the loaded bufferlist
  source1.buffer = bufferList[0];
  source2.buffer = bufferList[1];

  //connect the sources to the output
  source1.connect(context.destination);
  source2.connect(context.destination);
}

次に、プラグインのコールバック関数の 1 つを使用して、次のようにサウンドをトリガーできます。

$('#featured').orbit({
     afterSlideChange: function(){
       source1.noteOn(0);
       source2.noteOn(0);
     }
});

そのような何かがうまくいくはずです。

...いくつかのフレームワークもあり、それがいくつかの作業を行います。 http://www.schillmania.com/projects/soundmanager2/は良いものです。

于 2012-12-31T18:25:24.633 に答える