import Foundation
import Cocoa
import AVKit
import AVFoundation
let asset: AVURLAsset = AVURLAsset.init(url: "URL OF ANY VIDEO local/remote")
let imgGenerator: AVAssetImageGenerator = AVAssetImageGenerator.init(asset: asset)
imgGenerator.appliesPreferredTrackTransform = true
imgGenerator.generateCGImagesAsynchronously(forTimes: [NSValue(time: CMTime.zero)]) { (_, image, _, res, error) in
if error == nil {
DispatchQueue.main.async {
let imageView = NSImage.init(cgImage: image!, size: NSSize.init(width: 180.0, height: 180.0));
}
} else {
DispatchQueue.main.async {
// Some other fallback image
}
}
}
Category: macOS
macOS (previously Mac OS X and later OS X) is a proprietary graphical operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple’s Mac computers.
-

Capture first frame of the video as an image on iOS and macOS in swift
-
NSTableView custom highlight color with NSTableRowView
Getting the right color when you select NSTableView’s row was frustrating for me since I didn’t know how to do it properly. But it is really simple, all you need to do is having a class inherit from NSTableRowView and override its method drawSelection(in dirtyRect: NSRect).
import Foundation import Cocoa class MenuTableRowView: NSTableRowView { override func drawSelection(in dirtyRect: NSRect) { if self.selectionHighlightStyle != .none { let selectionRect = NSInsetRect(self.bounds, 2.5, 2.5) if let color = NSColor.init(named: NSColor.Name("menu_table_selection_color")) { color.setFill() } let selectionPath = NSBezierPath.init(roundedRect: selectionRect, xRadius: 0, yRadius: 0) selectionPath.fill() } } }Change menu_table_selection_color value in Assets.xcassets file.

Now go to your NSTableViewDelegate’s method add your custom NSTableRowView.
func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? { return MenuTableRowView() }Here you can see how my Storyboard looks like. Table view highlight value must be regular.

-

Install PHP 5.6 on macOS Catalina
These steps worked on my Mac, Catalina version 10.15.3 (19D76).
Step 1: Tap deprecated brew formula
brew tap exolnet/homebrew-deprecated
Step 2: Install PHP 5.6
brew install [email protected]
You can also have PHP 7.2 just run
brew install [email protected]
Step 3: Install PHP switcher script to switch between 5.6 and 7.2
$ curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw > /usr/local/bin/sphp
$ chmod +x /usr/local/bin/sphpIf you run sphp 7.2 it should work but running sphp 5.6 will not work and will show error like this from apache.
Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylibn Referenced from: /usr/local/opt/[email protected]/lib/httpd/modules/libphp5.son Reason: image not found
Unless we switch openssl version, it wont work. So we have to install old openssl
Step 4: Install old openssl
brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb
Step 5: Switch to openssl 1.0
brew switch openssl 1.0.2t
Now you switch to PHP 5.6 by
sphp 5.6
Everything works.
You can run these commands to check which version of openssl is being used in your mac.
brew info openssl and brew info openssh