我正在使用Xcode 4.6.1(目标是iPad)为iOS 6开发
我想在用户滑动屏幕时更改视频网址。
这是我的ViewController.m
文件:
#import "ViewController.h"
@interface experiencesViewController () {
MPMoviePlayerViewController *playerViewController;
MPMoviePlayerController *player;
}
@end
...
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSString *url = [[NSBundle mainBundle] pathForResource:"video" ofType:@"mp4"];
playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
player = [playerViewController moviePlayer];
[player setMovieSourceType:MPMovieSourceTypeFile];
player.fullscreen = YES;
[player play];
...
}
...
现在,我想在滑动事件中更改视频。我试过这样做:
- (IBAction)didSwipeLeft:(UITapGestureRecognizer *)recognizer {
NSLog(@"Left");
player.movieSourceType = MPMovieSourceTypeFile;
player.contentURL = [NSURL URLWithString:@"video2.mp4"];
[player prepareToPlay];
[player play];
}
然而,这不起作用。视频停止播放,之后没有任何反应。任何帮助都将受到高度赞赏。
谢谢:)
答案 0 :(得分:0)
删除[播放器播放]因为视频尚未准备好播放。