Skip to content

Commit 058bac8

Browse files
Harun.KarahanUrazAkgultan
Harun.Karahan
authored andcommitted
revert "react-native-track-player"
1 parent 78f18cb commit 058bac8

File tree

3 files changed

+24
-43
lines changed

3 files changed

+24
-43
lines changed

packages/jsActions/mobile-resources-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"react-native-localize": "3.2.1",
4141
"react-native-permissions": "4.1.5",
4242
"react-native-schedule-exact-alarm-permission": "^0.1.3",
43-
"react-native-track-player": "^4.1.1",
43+
"react-native-sound": "0.11.0",
4444
"url-parse": "^1.4.7"
4545
},
4646
"devDependencies": {

packages/jsActions/mobile-resources-native/src/platform/PlaySound.ts

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// - the code between BEGIN USER CODE and END USER CODE
66
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
77
// Other code you write will be lost the next time you deploy the project.
8-
import TrackPlayer, { Event } from "react-native-track-player";
8+
import Sound from "react-native-sound";
99

1010
// BEGIN EXTRA CODE
1111
// END EXTRA CODE
@@ -34,30 +34,19 @@ export async function PlaySound(audioFile?: mendix.lib.MxObject): Promise<void>
3434
const changedDate = audioFile.get("changedDate") as number;
3535
const url = mx.data.getDocumentUrl(guid, changedDate);
3636

37-
const play = async () => {
38-
await TrackPlayer.reset();
39-
40-
await TrackPlayer.add({
41-
id: guid,
42-
url,
43-
title: "Audio Playback",
44-
artist: "Unknown"
37+
const audio = new Sound(url, undefined, error => {
38+
if (error) {
39+
return Promise.reject(new Error(error));
40+
}
41+
42+
audio.play(success => {
43+
audio.release();
44+
if (success) {
45+
return Promise.resolve();
46+
}
47+
return Promise.reject(new Error("Playback failed due to an audio encoding error"));
4548
});
49+
});
4650

47-
await TrackPlayer.play();
48-
49-
const listener = TrackPlayer.addEventListener(Event.PlaybackQueueEnded, async () => {
50-
listener.remove(); // cleanup
51-
});
52-
};
53-
54-
try {
55-
await play();
56-
} catch (error) {
57-
// it means the player wasn't initialized yet.
58-
await TrackPlayer.setupPlayer();
59-
await play();
60-
console.error("Playback failed", error);
61-
}
6251
// END USER CODE
6352
}

yarn.lock

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12136,7 +12136,7 @@ __metadata:
1213612136
react-native-localize: "npm:3.2.1"
1213712137
react-native-permissions: "npm:4.1.5"
1213812138
react-native-schedule-exact-alarm-permission: "npm:^0.1.3"
12139-
react-native-track-player: "npm:^4.1.1"
12139+
react-native-sound: "npm:0.11.0"
1214012140
rimraf: "npm:^4.4.1"
1214112141
rollup: "npm:^2.79.2"
1214212142
url-parse: "npm:^1.4.7"
@@ -14353,6 +14353,15 @@ __metadata:
1435314353
languageName: node
1435414354
linkType: hard
1435514355

14356+
"react-native-sound@npm:0.11.0":
14357+
version: 0.11.0
14358+
resolution: "react-native-sound@npm:0.11.0"
14359+
peerDependencies:
14360+
react-native: ">=0.8.0"
14361+
checksum: 10/17eff55af971ef6d76d678a8de5b556cffaeced38e7c64277d441e78a55773fd5b34e986c545b8d42059e22bb66070a5ccbacd237496d9f3c9fed7ec8f3776c3
14362+
languageName: node
14363+
linkType: hard
14364+
1435614365
"react-native-svg@npm:15.7.1":
1435714366
version: 15.7.1
1435814367
resolution: "react-native-svg@npm:15.7.1"
@@ -14377,23 +14386,6 @@ __metadata:
1437714386
languageName: node
1437814387
linkType: hard
1437914388

14380-
"react-native-track-player@npm:^4.1.1":
14381-
version: 4.1.1
14382-
resolution: "react-native-track-player@npm:4.1.1"
14383-
peerDependencies:
14384-
react: ">=16.8.6"
14385-
react-native: ">=0.60.0-rc.2"
14386-
react-native-windows: ">=0.63.0"
14387-
shaka-player: ^4.7.9
14388-
peerDependenciesMeta:
14389-
react-native-windows:
14390-
optional: true
14391-
shaka-player:
14392-
optional: true
14393-
checksum: 10/6e755319a3f86d279e23392a2dc36ee0a55280526b5796f36f5d80da044a9b1de9b38d77b48259d815723c512e5a0a6bc5d4fda6f54b73d26f91b476c4cad9d2
14394-
languageName: node
14395-
linkType: hard
14396-
1439714389
"react-native-vector-icons@npm:10.2.0":
1439814390
version: 10.2.0
1439914391
resolution: "react-native-vector-icons@npm:10.2.0"

0 commit comments

Comments
 (0)