0
在Mac上,我想使用AVPlayer在我的Qt 4.8應用程序中播放視頻,因爲它具有Phonon::VideoPlayer
沒有的功能。如何將AVPlayer添加到QWidget?
如何將AVPlayerLayer添加到QWidget
以便它變得可見?我正在做以下事情:
pimpl->player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:videoFile]];
pimpl->player.actionAtItemEnd = AVPlayerActionAtItemEndPause;
pimpl->player.rate = 0;
pimpl->playerLayer = [[AVPlayerLayer playerLayerWithPlayer:pimpl->player] retain];
[pimpl->playerLayer setFrame: CGRectMake(0, 0, rect().width(), rect().height())];
NSView* view = (NSView*)winId();
[[view layer] addSublayer:pimpl->playerLayer];
當我播放我的視頻時,我聽到它,但我沒有看到它。任何想法我做錯了什麼?