I have been trying to play a video with MPMoviePlayerViewController
and it works fine. But before I play it, I want to check if the video I want to play really exists, so I'm using NSFileManager.defaultManager().fileExistsAtPath
, with the path to the file in the iPhone camera roll
My problem comes when checking if it exists. If I check it with this piece of code :
// videoImageUri = "/Users/AppName/Library/Developer/CoreSimulator/Devices/3DAC8D46-3E32-4143-A552-2DB325CB5965/data/Media/DCIM/100APPLE/IMG_0006.mov"
NSFileManager.defaultManager().fileExistsAtPath(NSURL(fileURLWithPath : videoImageUri).path!)
It returns true when used in Xcode
simulator, but if used with the iPhone, it returns false, even when the file exists. I know it exists because the MPMoviePlayerViewController
plays it right.
The path I use when using iPhone is
/var/mobile/Media/DCIM/100APPLE/IMG_0150.MP4
Maybe, is there any permission restriction about reading camera roll?
Applications are only allowed to access their own directory. Access to other parts is denied, so naturally all queries for files will say they don't exist.
The internal components like media playing have access to other directories also, otherwise you wouldn't be able to play items from the camera roll at all inside applications.
Seems the simulator doesn't enforce the permissions at all.