Skip to content

Commit ae36cf5

Browse files
Skipping calling load method on an audio tag on mobile devices
1 parent 402aa27 commit ae36cf5

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/loader/filetypes/HTML5AudioFile.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ var HTML5AudioFile = new Class({
6969
this.filesLoaded = 0;
7070
this.percentComplete = 0;
7171

72+
var touchLocked = 'ontouchstart' in window;
73+
7274
for(var i = 0; i < instances; i++)
7375
{
7476
var audio = new Audio();
7577
audio.name = this.key + ('0' + i).slice(-2); // Useful for debugging
7678
audio.dataset.used = 'false';
7779

78-
if (!('ontouchstart' in window))
80+
if (!touchLocked)
7981
{
8082
audio.preload = 'auto';
8183
audio.oncanplaythrough = this.onProgress.bind(this);
@@ -89,7 +91,11 @@ var HTML5AudioFile = new Class({
8991
{
9092
audio = this.data[i];
9193
audio.src = GetURL(this, baseURL || '');
92-
audio.load();
94+
95+
if (!touchLocked)
96+
{
97+
audio.load();
98+
}
9399
}
94100
}
95101

0 commit comments

Comments
 (0)