I had a video that was playing on my site which was just set as this:
<video #video [muted]="true" playsinline autoplay loop id="video">
<source [src]="section.backgroundVideo" type="video/mp4">
</video>
The CSS made it a background video, like this:
#video {
display: block;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
min-width: 100%;
min-height: 100%;
}
I am using the Angular Cloudinary library and have been struggling to get this to work the same. My HTML looks like this:
<cl-video public-id="Situ-Sizzler-Web-Clip-v05-01_auvu5o" fetch-format="auto" effect="volume:mute"
flags="streaming_attachment" autoplay id="video" #video>
</cl-video>
Sometimes it does play, but most of the time it just loads the poster image and never plays the video. If I remove the CSS and change the html to this:
<cl-video public-id="Situ-Sizzler-Web-Clip-v05-01_auvu5o" fetch-format="auto" effect="volume:mute"
flags="streaming_attachment" autoplay controls id="video" #video>
</cl-video>
I can press the play button and it will play. Is there something I am doing wrong?
Also, I would love it if it would resize based on the resolution. Does anyone know how that can be done? With images, you can just add responsive
but I can't find anything for video.
I thought I found a solution to this. I tried manually adding the generated URL to a video element and noticed that it had similar issues. After a bit of playing I found this:
Tell whether video is loaded or not in Javascript
which then lead me to this:
Checking if a html5 video is ready
But finally I found that a video will not allow autoplay unless it's muted. I had originally used the attributes autoplay muted
but as you can see I haven't done that in my cl-video (just autoplay).
So I changed my cl-video to this:
<cl-video public-id="Situ-Sizzler-Web-Clip-v05-01_auvu5o" fetch-format="auto" autoplay="true" muted="muted"
id="video" #video>
</cl-video>
Now it works more often, but still sometimes it doesn't autoplay.....