gpt4 book ai didi

iphone - 电影播放完毕后在电影播放器​​中显示控件

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:44:06 24 4
gpt4 key购买 nike

我想在电影结束时显示电影播放器​​控件,所以我将观察者添加到 NSNotificationCenter :

- (void)movieFinishedCallback:(NSNotification*)aNotification
{
// Obtain the reason why the movie playback finished
NSNumber *finishReason = [[aNotification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];

if ([finishReason intValue] == 0)
{
[self showControls];
}

// Handle other reasons
}


- (void)showControls
{
for(id views in [[[self.playerVC moviePlayer] view] subviews]){
for(id subViews in [views subviews]){
for (id controlView in [subViews subviews]){
[controlView setAlpha:1.0];
[controlView setHidden:NO];
}
}
}
}

直到现在一切都运行良好并且出现了控件,但是当我点击屏幕以隐藏它们时,控件消失并很快再次出现(类似于闪光灯),然后我需要再次点击查看隐藏控件..

有人知道我为什么遇到这个问题吗?或者有另一个想法在视频结束时显示控件?

最佳答案

首先调试并打印MPMoviePlayerView的 subview ,记下 subview ,找到控件 View 的名称。

这是我在我的应用程序中进行的调试。

Printing description of subViews:
<MPVideoContainerView: 0x7f936950f6e0; frame = (0 0; 375 667); autoresize = W+H; layer = <CALayer: 0x7f936950fa30>>
Printing description of controlView:
<MPVideoPlaybackOverlayView: 0x7f9369659a70; frame = (0 0; 375 667); alpha = 0; hidden = YES; autoresize = W+H; tag = 1004; layer = <CALayer: 0x7f93696c4710>>
Printing description of subViews:
<MPVideoContainerView: 0x7f936950f6e0; frame = (0 0; 375 667); autoresize = W+H; layer = <CALayer: 0x7f936950fa30>>
Printing description of views:
<MPSwipableView: 0x7f9369510290; frame = (0 0; 375 667); autoresize = W+H; gestureRecognizers = <NSArray: 0x7f9369510d30>; layer = <CALayer: 0x7f9369510620>>

然后我检查了控件 View 的名称并将其从播放器中删除。将其设置为隐藏。

- (void)hideControls
{
for(id views in [[player view] subviews]){
for(id subViews in [views subviews]){
for (id controlView in [subViews subviews]){
if ( [controlView isKindOfClass:NSClassFromString(@"MPVideoPlaybackOverlayView")] ) {
[controlView setAlpha:0.0];
[controlView setHidden:YES];
}
}
}
}
}

关于iphone - 电影播放完毕后在电影播放器​​中显示控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13153131/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com