Skip to content
This repository was archived by the owner on Nov 4, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions modules/mojo/native/asyncsoundloader.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@

function BBAsyncSoundLoaderThread(){
this._running=false;
}

BBAsyncSoundLoaderThread.prototype.Start=function(){
this._sample=this._device.LoadSample( this._path );
this._sample = null;
if( !this._device.okay ) return;

var audio=new Audio();
if( !audio ) return;

var thread=this;
thread._running=true;

audio.src=BBGame.Game().PathToUrl( this._path );
audio.preload='auto';

var success=function( e ){
thread._running=false;
thread._sample = new gxtkSample( audio );
audio.removeEventListener( 'canplaythrough',success,false );
audio.removeEventListener( 'error',error,false );
}

var error=function( e ){
thread._running=false;
audio.removeEventListener( 'canplaythrough',success,false );
audio.removeEventListener( 'error',error,false );
}

audio.addEventListener( 'canplaythrough',success,false );
audio.addEventListener( 'error',error,false );
audio.load();
}

BBAsyncSoundLoaderThread.prototype.IsRunning=function(){
return false;
return this._running;
}
6 changes: 5 additions & 1 deletion modules/mojo/native/mojo.html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ gxtkAudio.prototype.Resume=function(){

gxtkAudio.prototype.LoadSample=function( path ){
if( !this.okay ) return null;

var ty=this.game.GetMetaData( path,"type" );
if(ty != "" && ty.indexOf( "audio/" ) != 0 ) return null;

var audio=new Audio( this.game.PathToUrl( path ) );
if( !audio ) return null;
Expand Down Expand Up @@ -524,9 +527,10 @@ gxtkAudio.prototype.PlayMusic=function( path,flags ){
this.StopMusic();

this.music=this.LoadSample( path );
if( !this.music ) return;
if( !this.music ) return -1;

this.PlaySample( this.music,32,flags );
return 0;
}

gxtkAudio.prototype.StopMusic=function(){
Expand Down
6 changes: 6 additions & 0 deletions src/transcc/builders/html5.monkey
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ Class Html5Builder Extends Builder
meta.Push "width="+Info_Width+";"
meta.Push "height="+Info_Height+";"
meta.Push "\n"
Case "wav","ogg","mp3","m4a"
If ext="mp3" ext="mpeg"
If ext="m4a" ext="x-m4a"

meta.Push "[" + kv.Value + "];type=audio/" + ext + ";"
meta.Push "\n"
End
Next
Return meta.Join("")
Expand Down