MPMoviePlayerController Add custom Play button

前端 未结 2 776
长情又很酷
长情又很酷 2021-02-03 11:14

Currently i am working on a iPhone Application Which is displaying video. I have used MPMoviePlayController to load the Video from the local folder.

Can we customize th

相关标签:
2条回答
  • 2021-02-03 12:00

    if you want to have any controlStyle of apple and still want to add some custom buttons on movie view. You can subclass MPMoviePlayerViewController.

    Let say you have MyCustomMoviePlayerViewController as subclass of MPMoviePlayerViewController then in MyCustomMoviePlayerViewController.m

    - (void)viewDidAppear:(BOOL)animated {
         [super viewDidAppear:animated];
         UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [button addTarget:self 
                   action:@selector(aMethod:)
        forControlEvents:UIControlEventTouchUpInside];
        [button setTitle:@"MyCustomButton" forState:UIControlStateNormal];
        button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
        [self.view addSubview :button];
        }
    
    0 讨论(0)
  • 2021-02-03 12:06

    You can surely add custom controls for MPMoviePlayerController. For that first hide existing controls using, MPMovieControlStyle, set this to MPMovieControlStyleNone

    Now add your custom control buttons and handle all the MoviePlayer events over there, like;

    • Play
    • Pause
    • Stop
    • Prev
    • Next, etc.
    • Or you can add your own controls like jump to this time (+10 sec, +20 sec), movie speed control (1x, 2x, ..), etc.

    Hope this will be useful for you.

    0 讨论(0)
提交回复
热议问题