Implement cdrom_getPlayingInfo

This commit is contained in:
kichikuou
2017-03-09 16:46:08 +09:00
parent 04cae28ee1
commit 5d1fcff674
2 changed files with 15 additions and 3 deletions
+5 -3
View File
@@ -59,7 +59,9 @@ int cdrom_stop() {
return OK;
}
int cdrom_getPlayingInfo (cd_time *info) {
info->t = info->m = info->s = info->f = 999;
return NG;
int cdrom_getPlayingInfo(cd_time *info) {
int t = EM_ASM_INT_V( return xsystem35.cdPlayer.getPosition(); );
info->t = t & 0xff;
FRAMES_TO_MSF(t >> 8, &info->m, &info->s, &info->f);
return OK;
}
+10
View File
@@ -79,12 +79,14 @@ class System35Shell {
class CDPlayer {
audio = <HTMLAudioElement>$('audio');
private blobs: Blob[];
private currentTrack: number;
constructor(private imageLoader:ImageLoader) {
this.blobs = [];
}
play(track:number, loop:number) {
this.currentTrack = track;
if (this.blobs[track]) {
this.startPlayback(this.blobs[track], loop);
return;
@@ -97,6 +99,14 @@ class CDPlayer {
stop() {
this.audio.pause();
this.currentTrack = null;
}
getPosition(): number {
if (!this.currentTrack)
return 0;
var time = Math.round(this.audio.currentTime * 75);
return this.currentTrack | time << 8;
}
private startPlayback(blob:Blob, loop:number) {