你好,歡迎來到IOS教程網

 Ios教程網 >> IOS訊息 >> 關於IOS >> ios視頻播放

ios視頻播放

編輯:關於IOS

導入MediaPlayer.framework,引入頭文件#import

- (void)createMPPlayerController:(NSString *)sFileNamePath {

NSURL *url = [NSURL URLWithString:sFileNamePath];
MPMoviePlayerViewController *playViewController=[[MPMoviePlayerViewController alloc] initWithContentURL:url];
MPMoviePlayerController *player=[playViewController moviePlayer];
player.scalingMode=MPMovieScalingModeFill;
player.controlStyle=MPMovieControlStyleFullscreen;
[player play];
[self.navigationController presentViewController:playViewController animated:YES completion:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:player]; //播放完後的通知

}

-(void)movieFinishedCallback:(NSNotification*)notify {

MPMoviePlayerController* theMovie = [notify object];

[[NSNotificationCenter defaultCenter] removeObserver:self

name:MPMoviePlayerPlaybackDidFinishNotification

object:theMovie];

[theMovie.view removeFromSuperview];
}

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved