Hello!
I have trouble to make my Ionic app play mp4 video in latest version of iOS 9.0.2 inside .
The video plays fine using Chrome/Safari, but once deployed to iOS, it can not play it and I can not see any errors. I can see only a Play icon. I have checked the config.xml and I have the following whilst access:
I have tested the following code :
<ion-content>
<video width="100%" controls="controls" preload="metadata" autoplay loop webkit-playsinline="webkit-playsinline" class="videoPlayer">
<source ng-src="http://video-js.zencoder.com/oceans-clip.mp4" type="video/mp4"/>
</video>
</ion-content>
I have not tested if this should work in older iOS, so I am not sure if this depends on new policy from Apple or something else.
I have tried to use “src” instead of “ng-src”, but same problem.
gru1966
October 19, 2015, 12:15am
2
I got the following error when I tested on older iOS:
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection
I resolved it after days thru adding the following in [ProjectName]-info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
And finally could get it work on my latest iOS mobile.
I had the following:
in config.xml but this was not enough to get it work and we need to add NSAppTransportSecurity entry in the config.xml.
gru1966:
NSAppTransportSecurity
In iOS9 only https requests are allowed by default. If you can get the video with https-host everything is fine.
In other cases you need to change you info.plist file in your ios build.
info.plist
<!--
This disables app transport security and allows non-HTTPS requests.
Note: it is not recommended to use non-HTTPS requests for sensitive data. A better
approach is to fix the non-secure resources. However, this patch will work in a pinch.
To apply the fix in your Ionic/Cordova app, edit the file located here:
platforms/ios/MyApp/MyApp-Info.plist
And add this XML right before the end of the file inside of the last </dict> entry:
This file has been truncated. show original