No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sound.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. var audio = null;
  2. var tkawasemi;
  3. function kawasemi(){
  4. var ckawasemi = 1;
  5. kawasemiimg = new Array(4);
  6. kawasemiimg[1] = "./css/img/kawasemi_01.png";
  7. kawasemiimg[2] = "./css/img/kawasemi_02.png";
  8. kawasemiimg[3] = "./css/img/kawasemi_01.png";
  9. kawasemiimg[4] = "./css/img/kawasemi_02.png";
  10. kawasemiUP();
  11. function kawasemiUP(){
  12. tkawasemi = setTimeout(kawasemiUP,500);
  13. document.kawasemi.src = kawasemiimg[ckawasemi];
  14. ckawasemi = ckawasemi + 1;
  15. if( ckawasemi > 4 ){
  16. ckawasemi = 1;
  17. }
  18. }
  19. }
  20. function sound(){
  21. audio = new Audio();
  22. audio.autoplay = false;
  23. audio.loop = true;
  24. if (audio.canPlayType) {
  25. var playMsg = audio.canPlayType('audio/mpeg');
  26. if ( "" != playMsg) {
  27. audio.src = "./sound/kawasemi.mp3";
  28. }
  29. playMsg = audio.canPlayType('audio/wav; codecs="1"');
  30. if ( "" != playMsg) {
  31. audio.src = "./sound/kawasemi.wav";
  32. }
  33. audio.load();
  34. }
  35. }
  36. /* マウスオーバー・アウト */
  37. function soundsmartRollover() {
  38. document.kawasemi.onmouseover = function() {
  39. audio.play();
  40. kawasemi();
  41. }
  42. document.kawasemi.onmouseout = function() {
  43. audio.pause();
  44. clearTimeout(tkawasemi);
  45. document.kawasemi.src = kawasemiimg[1];
  46. }
  47. }
  48. /* オンロード時に動作 */
  49. if(window.addEventListener) {
  50. window.addEventListener('load', sound, false);
  51. window.addEventListener('load', soundsmartRollover, false);
  52. } else {
  53. window.attachEvent("onload", sound);
  54. window.attachEvent("onload", soundsmartRollover);
  55. }