 import Foundation
+import AVFoundation
 
 internal protocol EventHandling {
   

    NotificationCenter.default().addObserver(forName: .NSFileHandleDataAvailable, object: nil, queue: OperationQueue.main()) { [weak self] _ in
      self?.readFromStandardInputAndWait()  
    }
    runLoop.run()
  }

  @objc private func readFromStandardInputAndWait() {
    defer {

    let event = Event(withInput: input)
    handler?.handle(event: event)
  }

  @objc private func playerItemDidFinishPlaying(_ notification: NSNotification) {
    guard let item = notification.object as? AVPlayerItem else {
      return
    }
    handler?.handle(event: .itemFinishedPlaying(item: item))
  }
}


