How to play unsecure video in AVPlayer in iOS 13?

Viewed 479

I wanted to play video with URL in AVPlayerViewController. When I am using secure links (https) then video played successfully but when I am using http URLs then it just keep buffering.

enter image description here

Can anyone help me out here??

1 Answers

If something works with secure URLs and not non secure URLs in iOS then you are very likely haivng issues with App Transport Security (ATS).

It blocks non secure traffic. If you really must use a non secure connection, you have to configure ATS to allow the connections.

NSAllowsArbitraryLoadsForMedia setting this value to true in your plist should allow you to load non secure content to play videos.

To do this, open up your info.plist file for your project.

  • If an entry for App Transport Security Settings does not exist. Add it.

  • Expand App Transport Security Settings

  • Add NSAllowsArbitraryLoadsForMedia with a value of YES/true

Re-run your app and try that.

Related