2

I have a AVPlayer that plays video from remote url.

Here is my code:

AVPlayerItem* playerItem = [AVPlayerItem playerItemWithURL:videoUrl];
self.player = [AVPlayer playerWithPlayerItem:playerItem];
self.player.actionAtItemEnd = AVPlayerActionAtItemEndNone;

AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];
playerLayer.frame = playerView.bounds;
[playerView.layer addSublayer:playerLayer];

[self.player play];

When I start to stream I have only less then a second video chunck and then downloading stops and nothing happens.

MPMoviePlayerController and browser plays this video as usual.

I also doubt, that it might be effect of cropping video (because videos without cropping works fine). Here is the guide I use to crod video http://www.one-dreamer.com/cropping-video-square-like-vine-instagram-xcode/

Also clean app with same setup can't play video.

Any ideas? thanks!

Anton
  • 113
  • 7

1 Answers1

1

Use the AVPlayerItemPlaybackStalledNotification

 [[NSNotificationCenter defaultCenter] addObserverForName:AVPlayerItemPlaybackStalledNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
        [weakself performBlockOnMainQueueAfterDelay:1.5 block:^{
            [weakself.player play];
        }];
    }];
Nicolas Manzini
  • 8,379
  • 6
  • 63
  • 81