Skip to content

Commit c0e97f0

Browse files
authored
fix: ios/macos no longer start audio when calling only setSourceUrl (#1206)
1 parent 40644cc commit c0e97f0

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

packages/audioplayers/example/macos/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ EXTERNAL SOURCES:
2020

2121
SPEC CHECKSUMS:
2222
audioplayers_darwin: dcad41de4fbd0099cb3749f7ab3b0cb8f70b810c
23-
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
23+
FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811
2424
path_provider_macos: 160cab0d5461f0c0e02995469a98f24bdb9a3f1f
2525

2626
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

packages/audioplayers_darwin/darwin/Classes/WrappedMediaPlayer.swift

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ class WrappedMediaPlayer {
8181

8282
func resume() {
8383
isPlaying = true
84-
if #available(iOS 10.0, macOS 10.12, *) {
85-
player?.playImmediately(atRate: Float(playbackRate))
86-
} else {
87-
player?.play()
84+
if let player = self.player {
85+
configParameters(player: player)
86+
if #available(iOS 10.0, macOS 10.12, *) {
87+
player.playImmediately(atRate: Float(playbackRate))
88+
} else {
89+
player.play()
90+
}
91+
updateDuration()
8892
}
8993
}
9094

@@ -209,7 +213,6 @@ class WrappedMediaPlayer {
209213
let status = playerItem.status
210214
Logger.info("player status: %@ change: %@", status, change)
211215

212-
// Do something with the status...
213216
if status == .readyToPlay {
214217
self.updateDuration()
215218
completer?()
@@ -228,7 +231,9 @@ class WrappedMediaPlayer {
228231
}
229232

230233
func configParameters(player: AVPlayer) {
231-
player.volume = Float(volume)
232-
player.rate = Float(playbackRate)
234+
if (isPlaying) {
235+
player.volume = Float(volume)
236+
player.rate = Float(playbackRate)
237+
}
233238
}
234239
}

0 commit comments

Comments
 (0)