Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVPlayer with local video file

Tags:

ios

nsurl

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?

like image 641
Eugene Trapeznikov Avatar asked Dec 04 '22 11:12

Eugene Trapeznikov


1 Answers

Try using fileURLWithPath: method instead of URLWithString:

like image 101
Raj Avatar answered Dec 29 '22 13:12

Raj