【发布时间】:2013-06-26 18:41:56
【问题描述】:
在 Mac 上,我想使用 AVPlayer 在我的 Qt 4.8 应用程序中播放视频,因为它具有 Phonon::VideoPlayer 所没有的功能。
如何将 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];
当我播放我的视频时,我能听到,但我看不到。知道我做错了什么吗?
【问题讨论】:
标签: macos cocoa qt4 avplayer qt4.8