love.js icon indicating copy to clipboard operation
love.js copied to clipboard

Sound not worked on Mobile Web

Open andreymust19 opened this issue 7 years ago • 1 comments

Example: https://gamejolt.com/claim/HSfptdX3 I hear music and sound when click and press 'space' if open this page on computer. And full silence on mobile (android). Browser: google chrome

CONF.LUA

function love.conf(t) t.title = "TestHTML" t.author = "AndreyMust19" t.identity = "TestHTML" t.version = "0.10.1" t.console = false t.window.width = 512 t.window.height = 512 t.window.fullscreen = false t.window.vsync = false t.window.fsaa = 2 t.modules.joystick = false t.modules.audio = true t.modules.keyboard = true t.modules.event = true t.modules.image = true t.modules.graphics = true t.modules.timer = true t.modules.mouse = true t.modules.sound = true t.modules.physics = false end

MAIN.LUA

lg = love.graphics la = love.audio

local sound, music

function love.load() sound = la.newSource("click.wav", 'static') music = la.newSource("track1.mp3", 'stream') music:setLooping(true) music:play(); start() end local function real_update(dt) end

local last_dt, last_fps local max_dt = 0.05

function love.update(dt) if (dt > max_dt) then dt = max_dt end real_update(dt) last_dt = math.floor(dt*1000000) last_fps = math.floor(love.timer.getFPS()) end

function love.draw() lg.printf("dt: "..last_dt, 20, 20, 100, 'left'); lg.printf("FPS: "..last_fps, 20, 40, 100, 'left'); end

function love.keypressed(key, unicode) if (key == 'space' or key == ' ') then sound:play() end end

function love.mousepressed(x, y, btn) if (btn == 1) then sound:play() end end

function love.quit() end

andreymust19 avatar May 15 '18 18:05 andreymust19

Try to put the track1 as static in the newSource call. I have a flag for web builds which makes all the sounds static because the streaming of audios makes the games slower and sometimes it doesn't work.

drmargarido avatar Feb 12 '19 14:02 drmargarido