Skip to content

Commit 7572d08

Browse files
committed
fix(audio): use html5 audio to make howler work
was not working on ios in silent mode
1 parent 880f9ff commit 7572d08

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

packages/web-component/src/components/read-along-component/read-along.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
extractPages,
2121
extractAlignment,
2222
isFileAvailable,
23+
isIOS,
2324
getUserPreferences,
2425
USER_PREFERENCE_VERSION,
2526
setUserPreferences,
@@ -1200,6 +1201,7 @@ export class ReadAlongComponent {
12001201
// load basic Howl
12011202
this.audio_howl = new Howl({
12021203
src: [this.audio],
1204+
html5: isIOS(),
12031205
preload: false,
12041206
});
12051207
// Once loaded, get duration and build Sprite

packages/web-component/src/utils/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export function zip(arrays): Array<any[]> {
1717
});
1818
}
1919

20+
export function isIOS(): boolean {
21+
return /iPad|iPhone|iPod/.test(navigator.userAgent);
22+
}
23+
2024
/**
2125
* Return pages from readalong XML file
2226
* @param {string} - the path to the readalong file
@@ -98,7 +102,7 @@ export function extractAlignment(parsed_text: Array<Page>): Alignment {
98102
*/
99103
export var Sprite = function (options) {
100104
var self = this;
101-
105+
const html5 = isIOS();
102106
self.sounds = [];
103107
// Setup the options to define this sprite display.
104108
self._sprite = options.sprite;
@@ -120,6 +124,7 @@ export var Sprite = function (options) {
120124
src: options.src,
121125
sprite: options.sprite,
122126
rate: options.rate,
127+
html5: html5,
123128
onend: function () {
124129
self._reading$.next(""); //flush the pipe
125130
},

0 commit comments

Comments
 (0)