Skip to content

Commit

Permalink
Check API availability on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanheise committed Apr 7, 2020
1 parent 522eafa commit 8f0ac3d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions darwin/Classes/AudioPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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); */
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 8f0ac3d

Please sign in to comment.