javascript - Play Mp3 sound clip on mouseclick using jplayer? - Stack Overflow

Actually this the first time I'm gonna use jplayer plugin, so all I need is to play a sound clip (

Actually this the first time I'm gonna use jplayer plugin, so all I need is to play a sound clip (2 sec) when I click on a div, and I don't know how to use jplayer!

I also need to load the sound clip file in cache as well as the page is loading, so when I click that div the sound clip plays immediately without loading it when clicking

btw, is it possible to do that without using jplayer, jquery maybe?!

Actually this the first time I'm gonna use jplayer plugin, so all I need is to play a sound clip (2 sec) when I click on a div, and I don't know how to use jplayer!

I also need to load the sound clip file in cache as well as the page is loading, so when I click that div the sound clip plays immediately without loading it when clicking

btw, is it possible to do that without using jplayer, jquery maybe?!

Share Improve this question edited Sep 16, 2011 at 23:24 Derek Adair 22k31 gold badges101 silver badges134 bronze badges asked Jun 2, 2011 at 14:42 SamSam 3252 gold badges3 silver badges9 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

If you want to stick with jPlayer, try setting warningAlerts and errorAlerts to true.

$(id).jPlayer( { warningAlerts: true, errorAlerts: true } );

This may solve your problem.

But as long as you only need sound (no video), SoundManager 2 might be a better fit for you. Its really robust and provides extensive debugging output.

soundManager.url = './swf/'; // directory where SM2 .SWFs live

var mySound;

soundManager.onready(function() {

    // SM2 has loaded - now you can create and play sounds!

    mySound = soundManager.createSound({
      id: 'someSound',
      url: '/path/to/some.mp3'
    });
});

//....
//if(xhr-stuff)
    if(mySound)
        mySound.play();

Use soundmanager2.js for testing and soundmanager2-nodebug-jsmin.js for production. If you have further questions, don't hesistate to ask.

-snip-

scratch that... there's an api

http://www.jplayer/latest/developer-guide/#jPlayer-play

Use

$("#jpId").jPlayer("play");

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745634842a4637327.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信