An error occured trying to load the resource

Hi,

I use a lot of videos within my game and my deployment targets are android and iOS. With android, I have barely problems using videos, but apple besides, is a mess like always.
It took a long time for me to figure out the actual problem: “An error occured trying to load the resource” (when loading pack.json, I gues actually I load the video here, but as it is referenced in the pack.json…) says the network tab of the web inspector within safari. But: Phaser does not throw specific errors.

For the format I already tried .mp4 and .webm, the result is the same: A black screen. However, when I specify a video directly like this

	<video autoplay  muted playsinline>
	<source src="my/path/to/video.mp4" type="video/mp4">
	Your browser does not support HTML5 video.
</video>

then it works for iOS < 11, for iOS >=11 it still shows a black screen.
Do you guys know of any solution to make it working for iOS >= 8?
I tried setting asBlob within the Phaser Editor, but it didn’t work.

Somehow it seems like iOS is expecting another encoding or something like that? Help me out of the Apple hell :smiley:

Hi @Davaaron,

What version of Phaser Editor are you using? Can you please attach the pack.json file here?

Other work around is, remove the videos from the pack file and to load them using the this.load.video() method in the preload() method.

Version 2.6.2.

I tried loading the video, but the video object is null. Printing out the loading progress within the update method shows, that the video is not loaded -> the progress is constantly 0.

1 Like

I mean, what version of the Phaser Editor.

Try with this.load.video() to see if it is a problem with Phaser or Phaser Editor.

Version 1.5.1.
I already did it. The video object is null.

Two new knowledges:
First: When setting asBlob within the Phaser Editor, the Phaser API still holds asBlob=false when you reach the point where the video is loaded. This way, my video was never loaded as blob.
Second: Although I specified playsinline, autoplay and muted, the user agent still doesn’t have permission to play the video. How do I know? I changed the asBlob property of the file to true just before it was loading. “Unhandled Promise Rejection: NotAllowedError”.

The second point may be the main reason why the video is not even loaded when loading it as a tag? That’s why I cannot find the video in the cache…

However, when I put the video directly into the index.html with html5, then it works (well, at least the videos loads).
I think Phaser messes something up internally. And Apple just wants to be the hatred. And of course me :slight_smile:

Edit2: XMLHttpRequest cannot load ‘file://…’. Cross origin requests are only supported for HTTP. That’s the error now when trying to load the pack.json. When loading an asset directly, it works (because it’s not loaded via XHR).

Hi @Davaaron,

Sorry, I just see your answer now! I have to check my notification settings.

First: When setting asBlob within the Phaser Editor, the Phaser API still holds asBlob=false when you …

It is a Phaser bug, look this code in the Loader.


                case 'video':
                    this.video(file.key, file.urls);
                    break;

When it process the video data, it ignores file.asBlob. I think you can fix it and create a PR. The code should be:


case 'video':
    this.video(file.key, file.urls, file.asBlob);
    break;

Edit2: XMLHttpRequest cannot load ‘file://…’. Cross origin requests are only supported for HTTP…

Are you serving the assets in an HTTP server? If not, you should do it, or lot of things could be broken. By the way, there is a game.load.crossOrigin property that you can set true.

Hey,

no problem. I already found that specific part and changed it locally. That was exactly the place where the asBlob property was ignored. I didn’t do a PR anyways because Phaser 2 isn’t continued to be developed.

No, iOS give me errors as they only allow HTTP requests when using its new WebView (WkWebView).

I didn’t do a PR anyways because Phaser 2 isn’t continued to be developed.

Well, there is Phaser CE and it is released from time to time.

No, iOS give me errors as they only allow HTTP requests when using its new WebView (WkWebView).

Well, good luck with iOS.

Well, good luck with iOS.

Yea, gonna need that.