                                                name: NSNotification.Name.AVAudioSessionMediaServicesWereLost,
                                                object: nil)
         
+        NotificationCenter.default.addObserver(self,
+                                               selector: #selector(handleRouteChange),
+                                               name: .AVAudioSessionRouteChange,
+                                               object: AVAudioSession.sharedInstance())
+        
         
     }
     

    @objc private func handleMediaServicesLost() {
        pause()
    }
}

extension YSPlayerViewModel: YSUpdatingDelegate {

        YSDatabaseManager.updatePlayingInfo(file: currentFile)
    }
    
    //MARK: - oberver methodts
    private func activateAudioSession() {
        do {
            try AVAudioSession.sharedInstance().setActive(true)
