Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion configs/e2e/native_dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"react-native-image-picker": "7.2.3",
"react-native-permissions": "5.5.1",
"react-native-webview": "13.16.1",
"@sbaiahmed1/react-native-biometrics": "0.15.0"
"@sbaiahmed1/react-native-biometrics": "0.15.0",
"react-native-sound": "0.13.0"
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@
"@mendix/pluggable-widgets-tools@11.8.0": "patches/@mendix+pluggable-widgets-tools+11.8.0.patch",
"react-native-gesture-handler@2.31.2": "patches/react-native-gesture-handler+2.31.2.patch",
"react-native-slider@0.11.0": "patches/react-native-slider+0.11.0.patch",
"react-native-snap-carousel@3.9.1": "patches/react-native-snap-carousel+3.9.1.patch",
"react-native-track-player@4.1.2": "patches/react-native-track-player@4.1.2.patch"
"react-native-snap-carousel@3.9.1": "patches/react-native-snap-carousel+3.9.1.patch"
}
},
"packageManager": "pnpm@10.32.0+sha512.9b2634bb3fed5601c33633f2d92593f506270a3963b8c51d2b2d6a828da615ce4e9deebef9614ccebbc13ac8d3c0f9c9ccceb583c69c8578436fa477dbb20d70"
Expand Down
2 changes: 1 addition & 1 deletion packages/jsActions/mobile-resources-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"react-native-image-picker": "7.2.3",
"react-native-localize": "3.7.0",
"react-native-permissions": "5.5.1",
"react-native-track-player": "4.1.2",
"react-native-sound": "0.13.0",
"url-parse": "^1.4.7"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import TrackPlayer, { State, Event } from "react-native-track-player";
import Sound from "react-native-sound";

// BEGIN EXTRA CODE
// END EXTRA CODE
Expand All @@ -19,7 +19,7 @@ import TrackPlayer, { State, Event } from "react-native-track-player";
*/
export async function PlaySound(audioFile?: mendix.lib.MxObject): Promise<void> {
// BEGIN USER CODE
// Documentation https://rntp.dev
// Documentation https://github.com/zmxv/react-native-sound

if (!audioFile) {
return Promise.reject(new Error("Input parameter 'Audio file' is required"));
Expand All @@ -35,33 +35,22 @@ export async function PlaySound(audioFile?: mendix.lib.MxObject): Promise<void>

try {
const url = await mx.data.getDocumentUrl(guid, changedDate);
// Initialize the player if it hasn't been set up yet
const state = await TrackPlayer.getPlaybackState();
if (state.state === State.None) {
await TrackPlayer.setupPlayer({
maxCacheSize: 1024
});
}

await TrackPlayer.reset();
await TrackPlayer.add({
id: guid,
url,
title: `Audio ${guid}`,
artist: "Mendix App"
});

await TrackPlayer.play();

return new Promise<void>((resolve, reject) => {
const subscription = TrackPlayer.addEventListener(Event.PlaybackState, event => {
if (event.state === State.Stopped || event.state === State.Ended) {
subscription.remove();
resolve();
} else if (event.state === State.Error) {
subscription.remove();
reject(new Error(event.error.message || "Playback error"));
return await new Promise<void>((resolve, reject) => {
const sound = new Sound(url, "", error => {
if (error) {
reject(new Error(`Failed to load audio: ${error.message ?? error}`));
return;
}

sound.play(success => {
sound.release();
if (success) {
resolve();
} else {
reject(new Error("Playback failed due to an audio encoding error"));
}
});
});
});
} catch (error) {
Expand Down
28 changes: 0 additions & 28 deletions patches/react-native-track-player@4.1.2.patch

This file was deleted.

34 changes: 12 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading