ian
ian

Reputation: 1002

Can't play video from url of downloaded content

Im downloading my video from AWS successfully with the following completion block:

if (task.result) {
                                                               AWSS3TransferManagerDownloadOutput *downloadOutput = task.result;
                                                               //File downloaded successfully.
                                                               NSLog(@"download succesful!");
                                                               NSLog(@"download outptut = %@", downloadOutput);
                                                               NSString *body = [downloadOutput valueForKey:@"body"];
                                                               NSLog(@"body = %@", body);

                                                               //play video
                                                               NSString *urlStr =[NSString stringWithFormat:@"%@", body];

                                                               NSURL *url=[[NSURL alloc] initWithString:urlStr];

                                                               MPMoviePlayerController *moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:url];

                                                               moviePlayer.controlStyle=MPMovieControlStyleDefault;
                                                               moviePlayer.shouldAutoplay=YES;
                                                               [self.view addSubview:moviePlayer.view];
                                                               [moviePlayer setFullscreen:YES animated:YES];

                                                           }

Heres what I am logging:

2016-01-08 17:40:28.763 Scene[4045:1637254] download succesful!
2016-01-08 17:40:28.766 Scene[4045:1637254] download outptut = <AWSS3TransferManagerDownloadOutput: 0x159f3fd70> {
    ETag = "\"b2e89e481befcecbdadbba782eaf192d\"";
    acceptRanges = bytes;
    body = "file:///private/var/mobile/Containers/Data/Application/A0806A72-C980-4419-A7B8-4DD8253070E5/tmp/downloads";
    contentLength = 3797949;
    contentType = "video/quicktime";
    lastModified = "2016-01-07 20:26:05 +0000";
    replicationStatus = 0;
    requestCharged = 0;
    serverSideEncryption = 0;
    storageClass = 0;
}
2016-01-08 17:40:28.767 Scene[4045:1637254] body = file:///private/var/mobile/Containers/Data/Application/A0806A72-C980-4419-A7B8-4DD8253070E5/tmp/downloads

So the download is successful and that object is a video. However when i try to play the video, the video player just pops without any content as well as not being dismissible.

Why is this? I usually work with Parse so I'm inexperienced with AWS.

Upvotes: 0

Views: 329

Answers (1)

Bogdan Balta
Bogdan Balta

Reputation: 121

You information is not sufficient to get the cause.

First of all, are you setting downloadingFileURL to your local download path? That is the exact same path that should be handed to the video player.

Secondly, URL for local file is not loaded properly. This is how NSURL should be created for local files:

NSURL *url = [NSURL fileURLWithPath:urlStr];

Thirdly, I am not sure about that path format. "file:///" is a format which failed to get my files in some cases. I'm not sure about this, but if the first two suggestions don't work you could try to have only "file://" set in the path.

Hope this helps.

Upvotes: 1

Related Questions