diff --git a/darwin/Classes/AudioPlayer.m b/darwin/Classes/AudioPlayer.m index 02c662d..3b536b0 100644 --- a/darwin/Classes/AudioPlayer.m +++ b/darwin/Classes/AudioPlayer.m @@ -39,6 +39,7 @@ BOOL _automaticallyWaitsToMinimizeStalling; BOOL _configuredSession; BOOL _playing; + float _speed; } - (instancetype)initWithRegistrar:(NSObject *)registrar playerId:(NSString*)idParam configuredSession:(BOOL)configuredSession { @@ -74,6 +75,7 @@ _loadResult = nil; _playResult = nil; _automaticallyWaitsToMinimizeStalling = YES; + _speed = 1.0f; __weak __typeof__(self) weakSelf = self; [_methodChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) { [weakSelf handleMethodCall:call result:result]; @@ -919,7 +921,7 @@ [[AVAudioSession sharedInstance] setActive:YES error:nil]; } #endif - [_player play]; + _player.rate = _speed; [self updatePosition]; if (@available(macOS 10.12, iOS 10.0, *)) {} else { @@ -961,7 +963,10 @@ if (speed == 1.0 || (speed < 1.0 && _player.currentItem.canPlaySlowForward) || (speed > 1.0 && _player.currentItem.canPlayFastForward)) { - _player.rate = speed; + _speed = speed; + if (_playing) { + _player.rate = speed; + } } [self updatePosition]; } diff --git a/example/pubspec.lock b/example/pubspec.lock index 566c144..ae3ad01 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -113,7 +113,7 @@ packages: path: ".." relative: true source: path - version: "0.3.4" + version: "0.4.0" matcher: dependency: transitive description: