question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sound and Music do not function on iPhone 11 in HTML5/GWT game.

See original GitHub issue

Issue details

Sound and Music do not function on iPhone 11 when running an HTML5/GWT game. I am aware of the pitfalls of playing audio on mobile devices, and I’m careful to only play sounds when there is a touch interaction from the user. This technique works on older iOS devices. However, I received a new iPhone 11 for testing and I can’t get any Music or Sound to play at all or it will play a sound once and nothing else afterwards.

Reproduction steps/code

Please consider this very basic test class:

package com.mygdx.game;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.GL20;

public class MyGdxGame extends ApplicationAdapter {
	Sound sound;
	
	@Override
	public void create () {
		sound = Gdx.audio.newSound(Gdx.files.internal("correct.mp3"));
		
		Gdx.input.setInputProcessor(new InputAdapter() {
			@Override
			public boolean touchDown(int screenX, int screenY, int pointer, int button) {
				sound.play();
				return super.touchDown(screenX, screenY, pointer, button);
			}
		});
	}

	@Override
	public void render () {
		Gdx.gl.glClearColor(0, 1, 1, 1);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	}
}

Place the attached MP3 file into the assets folder and run the HTML5 project. Tap the game screen. It should play the sound every time you tap on all platforms. On an iPhone 11 and possibly other hardware, it may play the sound once and never again.

correct.zip

Version of LibGDX and/or relevant dependencies

1.9.10 1.9.11-SNAPSHOT

Please select the affected platforms

  • Android
  • iOS (robovm)
  • iOS (MOE)
  • HTML/GWT
  • Windows
  • Linux
  • MacOS

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
shatterblastcommented, Mar 20, 2020

I’m curious if this has anything to do with OpenAL. There is a generic switch towards that happening in the hardware ecosystem, and I think Apple tends to be super slow when updating their hardware in that regard. I believe future Apple devices will handle the problem, but I’m not sure about now.

Unfortunately, that’s part of the problem with Apple having such proprietary hardware, even if its typically reliable.

Anyhow, the problem would be with GWT itself. I think Google tends to stay ahead of the curve in terms of the libraries it supports, even if Apple has better hardware in some cases.

The next version of LibGDX may cure that for you. I’m not sure. On the good side, hardware support will likely not drift away from OpenAL for some time.

The thing with Apple hardware is that they don’t always ship with full support for everything when they initially release. They certainly try, but that’s usually not the case. If the next LibGDX version doesn’t help you, then hopefully the next iOS update for iPhone 11 will.

1reaction
MrStahlfelgecommented, Aug 20, 2020

You need to use WebAudio to get it working. Give your upvote for #5659 or switch to the GWT backend mentioned there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no sound in certain game apps - Apple Support Communities
After updating to ios 7.04 (11B554a) some of my daughters game apps have no sound. It is only a few that have done...
Read more >
No game Sounds in speaker mode, but can m…
Hi, my iPhone 11 recently lost its game sounds in speaker mode. ... and my only problem is that they don't work while...
Read more >
No audio when playing games if iPhone 13 pro is on silent
If we understand correctly, your iPhone is in Silent mode and you're not hearing sound in games or in some other apps. Is...
Read more >
If you hear no sound or distorted sound from your iPhone ...
Go to Settings > Sounds (or Settings > Sounds & Haptics), and drag the Ringer and Alerts slider back and forth a few...
Read more >
Change the way music sounds on iPhone - Apple Support
Change the way music sounds on iPhone with EQ, volume limit settings, and Sound Check. Choose an equalization (EQ) setting: Go to Settings...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found