Audio fix workaround for phone devices

master
sigonasr2 4 years ago
parent b5df1648f7
commit a5b136e02f
  1. 11
      game.js

@ -1,5 +1,7 @@
var canvas; var canvas;
var currentSound = new Audio();
const GOODQUOTES=[ const GOODQUOTES=[
"Let the conversion begin...", "Let the conversion begin...",
"All the bots, come to ME", "All the bots, come to ME",
@ -36,7 +38,7 @@ const TITLETIMELINE = [
}, },
{time:6500,cb: {time:6500,cb:
(ctx)=>{ (ctx)=>{
var audio = new Audio("Super 8 Old Movie Projector - Gaming Sound Effect.mp3") currentSound.src="Super 8 Old Movie Projector - Gaming Sound Effect.mp3"
audio.play() audio.play()
} }
}, },
@ -56,8 +58,9 @@ const TITLETIMELINE = [
}, },
{time:15000,cb: {time:15000,cb:
(ctx)=>{ (ctx)=>{
backgroundMusic.loop=true currentSound.src="Shostakovich_ Symphony No. 9.mp3"
backgroundMusic.play() currentSound.loop=true
currentSound.play()
SCENE_DRAW=(ctx)=>{ SCENE_DRAW=(ctx)=>{
ctx.globalAlpha=0.9 ctx.globalAlpha=0.9
ctx.drawImage(IMAGE_TITLE,canvas.width/2-260,canvas.height/2-70) ctx.drawImage(IMAGE_TITLE,canvas.width/2-260,canvas.height/2-70)
@ -73,7 +76,6 @@ const TITLETIMELINE = [
}, },
] ]
var backgroundMusic = new Audio("Shostakovich_ Symphony No. 9.mp3")
var SCENEBACKGROUND = "black" var SCENEBACKGROUND = "black"
var SCENEALPHA = 1.0 var SCENEALPHA = 1.0
@ -762,6 +764,7 @@ function clickEvent(e) {
} }
if (gameState===STARTUP) { if (gameState===STARTUP) {
currentSound.play()
setupTitleScreen() setupTitleScreen()
} }
if (gameState===TITLE) { if (gameState===TITLE) {

Loading…
Cancel
Save