What could be causing the video autoplay feature to not function properly when used in conjunction with a bootstrap carousel

My video is not auto-playing. The same code works when placed in a different file, but it's not working on my page. Can anyone help with this issue?

The URL where the video is not autoplaying:

I have tried everything I can think of to get it working, but still no luck. If my explanation is unclear, please let me know and I'll provide more details.

Thank you in advance for any assistance.

.video
        {
            width: 100%;
            height: 512px;
            object-fit: cover;
        }
        #carousel .carousel-item {
          height: 100vh;
          width: 100%;
          min-height: 350px;
          background: no-repeat center center scroll;
          background-size: cover;
        }
        
        #carousel .carousel-inner .carousel-item {
          transition: -webkit-transform 2s ease;
          transition: transform 2s ease;
          transition: transform 2s ease, -webkit-transform 2s ease;
        }
        
        #carousel .carousel-item .caption {
          background-color: rgba(0, 0, 0, 0.5);
          padding: 40px;
          color: white;
          animation-duration: 1s;
          animation-delay: 2s;
        }
        
        #carousel .caption h2 {
          animation-duration: 1s;
          animation-delay: 2s;
        }
        
        #carousel .caption p {
          animation-duration: 1s;
          animation-delay: 2.2s;
        }
        
        #carousel .caption a {
          animation-duration: 1s;
          animation-delay: 2.4s;
        }
        
        /* Button */
        .delicious-btn {
            display: inline-block;
            color: #ffffff;
            border: none;
            border-left: 3px solid #1c8314;
            border-radius: 0;
            padding: 0 30px;
            font-size: 16px;
            line-height: 35px;
            font-weight: 600;
            -webkit-transition-duration: 500ms;
            transition-duration: 500ms;
            text-transform: capitalize;
            background-color: #40ba37;
            margin-top: 15px;
        }
        
        .delicious-btn.active, .delicious-btn:hover, .delicious-btn:focus {
          font-size: 16px;
          font-weight: 600;
          color: #ffffff;
          background-color: #1c8314;
          border-color: #40ba37;
        }
        
        .slider-content-main
        {
            background: white;
            padding: 25px;
        }
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
    <section class="">
        <div id="carouselExampleIndicators" class="carousel slide hero-slides" data-ride="carousel">
          <ol class="carousel-indicators">
            <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
            <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
            <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
          </ol>
          <div class="carousel-inner" role="listbox" style="border: 1px solid #dedede;">
              <video autoplay loop class="video" id="vid">
                     <source src="https://pcbmagic.com/small5.mp4" width="1024" type="video/mp4" >
                     Your browser does not support the video tag.
              </video>
            <div class="carousel-item active">
              <div class="container d-none d-md-block">
                <div class="row align-items-center ml-4" style="height: 512px;">
                  <div class="col-12 col-md-9 col-lg-7 col-xl-6 slider-content-main">
                    <div class="caption animated fadeIn">
                      <h2 class="animated fadeInLeft">Boat Excursions</h2>
                      <p class="animated fadeInRight">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras tristique nisl vitae luctus sollicitudin. Fusce consectetur sem eget dui tristique, ac posuere arcu varius.</p>
                      <a class="animated fadeInUp btn delicious-btn" href="#">Learn more</a>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            
            <div class="carousel-item ">
              <div class="container d-none d-md-block">
                <div class="row align-items-center ml-4" style="height: 512px;">
                  <div class="col-12 col-md-9 col-lg-7 col-xl-6 slider-content-main">
                    <div class="caption animated fadeIn">
                      <h2 class="animated fadeInLeft">Explore the river valley</h2>
                      <p class="animated fadeInRight">Lorem ipsum dolor sit amet,</p>
                      <a class="animated fadeInUp btn delicious-btn" href="#">Learn more</a>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <!--<div class="carousel-item">
              <img class="d-block w-100" src="https://pcbwayfile.s3-us-west-2.amazonaws.com/banner/21/03/25/1808173691783t.jpg" alt="Third slide">
              
            </div>-->
          </div>
        </div>
        
     </section>
</body>
</html>

Answer №1

Ensure to include the 'muted' attribute in your video tag :-).

<video autoplay loop ➡️ muted ⬅️ class="video">

This is necessary because Google prohibits videos from autoplaying with audio. For more information, you can review Chrome's policy using the link below.

Autoplay will only be allowed once the user interacts with the video, such as clicking or tapping on it.

https://developer.chrome.com/blog/autoplay/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

jQuery show/hide functionality allows you to toggle the visibility of elements

I am looking to create a toggle button that expands the menu-wrapper width and hides the sidebar when clicked. Here is the initial CSS styling: #my-wrapper { Width:500px; } #sidebar-wrapper { width:200px; } Upon clicking the button, the CSS will update ...

Dragging a hyperlink onto the web browser using jQuery's drag functionality

Seeking a solution for my small script that allows users to drag a link and also drop it onto the browser bar for bookmarking or sharing. How can I achieve this functionality? Check out an example of one of the drag functions I currently utilize: http:/ ...

My HTML files are not getting bundled by Webpack

Despite including dependencies for HTML loaders in my Angular 2 application, webpack is not bundling my HTML files along with the rest of the files it generates. I have tried using both "html-loader" and "html-webpack-plugin," but to no avail. My webpack ...

Notify the user with a Jqgrid alert when they attempt to select multiple checkboxes

When editing rows, I wanted to avoid multiple selections. In order to achieve this, I need to check the condition if(count>1) and display an alert message. I am struggling to figure out how to retrieve the count of selected checkboxes in jqGrid. var m ...

Tips for locating a file using javascript

My application scans a folder and displays all folders and HTML files inside it in a dropdown menu. It also shows any HTML files inside an iframe. There is one file named "highlighted.html" that should not appear in the dropdown menu, but if it exists in t ...

What is the process for setting the <script src> to include a javascript file located outside the root folder specified in express.static()?

After setting app.use(express.static('public')), and with the folder structure shown below including my starting express from the parent folder of package.json: ├── package.json ├── public │   ├── favicon.ico │   ├─ ...

What is the method for absolutely positioning an element with separate targets for the `left` and `right` properties?

Seeking a complex CSS result that may seem impossible. Consider the following scenario: <div class="div1"> <div class="div2"> <div class="div3"> <div class="div4"></div> ...

Tips for displaying a background image without obstructing the container class on your website

How can I set a background image for my website? Whenever I use the code background-image:url('path_to_image');, it ends up covering my container class. Is there a way to place the image behind the container class? ...

Closing Browser Tabs with Javascript or jQuery

I've included a div with survey questions that is hidden by default. When the user tries to close the window or navigate away from the page, I want to display the survey div for confirmation instead of using the browser's default confirm box meth ...

Exploring the world of web scraping using R's XML package with the powerful xpathS

I need help extracting the names of shopping malls from a specific website. The URL is provided here: After examining the html code, I noticed that the mall names are stored under the "h5" tag. I tried to extract the text using the following codes, but it ...

What is the best way to smoothly switch from one Font Awesome icon to another?

I am working on an HTML button with the following code: <button id="sidebar-toggle-button" class="btn btn-primary header-btn" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasExample&q ...

Turn off scrolling but allow dragging on iPhone

Is it possible to disable scrolling but still allow dragging on the <canvas> element in iPhone? Currently, when you drag the <canvas>, the entire page also scrolls, which is not the desired behavior. <meta name="viewport" content="wid ...

Leveraging image values for selecting an image from a collection and showcasing it (Javascript)

I have a collection of images that I want to enlarge upon clicking. Here is what I currently have: <div class="gallery"> <div> <img src="content/imggallery/img1.jpg" class="oldimg" value="0"> </div> ...

Creating unique ID tags using AngularJS

I am struggling with creating an HTML structure that looks like this: <ul> <li id="r1_1">Root node 1 <ul> <li id="child_node_1">Child node 1</li> <li id="child_node_2">Child node 2</ ...

Ensuring Contact Form Accuracy with Jquery Validation

I am trying to implement form validation using jQuery. Here is the code I am using: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2 /jquery.min.js"></script> <script type="text/javascript" src=" http:// ...

Toggling a div overlay through various user interactions such as clicking, pressing a button, or hitting the escape

I've created a simple div overlay that appears when a user clicks inside an input box: HTML <html> <body> <input id="search" type="text" placeholder="Search..."> </body> </html> CSS #overlay { position: fixed; ...

Combining two arrays in JavaScript and saving the result as an XLS file

I have a question that I couldn't find an answer to. I need to merge two arrays and export them to an Excel file using only JavaScript/jQuery. Let's say we have two arrays: Array 1 : ["Item 1", "Item 2"] Array 2 : ["Item 3", "Item 4"] When the ...

the method of utilizing JavaScript to showcase an HTML form

I have created a form for entering an employee's skills. Below the form, there is a link to add a new skill. When this link is clicked, the form should be displayed again. My code looks like this: <html> <head> ...

The sub menu in IE 8 does not stay open while hovering over it

My website has a navigation menu with a sub-menu that appears when hovering over the parent element. While this works smoothly on modern browsers, Internet Explorer 8 presents an issue. When hovering over the parent li element in IE 8, the sub-menu is disp ...

What is the way to restrict the length of input in a v-select component?

I am currently using the Vue-select feature in my project and I have encountered an issue with setting a maximum input length of 45 characters within a v-select element. Despite attempting to handle this limitation on the back-end, I am unable to prevent u ...