Video not playing on iOS in WebGL

I’m having issues playing videos on WebGL using iOS Safari.

This is the error it is getting.

NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
play@[native code]
_JS_Video_Play

I have an interactive button that starts playback, a workaround I put when autoplay was causing issues on Chrome. Not sure why it is throwing this issue. I am preparing the video while the button is displayed, could that be causing the issue? It’s not an issue on other browsers.

I have several videos in the streaming assets folder that I’m calling with videoPlayer.url = Path.Combine(Application.streamingAssetsPath, URL[index]); This works on PC/Mac web browsers and Android Chrome. It also works on iOS Chrome. Safari on iOS seems to be the only issue.

I read some forum posts saying to use UnityWebRequest but I couldn’t find examples that lined up with what I wanted and the “Path.Combine(Application.streamingAssetsPath” seems to be working without it. Unsure what to do to troubleshoot. I’ve looked in the forums but haven’t found a solution.

Similarly, Firefox on Android will play the audio of the videos but won’t display the video.

So I found this thread that lists some workarounds with mixed results.

Looking up the ticket it says the issue was fixed in 2020.3.X, though I am on 2020.3.15f2 and still am encountering this issue.

The issue tracker says that the fix landed in 2020.3.16

Hello everyone, I hope that this is the right place to ask.
I have the same problem of black screen on iOS devices, meanwhile on android and pc it just works.

I am using unity 2021.3.2f

This is the test site: https://www.interactivelab.it/Work/WebTest/index.html

I setup a simple scene with a button and a video player that load a video hosted on Digital Ocean. The video works well everywhere but it doesn’t load on iOS, i see only a black screen.

I read through the internet that can also be a CORS problem (which i setup on DO). Do you have any idea of what is wrong?
Here the CORS settings.
Thank you in advance.

is not fixed at all
Still not work on ios

1 Like

2021.3.16f1
Still not work on ios

Hi,
I work on playing videos in unity with unity video player using video urls link. Urls must be with the video type (ex. https/xyz.mp4) it worked fine on Crome, Mac, IOS, firefox etc. the issue that I have 12 IPADS, iPhones, and android devices on which I test the webGL build with same link which I upload on firbase local host and its working on (3 IPADS and 4 iPhones) but at the same time its not working on only (1 iPhone and 1 IPAD). I face the request is not allowed by the user agent in the current context or the permission denied error. I use unity video player
build link is https://host557.web.app/

1 Like

still on 2023 we are unable to play video on Iphone or Ipads? :frowning:

Did you play my webGL build host557.web.app on your any IPAD or iPhone device?

Yes, and works on my device.
But I have the same problem as you, on some device it works and with some others don’t
But I cannot give an app with this kind of behaviour to a client…

Your solution anyway works on my device and mine not…
Can I ask you what did?
.
Did you something about the CORS problem?

Can I ask you what Unity version did you used to create your demo?

I found a very simple solutions. It seems that there is a problem with some validations and permissions with iOS, and the problem is when a video is played in the awake() or in the start(). My fix was just adding a button with a script that reproduce the video, and that was it!

I hope this works for you too!