I am using uihtml in matlab to play a video,I could embed a video in the uifigure,but it plays when I press the play button.
Is there a way to autoplay a video in uihtml in matlab?
my current HTML script looks like this :
<!DOCTYPE html>
<html>
<body style="background-color:black;font-family:arial;">
<video width="583" height="325" controls autoplay>
<source src="./movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
</body>
</html>
Found a solution for this, 'muted' should be added with autoplay to enable autoplay in uihtml in matlab
<!DOCTYPE html>
<html>
<body style="background-color:black;font-family:arial;">
<video width="583" height="325" autoplay muted loop>
<source src="./movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
</body>
</html>
Related
I want to make an mp4 video player in my HTML website.
I use this code in the body:
<html>
<head>
<title>Document></title>
<body>
<video width="400" controls>
<source src="video.mp4" type="video/mp4">
</video>
</body>
</html>
When I save it and refresh my website in the browser, there is an mp4 box but the video is not playing.
you need to pass the value muted if you are using it in chrome as mentioned here
In some browsers (e.g. Chrome 70.0) autoplay doesn't work if no muted attribute is present.
<video width="400" autoplay controls muted>
It seems you are new to html because you don't do indentation correctly and you did not close the <head> :
The right way to do it is :
<html>
<head>
<title>Document</title>
</head>
<body>
<video width="400" controls>
<source src="video.mp4" type="video/mp4" />
</video>
</body>
<html>
I think you should review your fundamentals before continuing.
My aim is to autoplay a song on a website in Chrome and Safari, but it is not working. I found a trick to use an iframe with a silence.mp3 before playing the audio tag, but it also did not work.
My code:
<iframe src="silence.mp3" allow="autoplay" id="audio" style="display: none" type="audio/mp3"></iframe>
<div style="position: fixed; left: 0px;top: 0px;">
<audio id="vid" controls loop="loop" autoplay="autoplay" type="audio/mp3">
<source src="song.mp3">
Your browser does not support the audio element.
</audio>
</div>
Is there anything I can do about that?
You cant - User interaction is needed to allow play/autoplay media with sound.
Add muted attribute
<audio id="vid" controls loop="loop" autoplay="autoplay" type="audio/mp3" muted>
...
</audio>
Audio will start to play only without the sound. Then allow user to switch sound on with JS.
EDIT
It seems that this is no longer working with audio tag
Tested with video
<video controls muted autoplay>
<source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-13.mp3"/>
</video>
<!DOCTYPE html>
<html>
<body>
<audio autoplay="autoplay">
<source src="sound.ogg" type="audio/ogg">
<source src="sound.mp3" type="audio/mpeg">
<source src="sound.wav" type="audio/wav">
Your browser does not support the audio element.
</audio>
</body>
</html>
ıt seems that work at W3school but i couldn't make it in my browser. I tried it chrome and firefox but it doesn't work. What's the wrong? I'm new about codding
You're supposed to put
<audio controls autoplay>
instead of
<audio autoplay="autoplay">
On the homepage of our website, we have a video that autoplays which you can click to enter the main site.
However when some people visit the website it does not load due to poor connection, and that page is left blank so they cannot access the site. Is there a way to detect if connection is slow and show an alternate text or webpage?
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<style>
html{
width:100%;
height:100%;
}
body {
background: black;
position:fixed;
width: 100%;
height: 100%;}
</style>
<audio autoplay>
<source src="http://files.cargocollective.com/598079/vape-sound_mixdown.mp3" type="audio/mpeg">
</audio>
<body bgcolor="black">
<video playsinline id="video1" width="100%" autoplay onended="run()" poster=“650mAh”>
<source src="img/lores/vape_text_openingSMALLER.mp4" type="video/mp4">
<source src="img/lores/vape_text_openingSMALLER.ogv" type="video/ogg">
<source src="/img/lores/vape_text_openingSMALLER.webm" type="video/webm">
650mAh
<object data="movie.mp4" width="100%">
<embed width="100%" src="movie.swf">
</object>
</video>
<a href="/650mah.html">
<video playsinline id="video2" width="100%" poster="http://650mah.com/img/650loop.gif" loop>
<source src="img/lores/vape_text_loopSMALL.mp4" type="video/mp4">
<source src="img/lores/vape_text_openingSMALL.ogv" type="video/ogg">
<source src="img/lores/vape_text_loopSMALL.webm" type="video/webm">
<object data="loop.mp4" width="100%" >
<embed width="100%" src="loop.swf">
</object>
</video>
</a>
<script>
$( "#video2" ).hide();
function run(){
$( "#video1" ).hide();
$( "#video2" ).show();
document.getElementById("video2").play();
};
</script>
I haven't tried it myself, but it's possible with JavaScript to determine the internet speed. Take a look at the link below.
How to detect internet speed in JavaScript?
If the internet connection is too slow, you could redirect to a different page using JavaScript/jQuery
One other approach is that you can have a single web page and display an image or text as an alternative until the video has loaded.
The HTML5 'canplaythrough' event is fired when the browser has the video donbwloaded and play it all:
https://developer.mozilla.org/en-US/docs/Web/Events/canplaythrough
When this fires you can replace the image or text with the video.
Here is the code what i'm using
<!DOCTYPE html>
<html>
<body>
<video width="400" controls>
<source src="mov_bbb.mp4" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML5 video.
</video>
<p>
Video courtesy of
Big Buck Bunny.
</p>
</body>
</html>
i'm using Mozilla browser and its version is 4.3