0

我正在使用 iphone 中的视频应用程序。当用户点击一个按钮时,它将导致第二个视图,并从那里我正在播放来自 url 的视频。

但是,当用户从该视图返回并再次转到视频未播放时。

它连续显示以下2行

     [MPAVController] Autoplay: Likely to keep up or full buffer: 0
     [MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.

这是我的代码

  - (void)viewDidLoad
  {
[super viewDidLoad];


 self.moviePlayerController = [[MPMoviePlayerController alloc] init];
[self.moviePlayerController prepareToPlay];
self.moviePlayerController.shouldAutoplay = YES;
[[self.moviePlayerController view] setFrame:CGRectMake(-30, 72, 360,140)];


[[self view] addSubview: [self.moviePlayerController view]];


  NSString *strng = [NSString stringWithFormat:@"http://quickemee_videos.s3.amazonaws.com/videoStream_1352395870143_616.mp4"];

NSLog(@"strng %@",strng);
NSURL * adurl = [NSURL URLWithString:strng];

 [self playVideo:adurl];

 }

. . . .

 -(IBAction)back:(id)sender{


 [moviePlayerController stop];
[self.navigationController popViewControllerAnimated:YES];

   }  
4

3 回答 3

2

使用此代码

    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"video_name" ofType:@"m4v"]];

    moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];

    [moviePlayer prepareToPlay];
    moviePlayer.view.frame = self.view.bounds;
    [self.view addSubview:moviePlayer.view];
    [moviePlayer play];
    [moviePlayer setFullscreen:FALSE];
// if you want no control.
    [moviePlayer setControlStyle:MPMovieControlStyleNone];        
于 2013-01-30T15:09:33.550 回答
1

先打电话试试[self prepareToPlay]

苹果 说:

如果调用 play 方法时电影播放器​​尚未准备好播放,则该方法会自动调用此方法。但是,为了尽量减少播放延迟,请在调用 play 之前调用此方法。

更新:

确保文件可用。我无法在浏览器中访问它。

于 2013-01-30T13:11:46.430 回答
1

viewDidLoad只调用一次。因此,当您弹出 viewController 然后返回它时,viewDidLoad不会再次调用它。所以尝试self.moviePlayerController = [[MPMoviePlayerController alloc] init];实施- (void)viewWillAppear:(BOOL)animated

于 2013-01-30T13:16:12.010 回答