Hi all, i have a class that wraps AVPlayer and right now i am a bit stuck. I need to create a listener to when a track is completed. I figured i would use something like this:
NSNotificationCenter.defaultCenter.addObserver(
observer = avPlayer,
selector = NSSelectorFromString(TrackCompletedListener::playerDidFinishPlaying.name + ":"),
name = AVPlayerItemDidPlayToEndTimeNotification,
`object` = null,
)
Problem is i get this exception when the track is completed:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AVPlayer playerDidFinishPlaying:]: unrecognized selector sent to instance 0x600000014660'
And i have no clue on how to fix it.
EDIT on how i fixed it in thread ->