Quantcast
Viewing all articles
Browse latest Browse all 204402

AVPlayer pre-loading and pausing

I want to pre-load the video in an AVPlayer, pause it on frame 1, then fade from the image to the player before starting the video.

I'm doing this in the ViewDidLoad method.

When I pause the AVPlayer

moviePlayer1.Play (); 
moviePlayer1.Pause();

and then fade out the loading image overlay

UIView.Animate (.5, 0, UIViewAnimationOptions.CurveEaseIn,
  () => {
           LoadingImageView.Alpha=0;},
  () => {
           LoadingImageView.Image = null;LoadingImageView.Hidden = true; CurrentMoviePlayer = moviePlayer1; 
    }
);

the movieplayer is paused, but just displaying the player layer's background color.

I've tried a few hacky tricks to try to get it working, such as introducing a loop after the play() and then pausing:

moviePlayer1.Play();
NSRunLoop.Current.RunUntil(DateTime.Now.AddMilliseconds(3000));

But it appears as though the video doesn't really start to play until after the method completes.

I'd really like to be able to just preload the video and have it waiting on-screen at frame 1. I've tried waiting for the moviePlayer1.Status and/or the moviePlayer1.CurrentItem.Status to be ReadyToPlay, but it stays stuck at UNKNOWN no matter how long I wait.

Is there a way to force the AVPlayer to pause on a frame?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>