Giter Club home page Giter Club logo

avplayer's Introduction

AVPlayer

视频播放,实现全屏播放及小屏播放

    类似效果
    ![](https://github.com/ClaudeLi/AVPlayer/blob/master/20141121215131793.png)

    ![](https://github.com/ClaudeLi/AVPlayer/blob/master/20141121215205505.png)

    1.旋转至全屏
    - (void)setLandscapeController:(TTPlayerOrientation)toOrientation{
        CGFloat angle = -M_PI_2;
        if (toOrientation == TTPlayerOrientationHomeRight) {
            angle = -M_PI_2;
        }else if (toOrientation == TTPlayerOrientationHomeLeft){
            angle = M_PI_2;
        }else{
            return;
        }
        _isFullScreen = YES;
        landscapeViewController.orientation = toOrientation;
        [_parentView.viewController presentViewController:landscapeViewController animated:NO completion:^{
        [self.view removeFromSuperview];
        [self removeFromParentViewController];

        [landscapeViewController addChildViewController:self];
        [landscapeViewController.view addSubview:self.view];

        [[UIApplication sharedApplication] setStatusBarHidden:YES];
        [self.playerView setLandscapeLayout];

        //旋转前
        CGAffineTransform transform = CGAffineTransformMakeRotation(angle);
        transform = CGAffineTransformScale(transform, 1.0, 1.0);
        self.view.transform = transform;
        self.view.center = landscapeViewController.view.center;
        //旋转动画
        [UIView animateWithDuration:[[UIApplication sharedApplication] statusBarOrientationAnimationDuration] animations:^{
        self.view.transform = CGAffineTransformIdentity;
        self.view.frame = landscapeViewController.view.bounds;
        }completion:^(BOOL finished) {
        //            [[UIApplication sharedApplication] setStatusBarHidden:NO];
        }];
        }];
    }
    
    2.旋转至竖屏
    - (void)setPortraitController:(TTPlayerOrientation)fromOrientation{
        CGFloat angle = M_PI_2;
        if (fromOrientation == TTPlayerOrientationHomeLeft) {
            angle = -M_PI_2;
        }else if (fromOrientation == TTPlayerOrientationHomeRight){
            angle = M_PI_2;
        }else{
            return;
        }
        [landscapeViewController dismissViewControllerAnimated:NO completion:^{
        [self.view removeFromSuperview];
        [self removeFromParentViewController];

        [_parentView.viewController addChildViewController:self];
        [_parentView addSubview:self.view];

        [[UIApplication sharedApplication] setStatusBarHidden:NO];
        [self.playerView setPortraitLayout];
        //缩放动画
        CGAffineTransform transform = CGAffineTransformMakeScale(1.0, 1.0);
        self.view.transform = transform;
        self.view.frame = _frame;
        self.view.transform = CGAffineTransformRotate(transform, angle);

        [UIView animateWithDuration:[[UIApplication sharedApplication] statusBarOrientationAnimationDuration]
        animations:^{
        self.view.transform = CGAffineTransformIdentity;
        }
        completion:^(BOOL finished) {
        self.view.frame = _frame;
        }];
        }];
    }

avplayer's People

Contributors

claudeli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

avplayer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.