ios,  objc

NSURL URLWithString vs fileURLWithPath

A frequent mistake when playing a local video using [AVAudioPlayer initWithContentsOfURL:url] is to use URLWithString instead of fileURLWithPath.

URLWithString creates a url as is! i.e. it does not add a scheme.

fileURLWithPath creates a url with a file (file://) scheme.

A frequent mistake when playing a local video using [AVAudioPlayer initWithContentsOfURL:url] is to use URLWithString instead of fileURLWithPath to create the url. The player will report no error but the video will not play.

NSURL URLWithString vs fileURLWithPath

Subscribe to The infinite monkey theorem

Get the latest posts delivered right to your inbox