• 播放视频


        //初始化url
        NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"abc" ofType:@"mp4"]];
       
        //初始化播放视频
        moviePlayer =[[MPMoviePlayerController alloc]initWithContentURL:url];
        [self.view addSubview:moviePlayer.view];
        moviePlayer.view.frame =CGRectMake(0, 0, self.view.frame.size.width, self.view.bounds.size.height*8/16);
        //控制模式
        moviePlayer.controlStyle=MPMovieControlStyleNone;
        //开始播放
        [moviePlayer play];
       
        UIButton *btn =[UIButton buttonWithType:UIButtonTypeCustom];
        [btn setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];

        [btn setTitle:@"" forState:UIControlStateNormal];
        btn.frame =CGRectMake(0, 0, self.view.frame.size.width, self.view.bounds.size.height*8/16);
        [btn addTarget:self action:@selector(btnAct:) forControlEvents:(UIControlEventTouchUpInside)];
        btn.tag = 110;
       
    //    moviePlayer.view.layer.transform=CATransform3DMakeRotation(M_PI, .5, 0, 1);
       
        [moviePlayer.view addSubview:btn];


       
       
    }

    - (void)btnAct:(UIButton *)btn{

        if (btn.selected) {
            [self play];
        }else{
            [self paush];
        }


       
    }

    - (void)play{
       
        UIButton *button = (UIButton*)[moviePlayer.view viewWithTag:110];
        button.selected = !button.selected;
        [moviePlayer play];
    }
    - (void)paush{
        UIButton *button = (UIButton*)[moviePlayer.view viewWithTag:110];
        button.selected = !button.selected;
        [moviePlayer pause];
       
    }
     
    button点击事件可以实现随意点击,实现播放,暂停功能
  • 相关阅读:
    LeetCode算法第一题
    基础题整理
    MongoDB 之 Limit 选取 Skip 跳过 Sort 排序 MongoDB
    MongoDB 之 $关键字 及 $修改器 $set $inc $push $pull $pop MongoDB
    mongodb的数据类型
    mongodb的增删改查
    session与cookie之间的关系
    Python 格式化输出的3种方式
    判断python字典中key是否存在的两种方法
    python实现忽略大小写对字符串列表排序的方法
  • 原文地址:https://www.cnblogs.com/yxt9322yxt/p/4764346.html
Copyright © 2020-2023  润新知