Reputation: 500
I have written an async call to download a video of mp4 format. The response result is an NSData. How can I open the NSData in any video player framework which should be supported in IOS 3.
Upvotes: 2
Views: 8745
Reputation: 478
It's not possible to directly play the NSData into AVPlayer. What you can do is download the Data into Document folder and later fetch the file path and give that path to AVPlayer.
Upvotes: 1
Reputation: 5707
An NSData is basically a container object, and thus not in a format you can play in a video player. Without seeing any code, or the results of your data, you can create an NSString from data with
NSString *dataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
Now that you have a string, you can create an NSURL with
NSURL *movieURL = [NSURL URLWithString:dataString];
From there, you should be able to pass this into an MPMoviePlayerController with
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
Upvotes: 2