私はAVPlayerView
の 2 番目としてを持ってNSSplitViewItem
いNSSplitViewController
ます。1 つ目の分割項目は動画のリストです。ビデオを選択すると、 で再生されますAVPlayerView
。問題は、再生中のビデオのサイズに応じてビューのサイズが変更されることです[self.videoView.player play];
。MediaViewController
私が使用StoryBoards
していMediaViewController
て、キャンバス上にはAVPlayerView
、スーパービューを抱き締めるためのトップ/ボトム/トレーリング/リーディング セットがあります。これは、ウィンドウのサイズを変更し、それに応じてビデオのサイズを調整することでうまくいくようです。
ビューが自分自身のサイズを変更することを決定した時点と、それを停止するために何をすべきかがわかりません。
設定しましたself.videoView.videoGravity = AVLayerVideoGravityResizeAspect;
私は何が欠けていますか?
ありがとう
編集 - - - - -
問題はビデオ サイズではなく、videoPlayer contentOverlayView に追加したイメージ オーバーレイにあるようです。
次のようにオーバーレイを追加します。
if (self.videoView.contentOverlayView.subviews.count == 0)
{
// Add an NSImageView subview to use for overlays
NSImageView *overlayIV = [[NSImageView alloc] initWithFrame:self.videoView.frame];
[overlayIV setTranslatesAutoresizingMaskIntoConstraints:NO];
[overlayIV setImageScaling:NSImageScaleProportionallyUpOrDown];
[self.videoView.contentOverlayView addSubview:overlayIV];
// Set constraints to hug parent
[self.videoView addConstraint:[NSLayoutConstraint constraintWithItem:overlayIV
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.videoView
attribute:NSLayoutAttributeTop
multiplier:1.0
constant:0.0]];
[self.videoView addConstraint:[NSLayoutConstraint constraintWithItem:overlayIV
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.videoView
attribute:NSLayoutAttributeBottom
multiplier:1.0
constant:0.0]];
[self.videoView addConstraint:[NSLayoutConstraint constraintWithItem:overlayIV
attribute:NSLayoutAttributeLeading
relatedBy:NSLayoutRelationEqual
toItem:self.videoView
attribute:NSLayoutAttributeLeading
multiplier:1.0
constant:0.0]];
[self.videoView addConstraint:[NSLayoutConstraint constraintWithItem:overlayIV
attribute:NSLayoutAttributeTrailing
relatedBy:NSLayoutRelationEqual
toItem:self.videoView
attribute:NSLayoutAttributeTrailing
multiplier:1.0
constant:0.0]];
}
次に、新しい画像オーバーレイを追加すると、ウィンドウのサイズが変更されることがあります。
NSImageView *overlayIV = [self.videoView.contentOverlayView.subviews firstObject];
if (overlayIV)
{
if (image)
{
overlayIV.image = image;
}
else
{
overlayIV.image = nil;
}
}