如何在ios中播放视频?(目标c)

时间:2015-09-11 04:21:41

标签: objective-c iphone xcode

当我的应用程序在ios中启动时,我需要一些关于如何实现视频启动的帮助。 样本类似于: http://www.iosappx.com/code/9173/

1 个答案:

答案 0 :(得分:0)

你可能有一个“虚假”的发布视频。因此,如果您有本地视频文件(mp4或其他支持的格式),您可以将窗口rootViewController设置为AVPlayerViewController。示例如下:

在AppDelegate.m文件中

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

AVPlayer *player = [AVPlayer playerWithURL:"YOUR URL"];
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(continueWithLaunch) name: AVPlayerItemDidPlayToEndTimeNotification object:player];
// create a player view controller
AVPlayerViewController *controller = [[AVPlayerViewController alloc] init];
self.window.rootViewController = controller;
controller.player = player;
[player play];
}  

-(void) continueWithLaunch {
  //Change the window rootView controller to your base controller (e.g. tabbar controller)
}