SwiftAudio icon indicating copy to clipboard operation
SwiftAudio copied to clipboard

handleAudioPlayerStateChange call multiple time

Open ralspatel opened this issue 4 years ago • 1 comments
trafficstars

Hi @jorgenhenrichsen

func handleAudioPlayerStateChange(data: AudioPlayer.StateChangeEventData) { }

with QueuedAudioPlayer when it plays the song at that time above method call 1 time, once all queued song playing finished, I go back and stop the player so upcoming and previous item will be erased. once I come back at that time above method call 2 times, when I come back at that time above method call 3 times, and so on.

I call the below method in viewwillappear method

controller.player.event.stateChange.addListener(self, handleAudioPlayerStateChange) controller.player.event.secondElapse.addListener(self, handleAudioPlayerSecondElapsed) controller.player.event.seek.addListener(self, handleAudioPlayerDidSeek) controller.player.event.updateDuration.addListener(self, handleAudioPlayerUpdateDuration) controller.player.event.didRecreateAVPlayer.addListener(self, handleAVPlayerRecreated)

controller.player.event.playbackEnd.addListener(self, handlePlayEnd) controller.player.event.fail.addListener(self, handlePlayerFailure) controller.player.nowPlayingInfoController.set(keyValue: NowPlayingInfoProperty.isLiveStream(true))

so I need to remove this listener? if yes then when I need to remove this listner.

Thanks

ralspatel avatar Apr 20 '21 15:04 ralspatel

Hi @ralspatel Did you find any solution for this? I tried removing listener as well but it keeps calling in other screens as well even thogh I have removed listener for that screen. Thanks

moonakash avatar Sep 20 '23 14:09 moonakash