Eugene Trapeznikov
Eugene Trapeznikov

Reputation: 3240

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?

Upvotes: 4

Views: 7981

Answers (1)

Raj
Raj

Reputation: 1091

Try using fileURLWithPath: method instead of URLWithString:

Upvotes: 16

Related Questions