From 8f0ac3d605390cfb262696dd47b63e10408e0db2 Mon Sep 17 00:00:00 2001 From: Ryan Heise Date: Tue, 7 Apr 2020 12:13:55 +1000 Subject: [PATCH] Check API availability on MacOS --- darwin/Classes/AudioPlayer.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/darwin/Classes/AudioPlayer.m b/darwin/Classes/AudioPlayer.m index c82a235aa..2cf5434b5 100644 --- a/darwin/Classes/AudioPlayer.m +++ b/darwin/Classes/AudioPlayer.m @@ -165,7 +165,7 @@ - (void)setUrl:(NSString*)url result:(FlutterResult)result { [self setPlaybackState:connecting]; if (_player) { [[_player currentItem] removeObserver:self forKeyPath:@"status"]; - if (@available(iOS 10.0, *)) {[_player removeObserver:self forKeyPath:@"timeControlStatus"];} + if (@available(macOS 10.12, iOS 10.0, *)) {[_player removeObserver:self forKeyPath:@"timeControlStatus"];} [[NSNotificationCenter defaultCenter] removeObserver:_endObserver]; _endObserver = 0; } @@ -202,7 +202,7 @@ - (void)setUrl:(NSString*)url result:(FlutterResult)result { [_player removeTimeObserver:_timeObserver]; _timeObserver = 0; } - if (@available(iOS 10.0, *)) { + if (@available(macOS 10.12, iOS 10.0, *)) { _player.automaticallyWaitsToMinimizeStalling = _automaticallyWaitsToMinimizeStalling; [_player addObserver:self forKeyPath:@"timeControlStatus" @@ -246,7 +246,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath break; } } - if (@available(iOS 10.0, *)) { + if (@available(macOS 10.12, iOS 10.0, *)) { if ([keyPath isEqualToString:@"timeControlStatus"]) { AVPlayerTimeControlStatus status = AVPlayerTimeControlStatusPaused; NSNumber *statusNumber = change[NSKeyValueChangeNewKey]; @@ -278,7 +278,7 @@ - (void)play { //int lag = 6; //int start = [self getCurrentPosition]; [_player play]; - if (!@available(iOS 10.0, *)) {[self setPlaybackState:playing];} + if (!@available(macOS 10.12, iOS 10.0, *)) {[self setPlaybackState:playing];} // TODO: convert this Android code to iOS /* if (endDetector != null) { */ /* handler.removeCallbacks(endDetector); */ @@ -302,7 +302,7 @@ - (void)play { - (void)pause { [_player pause]; - if (!@available(iOS 10.0, *)) {[self setPlaybackState:paused];} + if (!@available(macOS 10.12, iOS 10.0, *)) {[self setPlaybackState:paused];} } - (void)stop { @@ -335,7 +335,7 @@ - (void)setSpeed:(float)speed { -(void)setAutomaticallyWaitsToMinimizeStalling:(bool)automaticallyWaitsToMinimizeStalling { _automaticallyWaitsToMinimizeStalling = automaticallyWaitsToMinimizeStalling; - if (@available(iOS 10.0, *)) { + if (@available(macOS 10.12, iOS 10.0, *)) { if(_player) { _player.automaticallyWaitsToMinimizeStalling = automaticallyWaitsToMinimizeStalling; }