网址不支持在iphone应用程序中播放视频

时间:2013-08-06 06:16:50

标签: ios iphone video

我必须在我的Iphone应用程序中播放视频,但我无法找到以下链接是什么类型以及如何播放它? This video。在许多方面进行了测试,但仍未找到最佳实践。

1 个答案:

答案 0 :(得分:0)

试试吧

在.h文件中声明的MPMoviePlayerController

-(void)playVideo:(id)sender
 {


     NSURL *movieURL = [NSURL URLWithString:[[newsFeedsMA objectAtIndex:0] valueForKey:@"url"]];
     _player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

     [self.view addSubview:_player.view];

     [_player prepareToPlay];
     _player.controlStyle = MPMovieControlStyleDefault;
     _player.shouldAutoplay = YES;
     [_player setFullscreen:YES animated:YES];

 }

 //Notification method:



    - (void) moviePlayBackDidFinish:(NSNotification*)notification
     {

         MPMoviePlayerController *player = [notification object];

         [[NSNotificationCenter defaultCenter] removeObserver:self
                                                         name:MPMoviePlayerPlaybackDidFinishNotification object:player];

         if ([player respondsToSelector:@selector(setFullscreen:animated:)])
         {
             [player.view removeFromSuperview];
         }
     }