Playing a Downloaded Video from the Documents Directory with Cocoa-Touch

后端 未结 2 466
长情又很酷
长情又很酷 2021-01-05 20:25

I\'m trying to get my app to play a video file that\'s been downloaded to the documents directory. I know the file is getting downloaded, but I can\'t seem to get the file t

相关标签:
2条回答
  • 2021-01-05 21:03

    Issue will be with this line: NSString *path = [documentsDirectory stringByAppendingPathComponent:@"%@/piggy.m4v"];

    Change that to NSString *path = [documentsDirectory stringByAppendingPathComponent:@"piggy.m4v"];

    0 讨论(0)
  • 2021-01-05 21:04

    This looks like some kind of bug, but you have to set your path like that:

     NSString *vidPath = [[NSBundle mainBundle] pathForResource:@"promo" ofType:@"mp4"];
     NSURL *url = [NSURL fileURLWithPath:vidPath isDirectory:NO]; //THIS IS THE KEY TO GET THIS RUN :) 
     [introPlayer setContentURL:url];
    
    0 讨论(0)
提交回复
热议问题