3

In our ios app users can upload and play videos.

  1. We are using AWS S3 bucket for store the videos.
  2. AWS Cloudfront is the CDN.

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

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

but the problem is when we click one video its taking long time to play. only we can see is loading.after start to play the video playing smoothly. issue with the initial loading.

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 original cloud front url. If the video is available in the cache we load it from the cache with source type MPMovieSourceTypeFile. Or else we stream from the url with source type MPMovieSourceTypeStreaming. also we are using HTTP live Streaming (HLS).

these videos are caching and there is no issue with playing cached video.

4

0 回答 0