반응형

    AVPlayerItem *playItem = [AVPlayerItem playerItemWithURL:url];
   
    self.currentPlayer = [AVPlayer playerWithPlayerItem:playItem];
    [self.playerView setPlayer:self.currentPlayer];
    [self.playerView setVideoFillMode:AVLayerVideoGravityResizeAspectFill];
   
   
   
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
    [UIView animateWithDuration:0.3 animations:^{
        [self.view setFrame:CGRectMake(0.0f, 0.0f, 480.0f, 320.0f)];
        [self.view setCenter:CGPointMake(160.0f, 240.0f)];
        [self.view setTransform:CGAffineTransformMakeRotation(M_PI/2)];
        [self.view bringSubviewToFront:self.playerView];
    }];
   
    [self.playerView.player play];
   
}

- (void) setPlayStop {
    [self.playerView setVideoFillMode:AVLayerVideoGravityResizeAspect];
    [self.playerView.player pause];
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
    [self.view setNeedsDisplay];
    [self.view setFrame:CGRectMake(0.0f, 0.0f, 480.0f, 320.0f)];
    [self.view setCenter:CGPointMake(160.0f, 240.0f)];
    [self.view setTransform:CGAffineTransformMakeRotation(0)];
}


반응형
Posted by onlyTheOne
,