I'm doing that (using UTType.movie.identifier instead of the literal "public.movie"), and then loading the resulting URL into an AVPlayer, but I get an error message and the video doesn't play.
Here's my code:
import AVKit
import PhotosUI
import UIKit
class ViewController: UIViewController {
		override func viewDidLoad() {
				super.viewDidLoad()
		}
	
		@IBAction func selectMovieTapped(_ sender: UIButton) {
				var config = PHPickerConfiguration()
				config.filter = .videos
				let picker = PHPickerViewController(configuration: config)
				picker.delegate = self
				present(picker, animated: true, completion: nil)
		}
	
}
extension ViewController: PHPickerViewControllerDelegate {
		func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
				picker.dismiss(animated: true, completion: nil)
				guard let provider = results.first?.itemProvider else { return }
				if provider.hasItemConformingToTypeIdentifier(UTType.movie.identifier) {
						provider.loadItem(forTypeIdentifier: UTType.movie.identifier, options: [:]) { [self] (videoURL, error) in
								print("resullt:", videoURL, error)
								DispatchQueue.main.async {
										if let url = videoURL as? URL {
												let player = AVPlayer(url: url)
												let playerVC = AVPlayerViewController()
												playerVC.player = player
												present(playerVC, animated: true, completion: nil)
										}
								}
						}
				}
		}
}
It prints the following when I pick a video on the simulator:
resullt: Optional(file:///Users/zev/Library/Developer/CoreSimulator/Devices/C5BEBCF2-D16A-41F7-B788-6CC208B02D4C/data/Containers/Shared/AppGroup/D7862E29-F13B-42A8-A74B-721676090D8D/File%20Provider%20Storage/47F700FF-7501-49A0-B84B-23E701A758F9.mov) nil
2020-07-01 07:56:34.992199-0400 DeflickerPOC[20292:373394] [] [07:56:34.992] FigFileForkOpenMainByCFURL signalled err=2 (errno) (open failed) at /Library/Caches/com.apple.xbs/Sources/EmbeddedCoreMediaFramework_Sim/EmbeddedCoreMedia-2729.5.1.3/Sources/Platform/Darwin/DarwinFile.c:564
And the player VC presents, but is not playable. It shows a ▶️ with a 🚫 through it (roughly; I can't attach or link to a screenshot on this forum, apparently).
Post
Replies
Boosts
Views
Activity
Submitted. Thanks! FB7834225
I haven't found a feature that does what you ask, but as a workaround, you can add a separate PreviewSurface node just for previewing. When you want to preview a node, connect it up to the appropriate input of the PreviewSurface node, and temporarily connect the Preview Surface node to the Custom Surface output of your material.
Note that this has two major downsides:
It requires some fiddly manual connection. It would be so nice if this were automatic!
If the type of the node you want to preview doesn't match the Diffuse Color input (or whichever input you want to use) of the PreviewSurface node, you'll need to transform it into color data first, which adds more tedious steps.
I'd definitely recommend filing a feedback explaining why you'd like this, and how you use it in Unity! I find myself missing the same feature from Blender's node tools add-on.