                                                selector: #selector(applicationWillResignActive(_:)),
                                                name: NSNotification.Name.UIApplicationWillResignActive,
                                                object: nil)
-        
+
         NotificationCenter.default.addObserver(self,
                                                selector: #selector(handleMediaServicesReset),
                                                name: NSNotification.Name.AVAudioSessionMediaServicesWereReset,
                                                object: nil)
-        
+
         NotificationCenter.default.addObserver(self,
                                                selector: #selector(handleMediaServicesLost),
                                                name: NSNotification.Name.AVAudioSessionMediaServicesWereLost,
                                                object: nil)
-        
+
         NotificationCenter.default.addObserver(self,
                                                selector: #selector(handleRouteChange),
                                                name: .AVAudioSessionRouteChange,
                                                object: AVAudioSession.sharedInstance())
-        
-        
-    }
-    
+    }
+
     @objc func applicationWillResignActive(_ notification: NSNotification) {
         deactivateAudioSession()
     }
-    
+
     deinit {
         player?.pause()
         elapsedTimeTimer?.invalidate()

    }

    private var currentPlayingIndex: Int = 0
    
    fileprivate func updateCurrentPlaying() {
        if var currentFile = currentFile, let fileUrl = currentFile.localFilePath(), fileUrl != player?.url {
            if let currentFileIndex = files.index(where: {$0.id == currentFile.id}) {

import SwiftyTimer

class YSPlayerViewModel: NSObject, YSPlayerViewModelProtocol, AVAudioPlayerDelegate {

    let commandCenter = MPRemoteCommandCenter.shared()

    weak var playerDelegate: YSPlayerDelegate?
