我是 Xcode 的新手,所以我一直在尝试遵循教程,但没有遇到任何解释我想要实现的目标的东西。我只想在您打开应用程序时自动播放视频。我在播放音频时有点工作,但我看不到任何视频。我错过了什么吗?我在输出窗口中收到此警告:
警告:尝试在 ViewController: 0x9d10540 上显示 MPMoviePlayerViewController: 0x831d7a0,其视图不在窗口层次结构中!
在我的ViewController.h
:
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface ViewController : UIViewController
@end
ViewController.m
:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url =[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Placeholder" ofType:@"mp4"]];
MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:playercontroller];
playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[playercontroller.moviePlayer play];
playercontroller = nil;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end