add support to handle mp3 sound

This commit is contained in:
Yueyu 2021-10-11 08:15:50 +08:00
parent d32d2214e7
commit d656f28ca8
3 changed files with 3 additions and 3 deletions

View file

@ -324,7 +324,7 @@ public class IOManager {
if (entry == null) { if (entry == null) {
continue; 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; continue;
} }
// copy file to target file // copy file to target file

View file

@ -332,7 +332,7 @@ NSMutableDictionary *soundtimers;
NSString *path; NSString *path;
while ((path = [enumerator nextObject]) != nil) { while ((path = [enumerator nextObject]) != nil) {
// we are only interested in images and sounds // 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]; NSString *fileName = [path lastPathComponent];
// extract file // extract file
NSString *toPath = [[IO getpath] stringByAppendingPathComponent:fileName]; NSString *toPath = [[IO getpath] stringByAppendingPathComponent:fileName];

View file

@ -86,7 +86,7 @@ export default class ScratchAudio {
var dir = ''; var dir = '';
if (!isAndroid) { if (!isAndroid) {
if (md5.indexOf('/') > -1) dir = 'HTML5/'; 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); ScratchAudio.loadFromLocal(dir, md5, fcn);
} }