bloom-player 2.21.1-alpha.1 → 2.22.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -2
- package/dist/{bloomPlayer.BP9VbJGB.js → bloomPlayer.CE5-ibq6.js} +28 -28
- package/dist/bloomplayer.htm +1 -1
- package/lib/shared.es.js +416 -413
- package/lib/shared.es.js.map +1 -1
- package/package.json +1 -1
- package/src/shared/dragActivityRuntime.ts +17 -2
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A library for displaying Bloom books in iframes or WebViews",
|
|
4
4
|
"author": "SIL Global",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.22.0-alpha.2",
|
|
7
7
|
"packageManager": "pnpm@11.1.2",
|
|
8
8
|
"private": false,
|
|
9
9
|
"// sideeffects might need to be ['*.css'] to avoid 'shaking' our CSS, if we ever get tree shaking working": "",
|
|
@@ -923,6 +923,21 @@ export function setDefaultSoundUrls(
|
|
|
923
923
|
// Attribute used to mark audio elements preloaded for correct/wrong sounds.
|
|
924
924
|
const kPreloadSoundAttr = "data-preload-sound";
|
|
925
925
|
|
|
926
|
+
// Get the URL to play a sound from. If addPrefix is true, soundFile is the value of a
|
|
927
|
+
// data-sound, data-correct-sound or data-wrong-sound attribute: a file in the book's audio
|
|
928
|
+
// folder. Bloom stores that as the plain file name, NOT URL-encoded (BL-16669), so we must
|
|
929
|
+
// encode it here, when it becomes part of a URL. Otherwise a '#' in the name starts a fragment
|
|
930
|
+
// ("bird#1.mp3" is asked for as "bird", BL-16177) and a '%' starts an escape ("beep%41.mp3" is
|
|
931
|
+
// asked for as "beepA.mp3", BL-16688), and the sound silently never plays. Encoding the whole
|
|
932
|
+
// name is safe because it is a bare file name, with no '/' of its own to preserve.
|
|
933
|
+
// If addPrefix is false, soundFile is one of the default sound URLs, already a URL.
|
|
934
|
+
function getSoundUrl(soundFile: string, addPrefix: boolean): string {
|
|
935
|
+
if (!addPrefix) {
|
|
936
|
+
return soundFile;
|
|
937
|
+
}
|
|
938
|
+
return urlPrefix() + "/audio/" + encodeURIComponent(soundFile);
|
|
939
|
+
}
|
|
940
|
+
|
|
926
941
|
// Remove any audio elements previously added by preloadSoundsForActivity.
|
|
927
942
|
// Called from undoPrepareActivity and ActivityContext.stop().
|
|
928
943
|
export function cleanupActivitySounds(page: HTMLElement): void {
|
|
@@ -950,7 +965,7 @@ export function preloadSoundsForActivity(page: HTMLElement): void {
|
|
|
950
965
|
}
|
|
951
966
|
if (!soundFile) return;
|
|
952
967
|
|
|
953
|
-
const url = (addPrefix
|
|
968
|
+
const url = getSoundUrl(soundFile, addPrefix);
|
|
954
969
|
// Avoid duplicate preloads (e.g. if prepareActivity is called more than once)
|
|
955
970
|
const already = Array.from(
|
|
956
971
|
page.querySelectorAll<HTMLAudioElement>(`audio[${kPreloadSoundAttr}]`),
|
|
@@ -1046,7 +1061,7 @@ function playSound(
|
|
|
1046
1061
|
addPrefix = true,
|
|
1047
1062
|
then?: () => void,
|
|
1048
1063
|
) {
|
|
1049
|
-
const url = (addPrefix
|
|
1064
|
+
const url = getSoundUrl(soundFile, addPrefix);
|
|
1050
1065
|
|
|
1051
1066
|
// Reuse a preloaded element if one was prepared by preloadSoundsForActivity.
|
|
1052
1067
|
// This avoids re-downloading the file and removes the delay before playback starts.
|