Mercurial > hg > Members > e075723
changeset 2:3fe0d4829300
test
author | Yui SHIMURA <e075723@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 30 Nov 2010 17:43:13 +0900 |
parents | d17e4232f039 |
children | c54fd1f7ff2a |
files | resources/music.js |
diffstat | 1 files changed, 43 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/resources/music.js Tue Nov 30 17:43:13 2010 +0900 @@ -0,0 +1,43 @@ +/**音を鳴らす為の関数**/ + +//usage +//var sample = MusicLoad("./sound/sample.wav"); +//BgmPlay(sample,"on"); +//---------------------------------------------- +//MusicLoad load a music file +//BgmPlay play music with loop +//SoundPlay play sound onetime + + +// prototype +//readonly attribute MediaError error; +//void play(); +//void pause(); +//interface HTMLAudioElement : HTMLMediaElement {}; +//Audio +//attribute DOMString src; +//attribute DOMString preload; +//attribute boolean autoplay; +//attribute boolean loop; +//attribute boolean controls; + +function MusicLoad(src) +{ + var audio =new Audio(src); + return(audio); +} + +function BgmPlay(audio,sta) +{ + if(sta =="on"){ + audio.play(); + audio.loop=true; + }else if( sta =="off" ){ + audio.pause(); + } +} + +function SoundPlay(audio) +{ + audio.play(); +}