How can I add videos without file extensions?

Hi everyone,

I’m trying to add a video that the url does not have the extension on it, so the browser can’t open it as a normal video and starts to downloading it. My question is, how can I make it work on Phaser? I’m always getting the warning “Video not loaded” with a local video or other .mp4 videos from the web I can see my configs working correctly. Any idea?

:wave:

I think it’s

this.load.video('intro', { url: 'video/level1', type: 'mp4' });

The types are in game.device.video.

But without a file extension the server may not send the correct media type.

Hi @samme thanks for your reply.
I tried this:

this.scene.load.video('intro', { url: videoProperties.videoUrl, type: 'mp4' })

But I’m getting this:

Argument of type '{ url: string; type: string; }' is not assignable to parameter of type 'string | string[] | undefined'.
  Object literal may only specify known properties, and 'url' does not exist in type 'string[]'.ts(2345)

It should work anyway, so ignore the TypeScript error.

Hey @samme thanks for trying to solve my problem, really appreciate this!

Even though ignoring the Typescript error, still does not works. I’m using Phaser 3.55.2.

What happens?

The same :frowning:

I’m trying to do something that looks promising on my end, creating the video element and adding it like
this.video.video = $videoEl;

I just need to figure out if there’s anyway to add the whole element directly and I think that this can solve my problem for now. At least the video is loading (I can hear it), but unfortunately I can see it because I need to access the hooks that comes after the video loads.

But looks like that I’m getting close :crossed_fingers:

Hello @samme just to close this topic, I’ve figured out in another way. I’ve created a small api that just get my link as a parameter and change the content-type to video/mp4.

And then it works just fine, thanks for your help.

This works well.
this.add
.video(this.scale.width / 2, this.scale.height / 2)
.loadHandler(url, true, “anonymous”)
.setDepth(9)
.play(true);