Fix setSpeed bug on iOS.

This commit is contained in:
Ryan Heise 2020-08-28 22:24:56 +10:00
parent 3c37235e03
commit f1aaa0b132
2 changed files with 8 additions and 3 deletions

View File

@ -39,6 +39,7 @@
BOOL _automaticallyWaitsToMinimizeStalling; BOOL _automaticallyWaitsToMinimizeStalling;
BOOL _configuredSession; BOOL _configuredSession;
BOOL _playing; BOOL _playing;
float _speed;
} }
- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar playerId:(NSString*)idParam configuredSession:(BOOL)configuredSession { - (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar playerId:(NSString*)idParam configuredSession:(BOOL)configuredSession {
@ -74,6 +75,7 @@
_loadResult = nil; _loadResult = nil;
_playResult = nil; _playResult = nil;
_automaticallyWaitsToMinimizeStalling = YES; _automaticallyWaitsToMinimizeStalling = YES;
_speed = 1.0f;
__weak __typeof__(self) weakSelf = self; __weak __typeof__(self) weakSelf = self;
[_methodChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) { [_methodChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
[weakSelf handleMethodCall:call result:result]; [weakSelf handleMethodCall:call result:result];
@ -919,7 +921,7 @@
[[AVAudioSession sharedInstance] setActive:YES error:nil]; [[AVAudioSession sharedInstance] setActive:YES error:nil];
} }
#endif #endif
[_player play]; _player.rate = _speed;
[self updatePosition]; [self updatePosition];
if (@available(macOS 10.12, iOS 10.0, *)) {} if (@available(macOS 10.12, iOS 10.0, *)) {}
else { else {
@ -961,7 +963,10 @@
if (speed == 1.0 if (speed == 1.0
|| (speed < 1.0 && _player.currentItem.canPlaySlowForward) || (speed < 1.0 && _player.currentItem.canPlaySlowForward)
|| (speed > 1.0 && _player.currentItem.canPlayFastForward)) { || (speed > 1.0 && _player.currentItem.canPlayFastForward)) {
_player.rate = speed; _speed = speed;
if (_playing) {
_player.rate = speed;
}
} }
[self updatePosition]; [self updatePosition];
} }

View File

@ -113,7 +113,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "0.3.4" version: "0.4.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description: