Initial video stream is slow (MPMoviePlayerViewController) in ios app

In our ios app, users can download and play videos.

  • We are using AWS S3 bucket to store videos.
  • AWS Cloudfront is a CDN.

all videos will be available through the CDN URL. Example: https://dnxrwXXXXXX.cloudfront.net/1417696382ABC.mp4 .

as we checked, there is no problem with CDN and internet connection. when we play this video in HTML player in browser, no problem.

but the problem is when we click on one video it takes a long time to play. only we see that it is loading. After starting video playback, the game is smooth. boot problem.

here is the code

MPMovieSourceType sourceType;
    NSURL *currentURL = [[VideoDiskCache getSharedInstance] searchCash:urll];
    if (!currentURL) {
        currentURL = urll;
        sourceType = MPMovieSourceTypeStreaming;
    } else {
        sourceType = MPMovieSourceTypeFile;
    }
    moviePlayerController = [[MPMoviePlayerViewController alloc]
                initWithContentURL:currentURL];
    moviePlayerController.view.superview.backgroundColor = [UIColor blackColor];
    moviePlayerController.view.superview.superview.backgroundColor = [UIColor blackColor];
    moviePlayerController.view.superview.superview.backgroundColor = [UIColor blackColor];
    moviePlayerController.view.backgroundColor = [UIColor blackColor];
    moviePlayerController.moviePlayer.movieSourceType = sourceType;
    [AppDelegate getAppDelegate].navigationController.view.backgroundColor = [UIColor blackColor];
    [[AppDelegate getAppDelegate].navigationController presentMoviePlayerViewControllerAnimated:moviePlayerController];

      

Here url means the original cloud front. If the video is available in the cache, we load it from the cache with the source type MPMovieSourceTypeFile. Or else we will pass from a URL with the original MPMovieSourceTypeStreaming. we also use HTTP streaming live streaming (HLS).

these videos are cached and there is no problem with playing the cached video.

+3


source to share





All Articles