How can I check if my AVPlayer is buffering?

You can observe the values of your player.currentItem: playerItem.addObserver(self, forKeyPath: “playbackBufferEmpty”, options: .New, context: nil) playerItem.addObserver(self, forKeyPath: “playbackLikelyToKeepUp”, options: .New, context: nil) playerItem.addObserver(self, forKeyPath: “playbackBufferFull”, options: .New, context: nil) then override public func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) { if object is AVPlayerItem { switch keyPath { case “playbackBufferEmpty”: … Read more

PHP CLI: How to read a single character of input from the TTY (without waiting for the enter key)?

The solution for me was to set -icanon mode on the TTY (using stty). Eg.: stty -icanon So, the the code that now works is: #!/usr/bin/php <?php system(“stty -icanon”); echo “input# “; while ($c = fread(STDIN, 1)) { echo “Read from STDIN: ” . $c . “\ninput# “; } ?> Output: input# fRead from STDIN: … Read more