Skip to content

Commit 5da702c

Browse files
committed
add availability check to fix warning messages during iOS build
bluefireteam#425
1 parent 238d4af commit 5da702c

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

darwin/Classes/AudioplayersPlugin.m

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,16 +378,20 @@ -(MPRemoteCommandHandlerStatus) playOrPauseEvent: (MPSkipIntervalCommandEvent *)
378378
AVPlayer *player = playerInfo[@"player"];
379379
bool _isPlaying = false;
380380
NSString *playerState;
381-
if (player.timeControlStatus == AVPlayerTimeControlStatusPlaying) {
382-
// player is playing and pause it
383-
[ self pause:_currentPlayerId ];
384-
_isPlaying = false;
385-
playerState = @"paused";
386-
} else if (player.timeControlStatus == AVPlayerTimeControlStatusPaused) {
387-
// player is paused and resume it
388-
[ self resume:_currentPlayerId ];
389-
_isPlaying = true;
390-
playerState = @"playing";
381+
if (@available(iOS 10.0, *)) {
382+
if (player.timeControlStatus == AVPlayerTimeControlStatusPlaying) {
383+
// player is playing and pause it
384+
[ self pause:_currentPlayerId ];
385+
_isPlaying = false;
386+
playerState = @"paused";
387+
} else if (player.timeControlStatus == AVPlayerTimeControlStatusPaused) {
388+
// player is paused and resume it
389+
[ self resume:_currentPlayerId ];
390+
_isPlaying = true;
391+
playerState = @"playing";
392+
}
393+
} else {
394+
// Fallback on earlier versions
391395
}
392396
[_channel_audioplayer invokeMethod:@"audio.onNotificationPlayerStateChanged" arguments:@{@"playerId": _currentPlayerId, @"value": @(_isPlaying)}];
393397

0 commit comments

Comments
 (0)