Explorar o código

修复本地播放问题

i2edu %!s(int64=4) %!d(string=hai) anos
pai
achega
64e73b6d74
Modificáronse 2 ficheiros con 8 adicións e 5 borrados
  1. 1 1
      example/.flutter-plugins-dependencies
  2. 7 4
      ios/Classes/FlutterSoundPlugin.m

+ 1 - 1
example/.flutter-plugins-dependencies

@@ -1 +1 @@
-{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"flutter_sound","dependencies":[]}]}
+{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_sound","path":"/Users/i2edu/Documents/workspace/flutter_sound/","dependencies":[]}],"android":[{"name":"flutter_sound","path":"/Users/i2edu/Documents/workspace/flutter_sound/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_sound","dependencies":[]}],"date_created":"2020-09-28 15:16:21.681463","version":"1.20.4"}

+ 7 - 4
ios/Classes/FlutterSoundPlugin.m

@@ -301,10 +301,13 @@ NSString* status = [NSString stringWithFormat:@"{\"current_position\": \"%@\"}",
 
     [downloadTask resume];
   } else {
-    // if (!audioPlayer) { // Fix sound distoring when playing recorded audio again.
-      audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFileURL error:nil];
-      audioPlayer.delegate = self;
-    // }
+      NSData *imageData = [NSData dataWithContentsOfFile:path];
+          // if (!audioPlayer) { // Fix sound distoring when playing recorded audio again.
+      //      audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFileURL error:nil];
+      //      audioPlayer.delegate = self;
+          // }
+    self->audioPlayer = [[AVAudioPlayer alloc] initWithData:imageData error:nil];
+    self->audioPlayer.delegate = self;
 
     // Able to play in silent mode
     [[AVAudioSession sharedInstance]