2013-07-23 82 views
0

我使用此代碼與自動佈局視圖控制器,並在另一個視圖中播放視頻稱爲videoView,但它不是全屏播放視頻。視頻觀看不是全屏在橫向模式iPhone

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *path = [documentsDirectory stringByAppendingPathComponent:saveFileName]; 
    NSURL *url1 = [[NSURL alloc] initFileURLWithPath: path]; 
    videoPlayer = [AVPlayer playerWithURL:url1] ; 
    self.avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:videoPlayer]; 


    avPlayerLayer.frame = self.videoView.bounds; 
    [self.videoView.layer addSublayer: avPlayerLayer]; 
    [videoView setHidden:NO]; 

    [self.videoPlayer play]; 

回答

0
Use MPMPMoviePlayerViewController, 

    MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:url1]; 
     NSError *_error = nil; 
     [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &_error]; 
     [self presentMoviePlayerViewControllerAnimated:mpvc]; 
+0

感謝reply.But我必須使用AVplayer – iTag

相關問題