Hi,
what I'm trying to do:
using a vset to activate a material switch
the material displays a html page
when i switch, i want a sound to be played that is integrated in the html file
the autoplay feature works in the browser
but not yet in vred
I hope you can help me with this issue
Solved! Go to Solution.
Solved by seiferp. Go to Solution.
How did you get your audio autoplay working with the latest chrome browser? Google has changed their policies in April 2018 and blocked autoplay! You may have to build a function that allows you to trigger the play/pause html controls after the page was loaded via python in a 2nd step to simulate a user interaction.
Thanks for the quick reply.
I've tried my .html file with the edge chromium browser. I didn't think there would be a difference that affects me.
I'll try to find another solution.
Is there a python command which finds out if a geometry is hidden or not. Or alternatively, which Geometry in a switch is currently selected.
Thanks a lot, I can work with this solution.
Anyway:
I found a way to use Autoplay in VRED
Instead of using
<audio src="..." autoplay> </audio>
You can use
Hi Pascal,
I downloaded and tested your sample file from this Forum. It works for audio. I was unable to convert the index.html to a video format.
Do you have a sample running a video with sound not just sound? Video format MP4 or WMV or WEBM?
Thank you,
Shawn
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8">
<meta name="author" content="Pascal Seifert">
<title>Media Player - Movie</title>
<link rel="stylesheet" type="text/css" href="main.css"/>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<button onclick="playAudio()" type="button">Play Audio</button>
<button onclick="pauseAudio()" type="button">Pause Audio</button><br>
<audio id="myAudio" src="assets/6-Sorfjorden_Chapel-Wild_Bullet.wav" type="audio/wav"></audio>
<script>
var audio = document.getElementById("myAudio");
function playAudio() {
var i = audio.play();
}
document.addEventListener("VRED_Play", playAudio);
function pauseAudio() {
audio.pause();
}
document.addEventListener("VRED_Pause", pauseAudio);
</script>
</body>
</html>
Attached an example. The changed chrome policies are a bit annoying I agree 🙄 The attached example requires at least a one-time user input into the page. Single click on the canvas before the VSet script can start and pause the video.
Hi Pascal, Thank you for the Video demo file. The ZIP you posted is missing the index.html file. VRED is looking here for it: file:///C:/Users/seiferp/Desktop/index.html. It was not in the zip. Let me know if you can add the index file to the zip?
Thank you, Shawn
Awesome! Thank you Pascal! It's working and I was able to change the video and start image. Wish it would auto play or have a Python script to activate it without clicking on the video but this is a step in the right direction.
Thank you, Shawn
Hey Pascal, I was able to get the Video to autoplay when loaded. Chrome blocks autoplay if sound is on. Found this info and code to do it. Just cant get the sound turned back on after it autoplays...
The issue with this is Chrome would not play the video because it hasn’t been muted. The sound would start to play and Chrome doesn’t want that. So the solution is pretty simple, you have to mute the video and then, only then, will Chrome play it normally when the page loads. To mute the video add a “muted” attribute like so:
<video controls autoplay loop muted>
<source src=”movie.mp4″ type=”video/mp4″>
</video>
In my case autoplay worked if i dont use
<audio src=„Audiodatei.wav" type="audio/wav" autoplay></audio>
but use
<iframe src=„Audiodatei.wav" allow="autoplay" style="display:none"></iframe>
Can't find what you're looking for? Ask the community or share your knowledge.