From d656f28ca8c991dd44c2568a18f09f2a7e5c2a41 Mon Sep 17 00:00:00 2001 From: Yueyu Date: Mon, 11 Oct 2021 08:15:50 +0800 Subject: [PATCH] add support to handle mp3 sound --- .../app/src/main/java/org/scratchjr/android/IOManager.java | 2 +- ios/ScratchJr/src/IO.m | 2 +- src/utils/ScratchAudio.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/android/ScratchJr/app/src/main/java/org/scratchjr/android/IOManager.java b/android/ScratchJr/app/src/main/java/org/scratchjr/android/IOManager.java index 635d0ca..e5a5396 100644 --- a/android/ScratchJr/app/src/main/java/org/scratchjr/android/IOManager.java +++ b/android/ScratchJr/app/src/main/java/org/scratchjr/android/IOManager.java @@ -324,7 +324,7 @@ public class IOManager { if (entry == null) { continue; } - if (!(entry.endsWith(".png") || entry.endsWith(".wav") || entry.endsWith(".svg"))) { + if (!(entry.endsWith(".png") || entry.endsWith(".wav") || entry.endsWith(".mp3") || entry.endsWith(".svg"))) { continue; } // copy file to target file diff --git a/ios/ScratchJr/src/IO.m b/ios/ScratchJr/src/IO.m index 6fdacb7..e7bedfe 100644 --- a/ios/ScratchJr/src/IO.m +++ b/ios/ScratchJr/src/IO.m @@ -332,7 +332,7 @@ NSMutableDictionary *soundtimers; NSString *path; while ((path = [enumerator nextObject]) != nil) { // we are only interested in images and sounds - if ([path hasSuffix:@".png"] || [path hasSuffix:@".wav"] || [path hasSuffix:@".svg"]) { + if ([path hasSuffix:@".png"] || [path hasSuffix:@".wav"] || [path hasSuffix:@".mp3"] || [path hasSuffix:@".svg"]) { NSString *fileName = [path lastPathComponent]; // extract file NSString *toPath = [[IO getpath] stringByAppendingPathComponent:fileName]; diff --git a/src/utils/ScratchAudio.js b/src/utils/ScratchAudio.js index 1330654..d8398be 100755 --- a/src/utils/ScratchAudio.js +++ b/src/utils/ScratchAudio.js @@ -86,7 +86,7 @@ export default class ScratchAudio { var dir = ''; if (!isAndroid) { if (md5.indexOf('/') > -1) dir = 'HTML5/'; - else if (md5.indexOf('wav') > -1) dir = 'Documents'; + else if (md5.indexOf('wav') > -1 || md5.indexOf('mp3') > -1) dir = 'Documents'; } ScratchAudio.loadFromLocal(dir, md5, fcn); }