admin管理员组

文章数量:1025477

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");

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");

本文标签: javascriptPlay Mp3 sound clip on mouseclick using jplayerStack Overflow