AVPlayerViewcontroller播放视频网址问题

时间:2016-06-30 13:14:56

标签: ios iphone avplayer avplayerviewcontroller

我的代码:

这是我们的代码

    NSURL *videoURL = [NSURL URLWithString:strVideo];

    playerController = [[AVPlayerViewController alloc]init];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(playerItemDidReachEnd:)
                                                 name:AVPlayerItemDidPlayToEndTimeNotification
                                               object:[playerController.player currentItem]];

        playerController.view.frame = self.view.frame;

        playerController.player = [AVPlayer playerWithURL:videoURL];

        [self presentViewController:playerController animated:YES completion:nil];



        [playerController.player play];

}

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

       // [playerController dismissViewControllerAnimated:YES completion:nil];
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];

    NSLog(@"IT REACHED THE END");

}

视频首先播放2秒,然后从头到尾重播。

0 个答案:

没有答案