iphone - 如何添加 videoPlayer 作为 subview ?

标签 iphone

您好,我面临与添加 subview 相关的问题; 我遵循代码:

        NSString *urlStr  = [NSString  stringWithFormat:@"http:x/iphone0.m3u8"];
        NSURL *videoURL   = [NSURL URLWithString:urlStr];
        MPMoviePlayerController *iVideoPlayer = [[MPMoviePlayerController alloc]initWithContentURL:videoURL];
        [self.view addSubview:iVideoPlayer.view ];  

        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            // The device is an iPad running iPhone 3.2 or later.
             iVideoPlayer.view.frame = CGRectMake(353,258,320,240);
        }
        else
        {
             iVideoPlayer.view.frame = CGRectMake(156,96,168,148);
        }                   
        [iVideoPlayer play];

在这段代码中,我喜欢添加一个视频播放器作为 subview 。我已成功添加视频播放器。但问题是,在视频播放过程中,如果我单击指定区域(CGRectMake(353,258,320,240);视频停止。我喜欢应用视频播放器功能(下一个、暂停、音量增大/减小)还没有完成。 如何解决这个问题?

最佳答案

您可以选择 MPMoviePlayerController 实例的控制样式。通过将 controlStyle 属性设置为以下选项之一,您可以启用某些播放器控件(如暂停、播放等)。

MPMovieControlStyleNone,
MPMovieControlStyleEmbedded,
MPMovieControlStyleFullscreen,
MPMovieControlStyleDefault

以上样式的说明可以在这里找到:MPMoviePlayerController Class Reference

以下是如何设置此属性的示例。

[iVideoPlayer setControlStyle:MPMovieControlStyleEmbedded]

关于iphone - 如何添加 videoPlayer 作为 subview ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10497057/

相关文章:

iphone - iOS 4.2.1出现一些问题

iphone - 如何将 subview (其边缘的小 ImageView )添加到使用控件中的 segment-1

iphone - 字符串中的通配符

iphone - 如何让 UITextField 响应 UITextFieldDelegate?

iphone - 如何收集 iPhone 应用程序用户的电子邮件地址

iphone - iOS简单的SQL错误

iphone - 如何从 NSDictionary 获取数据到 NSArray

IOS 10.2 UserNotifications 关于简单警报和角标(Badge)的问题

iphone - NSMutableArray 中的 UITableView 分组部分

iphone - 以编程方式在 iphone SDK 中同时录制声音和播放