~repos /only-bible-app
git clone https://pyrossh.dev/repos/only-bible-app.git
The only bible app you will ever need. No ads. No in-app purchases. No distractions.
8921c8b0
—
pyrossh 2 years ago
fix(macos): audio permission
- lib/store/state.dart +16 -3
- macos/Runner/Info.plist +0 -5
- macos/Runner/Release.entitlements +0 -2
lib/store/state.dart
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import "dart:developer";
|
|
2
|
+
import "dart:io";
|
|
2
3
|
import "package:atoms_state/atoms_state.dart";
|
|
4
|
+
import "package:flutter/foundation.dart";
|
|
3
5
|
import "package:flutter/material.dart";
|
|
4
6
|
import "package:flutter/services.dart";
|
|
5
7
|
import "package:get_storage/get_storage.dart";
|
|
@@ -11,6 +13,7 @@ import "package:only_bible_app/theme.dart";
|
|
|
11
13
|
import "package:only_bible_app/utils.dart";
|
|
12
14
|
import "package:only_bible_app/navigation.dart";
|
|
13
15
|
import "package:only_bible_app/store/actions.dart";
|
|
16
|
+
import "package:path_provider/path_provider.dart";
|
|
14
17
|
|
|
15
18
|
final box = GetStorage("only-bible-app-prefs");
|
|
16
19
|
final player = AudioPlayer();
|
|
@@ -274,12 +277,22 @@ onPlay(BuildContext context, Bible bible) async {
|
|
|
274
277
|
} else {
|
|
275
278
|
dispatch(const SetPlaying(true));
|
|
276
279
|
for (final v in versesToPlay) {
|
|
280
|
+
final directory = await getApplicationDocumentsDirectory();
|
|
277
|
-
final pathname = "${bible.name}
|
|
281
|
+
final pathname = "${bible.name}_${v.book}_${v.chapter}_${v.index}";
|
|
282
|
+
final filepath = "${directory.path}/$pathname.mp3";
|
|
278
283
|
try {
|
|
279
|
-
final
|
|
284
|
+
final data = await convertText(context.currentLang.audioVoice, v.text);
|
|
285
|
+
if (!kIsWeb) {
|
|
286
|
+
await File(filepath).writeAsBytes(data);
|
|
287
|
+
await player.setUrl("file:$filepath");
|
|
288
|
+
} else {
|
|
280
|
-
|
|
289
|
+
await player.setAudioSource(BufferAudioSource(data));
|
|
290
|
+
}
|
|
281
291
|
await player.play();
|
|
282
292
|
await player.stop();
|
|
293
|
+
if (!kIsWeb) {
|
|
294
|
+
await File(filepath).delete();
|
|
295
|
+
}
|
|
283
296
|
} catch (err) {
|
|
284
297
|
log("Could not play audio", name: "play", error: (err.toString(), pathname));
|
|
285
298
|
recordError((err.toString(), pathname).toString(), null);
|
macos/Runner/Info.plist
CHANGED
|
@@ -24,11 +24,6 @@
|
|
|
24
24
|
<string>public.app-category.books</string>
|
|
25
25
|
<key>LSMinimumSystemVersion</key>
|
|
26
26
|
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
|
27
|
-
<key>NSAppTransportSecurity</key>
|
|
28
|
-
<dict>
|
|
29
|
-
<key>NSAllowsArbitraryLoads</key>
|
|
30
|
-
<true/>
|
|
31
|
-
</dict>
|
|
32
27
|
<key>NSHumanReadableCopyright</key>
|
|
33
28
|
<string>$(PRODUCT_COPYRIGHT)</string>
|
|
34
29
|
<key>NSMainNibFile</key>
|
macos/Runner/Release.entitlements
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
<dict>
|
|
5
5
|
<key>com.apple.security.app-sandbox</key>
|
|
6
6
|
<true/>
|
|
7
|
-
<key>com.apple.security.network.server</key>
|
|
8
|
-
<true/>
|
|
9
7
|
<key>com.apple.security.network.client</key>
|
|
10
8
|
<true/>
|
|
11
9
|
</dict>
|