What I am trying to do here is connect to an IP Camera and display the stream/feed using the AVPlayView.
If I play a local video everything is working fine:
let path = NSBundle.mainBundle().pathForResource("video-bg", ofType: "mp4")
let url = NSURL.fileURLWithPath(path!)
playerItem = AVPlayerItem(URL: url)
player = AVPlayer(playerItem: playerItem!)
//Display Stream on AVPlayerView
self.avPlayerView.player = player
But when I am trying to connect to a camera using the following code it does not work:
let url = NSURL.fileURLWithPath("http://96.10.1.168/")
playerItem = AVPlayerItem(URL: url)
player = AVPlayer(playerItem: playerItem!)
//Display the stream
self.avPlayerView.player = player
- This is a public IP Camera found from Google and it works on my browser.
info.plist is edited to allow connection:
<key>NSAllowsArbitraryLoads</key> <true/> <key>NSExceptionDomains</key> <dict> <key>http://96.10.1.168/</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSTemporaryExceptionMinimumTLSVersion</key> <string>TLSv1.1</string> </dict> </dict>
It seems that I am approaching this wrong, so can somebody point me to the right direction and tell what is the correct approach?