0

Im having trouble playing urls that are saved in my documents folder. I first download the videos from the server and save the path to the videos to my app documents folder. When I pull up the paths from the devices,AVplayer is just blank. Here is my code:

VideoPlayer *vidPlayer = (VideoPlayer *)[self.view viewWithTag:500];




NSString* path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *filepath = [path stringByAppendingPathComponent:@"Data.dat"];
NSMutableArray *listOfVideos = [NSKeyedUnarchiver unarchiveObjectWithFile:filepath];




NSURL *fileURL = listOfVideos[0][@"video"];
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:fileURL options:nil];
AVPlayerItem *firstItem = [[AVPlayerItem alloc] initWithAsset:asset];


_queuePlayer =[[AVQueuePlayer alloc]initWithPlayerItem:firstItem];
AVPlayerLayer *layer = (AVPlayerLayer *)vidPlayer.layer;
layer.player = _queuePlayer;
[_queuePlayer play];
abdi
  • 1
  • 2
  • Have you verified the value of `fileURL`? Have you verified that it actually points to a valid asset? – rmaddy Aug 07 '16 at 03:25
  • yes when I nslog it...it shows file:///Users/abdimusse/Library/Developer/CoreSimulator/Devices/4535C95E-85B3-4406-9E09-5E31AC64B440/data/Containers/Data/Application/EC41CF39-FF93-481C-9D50-4F44B9E7172D/Documents/634016.mp4 – abdi Aug 07 '16 at 03:42
  • Have you tried to export that `mp4` file and check if quicktime player is able to play it? – Marco Santarossa Aug 10 '16 at 17:49

0 Answers0