其簡單:我的視頻播放器出現,但從來沒有播放任何東西。我試圖播放的文件已存在(選中)。 我剛剛開始一個新的「單一視圖」項目。iOS AVPlayer不開始玩
#import "ViewController.h"
#import <MediaPlayer/MediaPlayer.h>
@interface ViewController()
@property (nonatomic, strong) MPMoviePlayerController *player;
@end
@implementation ViewController
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *filepath = [NSString stringWithFormat:@"%@/Videos/fileSequence0.ts", documentsDirectory];
NSLog(@"!! %i", [[NSFileManager defaultManager] fileExistsAtPath:filepath]);
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
_player = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[_player.view setFrame: CGRectMake(0, 0, 500, 500)];
[self.view addSubview:_player.view];
[_player play];
}
@end
。 –
是.ts能夠與ios一起玩 – iEinstein
@WillJenkins您不必合成,除非您想重命名合成屬性。 –