1

我正在使用 Xcode 4.6.1 为 iOS 6 开发(目标是 iPad)

当用户滑动屏幕时,我正在尝试更改视频 URL。

这是我的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];
}

但是,这不起作用。视频停止播放,之后没有任何反应。任何帮助将不胜感激。

谢谢 :)

4

1 回答 1

0

删除 [播放器播放] 因为视频尚未准备好播放。

于 2013-06-17T06:56:26.183 回答