SwiftAudio icon indicating copy to clipboard operation
SwiftAudio copied to clipboard

Player state does not always change to playing

Open biesbjerg opened this issue 6 years ago • 0 comments
trafficstars

Player state sometimes does not change to playing, even though audio starts and elapsedSecond event emits. It happens randomly, but more often if your network connection is slow. I'm testing on a device using Network Link Conditioner in Settings -> Developer Options to simulate a slow connection.

image

If you look at this log, it shouldn't be possible for player.playerState to be paused while emitting secondElapse (and actually playing):

⌛ stateChange - state: paused
⌛ stateChange - state: loading
⌛ stateChange - state: paused
⌛ secondElapse - currentTime: 0.0 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ secondElapse - currentTime: 0.0 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ secondElapse - currentTime: 0.0 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ updateDuration: 0.3657142857142857
⌛ secondElapse - currentTime: 0.02672804 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ secondElapse - currentTime: 0.026939374 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ updateDuration: 2.36472281
⌛ updateDuration: 7.380233014
⌛ secondElapse - currentTime: 1.000674124 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ updateDuration: 11.403090157
⌛ updateDuration: 16.941049341
⌛ secondElapse - currentTime: 2.000570967 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ updateDuration: 20.467579953
⌛ secondElapse - currentTime: 3.001347996 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ updateDuration: 23.994110565
⌛ updateDuration: 27.520641177
⌛ secondElapse - currentTime: 4.001117254 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ updateDuration: 33.032477912
⌛ updateDuration: 36.559008524
⌛ secondElapse - currentTime: 5.001199992 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ updateDuration: 42.096967708
⌛ secondElapse - currentTime: 6.000966879 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ updateDuration: 46.616151381
⌛ updateDuration: 52.154110565
⌛ secondElapse - currentTime: 7.000541125 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ updateDuration: 55.680641177
⌛ secondElapse - currentTime: 7.856695665 / state: Optional(SwiftAudio.AVPlayerWrapperState.paused)
⌛ updateDuration: 59.20717179

Tested on a device with iOS 13.

biesbjerg avatar Nov 02 '19 10:11 biesbjerg