home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ring.yamanashi.ac.jp/pub/pc/freem/action/
/
action.zip
/
henkyaku1.0.exe
/
henkyaku
/
Program
/
Kernel
/
Util
/
MediaPlayer.tonyu
< prev
next >
Wrap
Text File
|
2007-09-03
|
2KB
|
127 lines
extends Object;
//native _n_freeAllSE;
constructor MediaPlayer() {
_stopOnPageLoad = 1;
prevFc=null;
soundInterval=trunc(44100*16/1000);
soundDelay =1000;
timeLag=2000;
soundNextTime=null;
frameOffset=0;
playPosOffset=0;
bsize=6000;
}
function setFrameRate(r) {
soundInterval=trunc(44100*trunc(r)/1000);
}
function soundsPath() {
return "project.sounds";
}
function init() {
initResource(soundsPath());
}
function freeAllSE() {
var a,r;
r=getResource(soundsPath());
if (!r) return;
r=r.getSubRes();
for (a in r) {
a.release();
}
// _n_freeAllSE();
}
function play( s,ar,v) {
if ( s) {
if (s is BGM) stop();
if (!v || (v>=0 && v<=128)) {
s.play(ar,v);
} else {
s.play(ar,128);
}
}/* else {
(new BGM()).play();
}*/
}
native _n_stop;
function stop() {
_n_stop();
}
native _n_setEnable;
function setEnable(t) {
_n_setEnable(t);
}
function setStopOnPageLoad(t) { _stopOnPageLoad=t;}
function stopOnPageLoad() { return _stopOnPageLoad;}
native _n_setVolume;
function setVolume(s) {
_n_setVolume(s);
}
native _n_sound;
function sound(ch,typ,val,time) {
_n_sound(ch,typ,val,time);
}
function setSoundDelay(d) {
soundDelay=d;
}
function soundTone(ch,val) {
sound(ch,1,trunc(val*97391),calcTime());
}
function soundVolume(ch,val) {
sound(ch,2,val,calcTime());
}
function calcTime() {
var r,p;
r=playPosOffset+($frameCount-frameOffset)*soundInterval;
p=getPlayPos()+bsize;
if (abs(r-p)>3000) {
frameOffset = $frameCount;
playPosOffset = p;
if (r>p) soundInterval--;
else soundInterval++;
//print (r+" "+p+" "+soundInterval+" "+$frameCount);
return p;
}
return r;
}
native _n_setDelay;
function setDelay(d) {
_n_setDelay(d);
}
native _n_setBSize;
function setBSize(sz) {
_n_setBSize(sz);
bsize=sz;
}
native _n_getPlayPos;
function getPlayPos(type) {
return _n_getPlayPos(type);
}
function getLastWriteStartPos () {
return getPlayPos(1);
}
function getLastWriteEndPos () {
return getPlayPos(2);
}
function getBufferUnderrun () {
return getPlayPos(3);
}
native _n_start;
function start(ch,typ,val,time) {
_n_start();
}
native _n_calibration;
function calibration(len,lag) {
timeLag=lag;
_n_calibration(len,lag);
}