简体   繁体   中英

AVPlayer with local video file

There is a little video part in my application.

So i find this sample, which play mp4 video from url: http://www.sdkboy.com/?p=66

You can download sample here: http://www.sdkboy.com/tutorials/AVFoundation_Test3.zip

But when I replace NSURL code

NSURL *url = [NSURL URLWithString:@"http://www.samkeeneinteractivedesign.com/videos/littleVid3.mp4"];

With this one, for playing local video, player doesn't work.

NSURL *url = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"malina36" ofType:@"mp4"]];

This file exist, i check it with

if ([[NSFileManager defaultManager] fileExistsAtPath:url.absoluteString]) {
        NSLog(@"yes");
    } else {
        NSLog(@"no");
    }

Can you help me?

尝试使用fileURLWithPath:方法而不是URLWithString:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM