Replies: 10 comments 6 replies
-
@amcc You can check this example https://codesandbox.io/p/sandbox/white-smoke-wx5zht?file=%2Fsrc%2FApp.js%3A30%2C49 that shows how you can play/pause or mute/unmute a video |
Beta Was this translation helpful? Give feedback.
-
thanks for the help. I'm not sure i need the complexity within the HSL texture you have there. However now i look at that example it does seem that useVideoTexture has a reference to the source video, so i might be able to control it that way. I have also been trying this via the more default threejs video texture, however iOS is giving me a few issues. |
Beta Was this translation helpful? Give feedback.
-
@amcc You don't need the HLS stuff I just had that already in that sandbox, it should work the same with the default |
Beta Was this translation helpful? Give feedback.
-
looks like texture.image doesn't exist on useVideoTexture, however the video source is there: This contains the html video element, so i can set muted to false on that. It looks like your example isn't actually using drei useVideoTexture, it uses THREE.VideoTexture which must use the (i agree unfortunate) So far this seems to work on ios |
Beta Was this translation helpful? Give feedback.
-
Here's what i've done - i'll need to do some more testing on mobile devices that are very fussy about how video is used (with sound) Using this hook: https://github.com/pmndrs/drei?tab=readme-ov-file#usevideotexture i've changed the VideoMaterial in the above example to take a state 'muted' in order to enable the sound when i detect an anchor (using the callback from MindAR 'onAnchorFound' to trigger the statechange:
still having issues with ios - works on my phone, but not on another iphone at the moment |
Beta Was this translation helpful? Give feedback.
-
@amcc I have updated my example to work with useVideoTexture from drei directly, and it still works https://codesandbox.io/p/sandbox/white-smoke-wx5zht?file=%2Fsrc%2FApp.js%3A26%2C5 |
Beta Was this translation helpful? Give feedback.
-
Solved the issue - my problem was that i was trying to change properties on the video element (texture.image) within the videoMaterial component: originally i was passing in a state 'muted'
I realised that this is essentially re-rendering this component each time muted state changes, making a new video element, which probably causes safari to need a new click - its not going to be synchronous so we get the error in safari. The solution is to handle the mute/unmute within the parent component. I think we could do this a few ways, I chose to pass down a state setter to the VideoMaterial like so:
In the App component i'm doing this:
|
Beta Was this translation helpful? Give feedback.
-
That’s a much better idea and sounds like the correct thing to do! Does
seem to work as it is however.
Also worth mentioning is that desktop safari causes a lot of the same
issues.
Eg try running a Mac laptop on battery and setting the low power mode to
always on battery, you find it has the same behaviour as iOS on low power
mode and causes a similar react error (this can be dismissed however and is
only in development). You see this error on your example in this situation
too
…On Sat, 17 Feb 2024 at 22:44, Michael Dobekidis ***@***.***> wrote:
@amcc <https://github.com/amcc> Why not just use a ref? Mutating ref
properties doesn't cause re-render
—
Reply to this email directly, view it on GitHub
<#1832 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA4EX5PGDTV3RAONQUVF5TYUEXENAVCNFSM6AAAAABDMGWBAGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DKMBTG4ZTS>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
@netgfx Thanks for all the help - got it working, in case the solution is useful i put it all in a repo here: See the app.js for how I did it: |
Beta Was this translation helpful? Give feedback.
-
@netgfx true - i will be moving components to their own files, i wanted to keep this super simple as a test case for now. useMemo is a good call, i'll do that. I have another issue with this, which you might be able to help with - the built site has the lights working fine - but they're broken in the dev version only - you seen this behaviour before? I'm including drei in order to use the useVideoMaterial hook, but react-three-fibre and drei are already dependencies of react-three-mind (which is doing the AR stuff) - so i think i've 2 different versions included overall. I'm getting warnings in develop about multiple versions of three and i think there's possibly some issue with the newer version of drei in the App.js I elaborated more on the exact warnings here if you're interested: tommasoturchi/react-three-mind#21 |
Beta Was this translation helpful? Give feedback.
-
I have video successfully working with useVideoTexture as per https://github.com/pmndrs/drei?tab=readme-ov-file#usevideotexture. Its being used in conjunction with MindAR using this library: https://github.com/tommasoturchi/react-three-mind
I want to be able to unmute the video and perhaps start/stop the video. On mobile you must start the video muted or safari in ios displays black video (or errors locally). The AR provides callbacks for the target mounted/unmounted so this would be suitable for me to try to unmute the video. I can't see any way to do this with useVideoTexture. Other option is to use a more standard three.js video texture - but would like to use this
Beta Was this translation helpful? Give feedback.
All reactions