AVPlayerLayer を NS ビューに追加する方法について尋ねている質問と同様の質問を見ましたが、それがどのように機能するかを理解するための完全なソース コードが表示されません。私の質問の核心は、プレーヤー オブジェクトを作成し、移動 NSURL で初期化することです。AVPlayerLayer オブジェクトを作成し、プレーヤーで初期化します。AVPlayerLayer を自分自身 (私は NSView です) に追加してプログラムを実行しようとすると、何も得られません。
NSURL *movie = [[NSURL alloc] initWithString:@"file://localhost/Users/matthewmichal/Desktop/A%20Good%20To%20Die%20Hard.mov"];
[player initWithURL:movie];
[self setWantsLayer:YES];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
[self.layer addSublayer:playerLayer];
[player play];