【问题标题】:How to add custom Play/ pause buttons, volume bar etc in MPMoviePlayerController?如何在 MPMoviePlayerController 中添加自定义播放/暂停按钮、音量条等?
【发布时间】:2015-06-08 07:05:40
【问题描述】:

我正在尝试创建一个如下图所示的播放器,从播放和暂停按钮开始。但它没有出现在播放器上。如何为我的播放器、自定义栏、音量栏等创建自定义面板?

- (IBAction)playMovie:(UIButton *)sender {

NSURL *url = [[NSURL alloc] initWithString:urlStr.text];
self.movie = [[MPMoviePlayerController alloc]initWithContentURL:url];
self.movie.controlStyle = MPMovieControlStyleNone;

self.movie.shouldAutoplay = YES;
[self.view addSubview:self.movie.view];
[self.movie setFullscreen:YES animated:YES];

playButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 200, 100, 100)];
[playButton setImage:[UIImage imageNamed:@"apple.png"] forState:UIControlStateNormal];
[playButton addTarget:self action:@selector(playButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:playButton];
}

【问题讨论】:

    标签: ios objective-c video-streaming custom-controls mpmovieplayercontroller


    【解决方案1】:

    在带有按钮的视图上添加播放器,就像您的图片描述的那样

        moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:urlVideo];
        [moviePlayerController.view setFrame:CGRectMake(0, 170, 320, 270)];
        [self.view addSubview:moviePlayerController.view];
        moviePlayerController.fullscreen = YES;
        [moviePlayerController play];// put it in action
    

    【讨论】:

    • 您好,视频上的按钮在哪里,我想在视频上添加自定义暂停按钮。
    • 在您将添加 MPMoviePlayerController 的视图上添加按钮
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-13
    • 1970-01-01
    • 1970-01-01
    • 2021-07-07
    • 2014-08-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多