kaplay icon indicating copy to clipboard operation
kaplay copied to clipboard

feat: video support

Open niceEli opened this issue 1 year ago • 3 comments

idk if useful but would be good if you could have a node that plays a video

k.loadSprite("testVid", "./mp3s/testVid.mov")
k.add([
  k.sprite("testVid")
]);

and also the controls like with audio component would be in video component (like pause, play, loop, detune, start position)

niceEli avatar Jun 19 '24 02:06 niceEli

i think this is awesome, and should be added

amyspark-ng avatar Jun 19 '24 02:06 amyspark-ng

I think playing a video on a texture would be most powerful? Since you can still use shaders and vertex deformation?

mflerackers avatar Jun 19 '24 02:06 mflerackers

I think playing a video on a texture would be most powerful? Since you can still use shaders and vertex deformation?

Yes, would be nice

SpcFORK avatar Jun 25 '24 10:06 SpcFORK

I see this is a feature now mentioned here... https://v4000.kaplayjs.com/guides/video/

but.. I can not get it to work...

  1. Do I need to load a sprite like "k.loadSprite("box", "sprites/box.png");"
  2. what url am I putting?

I have tried different variations but I get the following error....

"Uncaught TypeError: Cannot read properties of undefined (reading 'width') at Object.video (kaplay.js?v=636aa5ed:3539:101) at main.js:30:5"

at first I thought it was because I was trying a .wmv file but .mp4 gives the same error... I am just using the code as listed in the guide link above... any help would be appreciated... sorry if this is the wrong place for this kind of ?

totomtornado avatar Apr 15 '25 09:04 totomtornado

Is your video file on the same server as your script?

mflerackers avatar Apr 15 '25 10:04 mflerackers

yes... same server... local server...

in the kaplay.js... it hits here: line 3539 function Ii(t, e) { let r = document.createElement("video"), n = false, o = false, s = false, a = new xe(u.gfx.ggl, e.width, e.height);

but the element is obviously empty...

totomtornado avatar Apr 15 '25 10:04 totomtornado

No, the element is r. What is undefined is e, the opt, you probably use video(url) instead of video(url, { width:320, height: 200 });

mflerackers avatar Apr 15 '25 10:04 mflerackers

No, the element is r. What is undefined is e, the opt, you probably use video(url) instead of video(url, { width:320, height: 200 });

specifying width and height worked... am I looking at the wrong documentation? I looked at the link above... might have just not been updated but if there is a better source for documentation then please let me know... thanks for the reply!!!

totomtornado avatar Apr 15 '25 10:04 totomtornado

I would definitely be interested in exposing settings/attributes like loop, autoplay, muted, etc... because it is a bit difficult to start the video on page load unless you set some of these features.

totomtornado avatar Apr 15 '25 10:04 totomtornado

Docs are not updated. I will setup a documentation for master, because we don't continuous releae

lajbel avatar Apr 15 '25 10:04 lajbel