zoukankan      html  css  js  c++  java
  • iOS 视频启动界面

    一个简单的 “视频启动界面” 的实现,参考他人的实现,核心抽出来,简化了一下。

    AnimationVideoViewController 实现

     

    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view from its nib.
        
        self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:self.videoURL];
        self.moviePlayer.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
        self.moviePlayer.shouldAutoplay = YES;
        self.moviePlayer.controlStyle = MPMovieControlStyleNone;
        self.moviePlayer.repeatMode = MPMovieRepeatModeNone;
        self.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
        
        [self.view addSubview:self.moviePlayer.view];
      
        
        //监听播放完成
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(playFinsihed) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
        
        UIView *backView = [[UIView alloc] initWithFrame:
                            CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        
        backView.backgroundColor = [UIColor clearColor];
        [self.moviePlayer.view addSubview:backView];
        
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickClip:)];
        [backView addGestureRecognizer:tap];
        
        [self configShimmerLabel];
    }
    

     

      

     

    AnimationVideoViewController 调用

     - (void)viewWillAppear:(BOOL)animated
     {
          [super viewWillAppear:animated];
          [self configureVideoStrat];
      }
      
      - (void)configureVideoStrat {
          
          NSString *firstlaunch = @"firstlaunch";
         
         __weak typeof(self)weakSelf = self;
         NSInteger firstIN = [[[NSUserDefaults standardUserDefaults] valueForKey:firstlaunch] integerValue];
         if (firstIN != 0) {
             //return;
         }
         
         self.animationVC = [[AnimationVideoViewController alloc] init];
         self.animationVC.videoURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"intro"ofType:@"mp4"]];
         self.animationVC.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
         
         self.animationVC.finishBlock = ^{
             [UIView animateWithDuration:1.0 animations:^{
                 weakSelf.animationVC.view.alpha = 0;
             } completion:^(BOOL finished) {
                 [weakSelf.animationVC.view removeFromSuperview];
                 weakSelf.animationVC = nil;
             }];
             
         };
         [[[UIApplication sharedApplication] keyWindow] addSubview:self.animationVC.view];
         [[[UIApplication sharedApplication] keyWindow] bringSubviewToFront:self.animationVC.view];
         
         [[NSUserDefaults standardUserDefaults] setValue:@(1) forKey:firstlaunch];
         [[NSUserDefaults standardUserDefaults] synchronize];
     }
    

      

    github 地址:LCSVideotartPageExample

  • 相关阅读:
    做题记录
    关于有向图强连通分量的一点想法
    浅谈二分图匹配(未完)
    水题狂欢赛 (爬楼梯赛)题解(偏向自我反省)
    浅谈迭代加深(iddfs)
    浅谈单调队列优化
    [cqbzoj#10644]鱼肉炸弹题解
    树形背包[2/ 50] luogu [P1273]
    树形背包[1/ 50] luogu [P2015] (超级板)
    (树状数组)区间修改,区间查询
  • 原文地址:https://www.cnblogs.com/saytome/p/6963909.html
Copyright © 2011-2022 走看看