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 _configuredSession;
BOOL _playing;
float _speed;
}
- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)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];
}

View File

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