mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-22 22:48:08 +03:00
Implement cdrom_getPlayingInfo
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user