Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only Downloading the Contents #6

Closed
SanjayRathor opened this issue Sep 26, 2018 · 3 comments
Closed

Only Downloading the Contents #6

SanjayRathor opened this issue Sep 26, 2018 · 3 comments

Comments

@SanjayRathor
Copy link

Hi ,

Now able to download the contents instead of Playing . I am doing like this..

NSURL *url = [NSURL URLWithString:@"https://videos.bodybuilding.com/video/mp4/62000/62792m.mp4"];
DVURLAsset *asset = [[DVURLAsset alloc] initWithURL:url options:nil];
asset.loaderDelegate = self;

@vdugnist
Copy link
Owner

Hi. If you want to download video file you can do it with NSURLRequest. After saving data to file you can play video from local URL. Example:

NSURL *url = [NSURL URLWithString:@"https://videos.bodybuilding.com/video/mp4/62000/62792m.mp4"];
NSURL *localURL = ...;
[[[NSURLSession sharedSession] dataTaskWithRequest:[NSURLRequest requestWithURL:url] completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
    if (data) {
        [data writeToURL:localURL atomically:YES];
    }
}] resume];

After downloading you can play it with:

AVPlayer *player = [AVPlayer playerWithURL:localURL];

Am I understand your question right?

@SanjayRathor
Copy link
Author

SanjayRathor commented Sep 26, 2018 via email

@vdugnist
Copy link
Owner

replied in this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants