简体   繁体   中英

AVPlayer and AWS Services Streaming

I'm attempting to stream videos from AWS S3 bucket. I uploaded several fils with the "make for everyone" permissions.

I have also created a CloudFront distribution (I just chose my bucket and let all others choices by default). In a web browser I can download file / read with the adress http://distribution.cloudfront.net/movie1.mov

In my project I have initiated an AVPlayer which takes path from a tableview (like an itune but for movie). The file for each row is the same as tested in my web browser: http://distribution.cloudfront.net/movie1.mov for row1 distribution.cloudfront.net/movie2.mov for row2 ...

The player takes well the path and start playing but it freeze always at the same time. I have to pause or advance/back to continue the video.

SO it seems to be a buffer problem.

I would like to know if I use well AWS Cloud Front and how I can resolve the buffer problem.

I didn't find any good tutorials or answers about this.

Thank you for your help.

Regards

did you set the Geographic restrictions on cloudfront so that it uses the servers in the area closest to you?

I meant between web and RMTP in my first comment. You want web so that is correct.

Now that it is restricted to France, test your videos again and see if their performance is better.

You will want to allow other regions as your usage expands. Remember different regions have DIFFERENT PRICES for cloudfront. EU and USA are the same but the other regions can be twice as expensive or more .

http://aws.amazon.com/cloudfront/pricing/

AVPlayer can stall while streaming long videos.

You will need to register observers for the keys playbackBufferEmpty and playbackLikelyToKeepUp

[playerItem addObserver:self forKeyPath:@"playbackBufferEmpty" options:NSKeyValueObservingOptionNew context:nil];
[playerItem addObserver:self forKeyPath:@"playbackLikelyToKeepUp" options:NSKeyValueObservingOptionNew context:nil];

Then on,

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
                        change:(NSDictionary *)change context:(void *)context {
    if (!player)  {
        return;
    }

    else if (object == playerItem && [keyPath isEqualToString:@"playbackBufferEmpty"])  {
        if (playerItem.playbackBufferEmpty) {
            //Other relevant code here, like adding spinner
        }
    }

    else if (object == playerItem && [keyPath isEqualToString:@"playbackLikelyToKeepUp"])  {
        if (playerItem.playbackLikelyToKeepUp)  {
            [player play];
            //Other relevant code here, like removing spinner
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM