# Sounds not worked on iOS

**URL:** <https://phaser.discourse.group/t/sounds-not-worked-on-ios/12193>\
**Category:** Phaser 3\
**Created:** [August 21, 2022, 2:54pm UTC](https://phaser.discourse.group/t/sounds-not-worked-on-ios/12193 "2022-08-21T14:54:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniil861](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/daniil861/32/6796_2.png) [@Daniil861](https://phaser.discourse.group/u/Daniil861)\
**Post date:** [August 21, 2022, 2:54pm UTC](https://phaser.discourse.group/t/sounds-not-worked-on-ios/12193/1 "2022-08-21T14:54:11Z")

</div>

Hello everyone!  
Problem with playing sounds on iphone devices.  
If i use this code [(get Phaser example](https://phaser.io/examples/v3/view/audio/web-audio/play-audio-file)), music is playing everywhere except iphone devices:

```javascript
var config = {
    type: Phaser.AUTO,
    parent: 'phaser-example',
    width: 800,
    height: 600,
    pixelArt: true,
    scene: {
        preload: preload,
        create: create
    }
};

var game = new Phaser.Game(config);

function preload ()
{
    this.load.audio('theme', [
        'assets/audio/oedipus_wizball_highscore.ogg',
        'assets/audio/oedipus_wizball_highscore.mp3'
    ]);

    this.load.image('wizball', 'assets/sprites/wizball.png');
}

function create ()
{
    this.add.image(400, 300, 'wizball').setScale(4);

    var music = this.sound.add('theme');

    music.play();
}

```

I read similar topics, and i try use html5 audio ( in config write property - audio: { disableWebAudio: true}), but if i use this way - audio not worked on all mobile devices.

Is there a way to make all sounds play on all devices (PC and mobile, android and iOS)?

---

<div class="post-metadata">

**Author:** ![Daniil861](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/daniil861/32/6796_2.png) [@Daniil861](https://phaser.discourse.group/u/Daniil861)\
**Post date:** [August 21, 2022, 4:28pm UTC](https://phaser.discourse.group/t/sounds-not-worked-on-ios/12193/2 "2022-08-21T16:28:34Z")

</div>

I found a answer, must use property:  
`this.sound.unlock();`

all work code:

```javascript
var config = {
	type: Phaser.AUTO,
	width: 800,
	height: 600,
	audio: {
		disableWebAudio: true
	},
	scene: {
		preload: preload,
		create: create
	}
};

var text;
var game = new Phaser.Game(config);

function preload() {
	text = this.add.text(10, 10, 'Loading audio ...', { font: '16px Courier', fill: '#00ff00' });

	this.load.audio('dafunk', [
		'assets/audio/Dafunk - Hardcore Power (We Believe In Goa - Remix).ogg',
		'assets/audio/Dafunk - Hardcore Power (We Believe In Goa - Remix).mp3',
		'assets/audio/Dafunk - Hardcore Power (We Believe In Goa - Remix).m4a'
	]);
}

function create() {
	this.sound.pauseOnBlur = false;

	this.input.on('pointerdown', function () {
		this.sound.unlock();
		var music = this.sound.add('dafunk');
		if (!this.sound.locked) {
			music.play();
		}
		else { // IF Not wait on unlock event 
			this.sound.once(Phaser.Sound.Events.UNLOCKED, () => {
				music.play();
			})
		}
	}, this)

	text.setText('Playing Dafunk - Hardcore Power (We Believe In Goa - Remix)');
}

```

---

<div class="post-metadata">

**Author:** ![Mastertaco](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/mastertaco/32/5290_2.png) [@Mastertaco](https://phaser.discourse.group/u/Mastertaco)\
**Post date:** [September 1, 2022, 2:15pm UTC](https://phaser.discourse.group/t/sounds-not-worked-on-ios/12193/3 "2022-09-01T14:15:05Z")

</div>

One thing I noted as I worked with iOS devices is that sometimes the audio started playing a little cut off from the beginning, so I needed to add a little bit of empty sound in the audio file before the sound effect I wanted.

I never knew why this happened.
