我想在以下链接上播放视频:www.mysite.com/iphone/video.mp4
我使用ios5和MPMoviePlayerController,尝试使用以下代码,但仅显示黑页:
MPMoviePlayerController *player=[[MPMoviePlayerController alloc]initWithContentURL:[NSURL URLWithString:@"http://www.mysite.com/iphone/video.mp4"]]; [[player view] setFrame:[self.view.bounds]]; [self.view addSubview:[player view]]; [player play];
是否可以通过网址字符串播放视频?我有很多视频,所以我不想将它们放到我的项目中,所以我需要从网络上播放它
@Edit:我使用apple's developer site上的示例完成了此操作
它使用流,但解决了我的问题,因为我使用了网址。感谢您的所有答案
最佳答案
试试这个
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"3idiots.mov" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:moviePlayer.view];
moviePlayer.view.frame = CGRectMake(0, 0, 300, 400);
[moviePlayer play];
关于ios - iOS 5-如何使用网址播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10635866/