HTML 5 video does not play in the container












0















Let me preface this post by saying I'm not web designer. I have some knowledge, but not a lot. However, I volunteered to help a friend update his 20-year-old website. The issue in question is this: There are several small videos that I'd like to have to displayed in a playlist. I found some code online here Here that works perfectly on their site. But when I pasted it into my test page the videos will play, but when I click one in the playlist it goes full screen and then overlaps the playlist. I don't what I did wrong. Any and all help would be appreciated to get this working. Everything works except the videos pop out and cover the screen negating the need for a playlist.
Here is my code:



    '<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
body { background: #222; }
video_player {
display: table; line-height: 0;
font-size: 0; background: #000;
max-width: 1000px;
margin: 0 auto;
}
#video_container {
position: relative;
}
#video_player div, #video_player figcaption {
display: table-cell;
vertical-align: top;
}
#video_container video {
position: absolute;
display: block;
width: 100%;
height: 100%;
top: 0;
}
#video_player figcaption { width: 25%; }
#video_player figcaption a { display: block; }
#video_player figcaption a {
opacity: .5;
transition: 1s opacity;
}
#video_player figcaption a img, figure video {
width: 100%; height: auto;
}
#video_player figcaption a.currentvid, #video_player figcaption a:hover,
#video_player figcaption a:focus { opacity: 1; }
@media (max-width: 700px) {
#video_player video, #video_player figcaption {
display: table-row;
}
#video_container { padding-top: 56.25%; }
#video_player figcaption a {
display: inline-block; width: 33.33%;
}
}
</style>
</head>
<body>
<figure id="video_player">
<div id="video_container">
<video controls poster="vid-glacier.jpg" playsinline>
<source src="glacier.mp4" type="video/mp4">
<source src="glacier.webm" type="video/webm">
</video>
</div>
<figcaption>
<a href="glacier.mp4" class="currentvid">
<img src="vid-glacier.jpg" alt="Athabasca Glacier">
</a>
<a href="lake.mp4">
<img src="vid-lake.jpg" alt="Athabasca Lake">
</a>
<a href="mountain.mp4">
<img src="vid-mountain.jpg" alt="Mountain">
</a>
</figcaption>
</figure>
<script>
var video_player = document.getElementById("video_player");
video = video_player.getElementsByTagName("video")[0],
video_links = video_player.getElementsByTagName("figcaption")[0],
source = video.getElementsByTagName("source"),
link_list = ,
vidDir = "C:UsersjohnnDesktopwebsite",
currentVid = 0,
allLnks = video_links.children,
lnkNum = allLnks.length;
video.removeAttribute("controls");
video.removeAttribute("poster");

video.addEventListener('click', () => { video.play(); })

(function() {
function playVid(index) {
video_links.children[index].classList.add("currentvid");
source[1].src = vidDir + link_list[index] + ".webm";
source[0].src = vidDir + link_list[index] + ".mp4";
currentVid = index;
video.load();
video.play();
}

for (var i=0; i<lnkNum; i++) {
var filename = allLnks[i].href;
link_list[i] = filename.match(/([^/]+)(?=.w+$)/)[0];
(function(index){
allLnks[i].onclick = function(i){
i.preventDefault();
for (var i=0; i<lnkNum; i++) {
allLnks[i].classList.remove("currentvid");
}
playVid(index);
}
})(i);
}
video.addEventListener('ended', function () {
allLnks[currentVid].classList.remove("currentvid");
if ((currentVid + 1) >= lnkNum) { nextVid = 0 } else { nextVid =
currentVid+1 }
playVid(nextVid);
})

video.addEventListener('mouseenter', function() {
video.setAttribute("controls","true");
})

video.addEventListener('mouseleave', function() {
video.removeAttribute("controls");
})

var indexOf = function(needle) {
if(typeof Array.prototype.indexOf === 'function') {
indexOf = Array.prototype.indexOf;
} else {
indexOf = function(needle) {
var i = -1, index = -1;
for(i = 0; i < this.length; i++) {
if(this[i] === needle) {
index = i;
break;
}}
return index;
};}
return indexOf.call(this, needle);
};
var focusedLink = document.activeElement;
index = indexOf.call(allLnks, focusedLink);

document.addEventListener('keydown', function(e) {
if (index) {
var focusedElement = document.activeElement;
if (e.keyCode == 40 || e.keyCode == 39) { // down or right cursor
var nextNode = focusedElement.nextElementSibling;
if (nextNode) { nextNode.focus(); } else {
video_links.firstElementChild.focus(); }
}
if (e.keyCode == 38 || e.keyCode == 37) { // up or left cursor
var previousNode = focusedElement.previousElementSibling;
if (previousNode) { previousNode.focus(); } else {
video_links.lastElementChild.focus(); }
}
}
});

})();
</script>
</body>
</html>`









share|improve this question



























    0















    Let me preface this post by saying I'm not web designer. I have some knowledge, but not a lot. However, I volunteered to help a friend update his 20-year-old website. The issue in question is this: There are several small videos that I'd like to have to displayed in a playlist. I found some code online here Here that works perfectly on their site. But when I pasted it into my test page the videos will play, but when I click one in the playlist it goes full screen and then overlaps the playlist. I don't what I did wrong. Any and all help would be appreciated to get this working. Everything works except the videos pop out and cover the screen negating the need for a playlist.
    Here is my code:



        '<!DOCTYPE html>
    <html>
    <head>
    <title>Page Title</title>
    <style>
    body { background: #222; }
    video_player {
    display: table; line-height: 0;
    font-size: 0; background: #000;
    max-width: 1000px;
    margin: 0 auto;
    }
    #video_container {
    position: relative;
    }
    #video_player div, #video_player figcaption {
    display: table-cell;
    vertical-align: top;
    }
    #video_container video {
    position: absolute;
    display: block;
    width: 100%;
    height: 100%;
    top: 0;
    }
    #video_player figcaption { width: 25%; }
    #video_player figcaption a { display: block; }
    #video_player figcaption a {
    opacity: .5;
    transition: 1s opacity;
    }
    #video_player figcaption a img, figure video {
    width: 100%; height: auto;
    }
    #video_player figcaption a.currentvid, #video_player figcaption a:hover,
    #video_player figcaption a:focus { opacity: 1; }
    @media (max-width: 700px) {
    #video_player video, #video_player figcaption {
    display: table-row;
    }
    #video_container { padding-top: 56.25%; }
    #video_player figcaption a {
    display: inline-block; width: 33.33%;
    }
    }
    </style>
    </head>
    <body>
    <figure id="video_player">
    <div id="video_container">
    <video controls poster="vid-glacier.jpg" playsinline>
    <source src="glacier.mp4" type="video/mp4">
    <source src="glacier.webm" type="video/webm">
    </video>
    </div>
    <figcaption>
    <a href="glacier.mp4" class="currentvid">
    <img src="vid-glacier.jpg" alt="Athabasca Glacier">
    </a>
    <a href="lake.mp4">
    <img src="vid-lake.jpg" alt="Athabasca Lake">
    </a>
    <a href="mountain.mp4">
    <img src="vid-mountain.jpg" alt="Mountain">
    </a>
    </figcaption>
    </figure>
    <script>
    var video_player = document.getElementById("video_player");
    video = video_player.getElementsByTagName("video")[0],
    video_links = video_player.getElementsByTagName("figcaption")[0],
    source = video.getElementsByTagName("source"),
    link_list = ,
    vidDir = "C:UsersjohnnDesktopwebsite",
    currentVid = 0,
    allLnks = video_links.children,
    lnkNum = allLnks.length;
    video.removeAttribute("controls");
    video.removeAttribute("poster");

    video.addEventListener('click', () => { video.play(); })

    (function() {
    function playVid(index) {
    video_links.children[index].classList.add("currentvid");
    source[1].src = vidDir + link_list[index] + ".webm";
    source[0].src = vidDir + link_list[index] + ".mp4";
    currentVid = index;
    video.load();
    video.play();
    }

    for (var i=0; i<lnkNum; i++) {
    var filename = allLnks[i].href;
    link_list[i] = filename.match(/([^/]+)(?=.w+$)/)[0];
    (function(index){
    allLnks[i].onclick = function(i){
    i.preventDefault();
    for (var i=0; i<lnkNum; i++) {
    allLnks[i].classList.remove("currentvid");
    }
    playVid(index);
    }
    })(i);
    }
    video.addEventListener('ended', function () {
    allLnks[currentVid].classList.remove("currentvid");
    if ((currentVid + 1) >= lnkNum) { nextVid = 0 } else { nextVid =
    currentVid+1 }
    playVid(nextVid);
    })

    video.addEventListener('mouseenter', function() {
    video.setAttribute("controls","true");
    })

    video.addEventListener('mouseleave', function() {
    video.removeAttribute("controls");
    })

    var indexOf = function(needle) {
    if(typeof Array.prototype.indexOf === 'function') {
    indexOf = Array.prototype.indexOf;
    } else {
    indexOf = function(needle) {
    var i = -1, index = -1;
    for(i = 0; i < this.length; i++) {
    if(this[i] === needle) {
    index = i;
    break;
    }}
    return index;
    };}
    return indexOf.call(this, needle);
    };
    var focusedLink = document.activeElement;
    index = indexOf.call(allLnks, focusedLink);

    document.addEventListener('keydown', function(e) {
    if (index) {
    var focusedElement = document.activeElement;
    if (e.keyCode == 40 || e.keyCode == 39) { // down or right cursor
    var nextNode = focusedElement.nextElementSibling;
    if (nextNode) { nextNode.focus(); } else {
    video_links.firstElementChild.focus(); }
    }
    if (e.keyCode == 38 || e.keyCode == 37) { // up or left cursor
    var previousNode = focusedElement.previousElementSibling;
    if (previousNode) { previousNode.focus(); } else {
    video_links.lastElementChild.focus(); }
    }
    }
    });

    })();
    </script>
    </body>
    </html>`









    share|improve this question

























      0












      0








      0








      Let me preface this post by saying I'm not web designer. I have some knowledge, but not a lot. However, I volunteered to help a friend update his 20-year-old website. The issue in question is this: There are several small videos that I'd like to have to displayed in a playlist. I found some code online here Here that works perfectly on their site. But when I pasted it into my test page the videos will play, but when I click one in the playlist it goes full screen and then overlaps the playlist. I don't what I did wrong. Any and all help would be appreciated to get this working. Everything works except the videos pop out and cover the screen negating the need for a playlist.
      Here is my code:



          '<!DOCTYPE html>
      <html>
      <head>
      <title>Page Title</title>
      <style>
      body { background: #222; }
      video_player {
      display: table; line-height: 0;
      font-size: 0; background: #000;
      max-width: 1000px;
      margin: 0 auto;
      }
      #video_container {
      position: relative;
      }
      #video_player div, #video_player figcaption {
      display: table-cell;
      vertical-align: top;
      }
      #video_container video {
      position: absolute;
      display: block;
      width: 100%;
      height: 100%;
      top: 0;
      }
      #video_player figcaption { width: 25%; }
      #video_player figcaption a { display: block; }
      #video_player figcaption a {
      opacity: .5;
      transition: 1s opacity;
      }
      #video_player figcaption a img, figure video {
      width: 100%; height: auto;
      }
      #video_player figcaption a.currentvid, #video_player figcaption a:hover,
      #video_player figcaption a:focus { opacity: 1; }
      @media (max-width: 700px) {
      #video_player video, #video_player figcaption {
      display: table-row;
      }
      #video_container { padding-top: 56.25%; }
      #video_player figcaption a {
      display: inline-block; width: 33.33%;
      }
      }
      </style>
      </head>
      <body>
      <figure id="video_player">
      <div id="video_container">
      <video controls poster="vid-glacier.jpg" playsinline>
      <source src="glacier.mp4" type="video/mp4">
      <source src="glacier.webm" type="video/webm">
      </video>
      </div>
      <figcaption>
      <a href="glacier.mp4" class="currentvid">
      <img src="vid-glacier.jpg" alt="Athabasca Glacier">
      </a>
      <a href="lake.mp4">
      <img src="vid-lake.jpg" alt="Athabasca Lake">
      </a>
      <a href="mountain.mp4">
      <img src="vid-mountain.jpg" alt="Mountain">
      </a>
      </figcaption>
      </figure>
      <script>
      var video_player = document.getElementById("video_player");
      video = video_player.getElementsByTagName("video")[0],
      video_links = video_player.getElementsByTagName("figcaption")[0],
      source = video.getElementsByTagName("source"),
      link_list = ,
      vidDir = "C:UsersjohnnDesktopwebsite",
      currentVid = 0,
      allLnks = video_links.children,
      lnkNum = allLnks.length;
      video.removeAttribute("controls");
      video.removeAttribute("poster");

      video.addEventListener('click', () => { video.play(); })

      (function() {
      function playVid(index) {
      video_links.children[index].classList.add("currentvid");
      source[1].src = vidDir + link_list[index] + ".webm";
      source[0].src = vidDir + link_list[index] + ".mp4";
      currentVid = index;
      video.load();
      video.play();
      }

      for (var i=0; i<lnkNum; i++) {
      var filename = allLnks[i].href;
      link_list[i] = filename.match(/([^/]+)(?=.w+$)/)[0];
      (function(index){
      allLnks[i].onclick = function(i){
      i.preventDefault();
      for (var i=0; i<lnkNum; i++) {
      allLnks[i].classList.remove("currentvid");
      }
      playVid(index);
      }
      })(i);
      }
      video.addEventListener('ended', function () {
      allLnks[currentVid].classList.remove("currentvid");
      if ((currentVid + 1) >= lnkNum) { nextVid = 0 } else { nextVid =
      currentVid+1 }
      playVid(nextVid);
      })

      video.addEventListener('mouseenter', function() {
      video.setAttribute("controls","true");
      })

      video.addEventListener('mouseleave', function() {
      video.removeAttribute("controls");
      })

      var indexOf = function(needle) {
      if(typeof Array.prototype.indexOf === 'function') {
      indexOf = Array.prototype.indexOf;
      } else {
      indexOf = function(needle) {
      var i = -1, index = -1;
      for(i = 0; i < this.length; i++) {
      if(this[i] === needle) {
      index = i;
      break;
      }}
      return index;
      };}
      return indexOf.call(this, needle);
      };
      var focusedLink = document.activeElement;
      index = indexOf.call(allLnks, focusedLink);

      document.addEventListener('keydown', function(e) {
      if (index) {
      var focusedElement = document.activeElement;
      if (e.keyCode == 40 || e.keyCode == 39) { // down or right cursor
      var nextNode = focusedElement.nextElementSibling;
      if (nextNode) { nextNode.focus(); } else {
      video_links.firstElementChild.focus(); }
      }
      if (e.keyCode == 38 || e.keyCode == 37) { // up or left cursor
      var previousNode = focusedElement.previousElementSibling;
      if (previousNode) { previousNode.focus(); } else {
      video_links.lastElementChild.focus(); }
      }
      }
      });

      })();
      </script>
      </body>
      </html>`









      share|improve this question














      Let me preface this post by saying I'm not web designer. I have some knowledge, but not a lot. However, I volunteered to help a friend update his 20-year-old website. The issue in question is this: There are several small videos that I'd like to have to displayed in a playlist. I found some code online here Here that works perfectly on their site. But when I pasted it into my test page the videos will play, but when I click one in the playlist it goes full screen and then overlaps the playlist. I don't what I did wrong. Any and all help would be appreciated to get this working. Everything works except the videos pop out and cover the screen negating the need for a playlist.
      Here is my code:



          '<!DOCTYPE html>
      <html>
      <head>
      <title>Page Title</title>
      <style>
      body { background: #222; }
      video_player {
      display: table; line-height: 0;
      font-size: 0; background: #000;
      max-width: 1000px;
      margin: 0 auto;
      }
      #video_container {
      position: relative;
      }
      #video_player div, #video_player figcaption {
      display: table-cell;
      vertical-align: top;
      }
      #video_container video {
      position: absolute;
      display: block;
      width: 100%;
      height: 100%;
      top: 0;
      }
      #video_player figcaption { width: 25%; }
      #video_player figcaption a { display: block; }
      #video_player figcaption a {
      opacity: .5;
      transition: 1s opacity;
      }
      #video_player figcaption a img, figure video {
      width: 100%; height: auto;
      }
      #video_player figcaption a.currentvid, #video_player figcaption a:hover,
      #video_player figcaption a:focus { opacity: 1; }
      @media (max-width: 700px) {
      #video_player video, #video_player figcaption {
      display: table-row;
      }
      #video_container { padding-top: 56.25%; }
      #video_player figcaption a {
      display: inline-block; width: 33.33%;
      }
      }
      </style>
      </head>
      <body>
      <figure id="video_player">
      <div id="video_container">
      <video controls poster="vid-glacier.jpg" playsinline>
      <source src="glacier.mp4" type="video/mp4">
      <source src="glacier.webm" type="video/webm">
      </video>
      </div>
      <figcaption>
      <a href="glacier.mp4" class="currentvid">
      <img src="vid-glacier.jpg" alt="Athabasca Glacier">
      </a>
      <a href="lake.mp4">
      <img src="vid-lake.jpg" alt="Athabasca Lake">
      </a>
      <a href="mountain.mp4">
      <img src="vid-mountain.jpg" alt="Mountain">
      </a>
      </figcaption>
      </figure>
      <script>
      var video_player = document.getElementById("video_player");
      video = video_player.getElementsByTagName("video")[0],
      video_links = video_player.getElementsByTagName("figcaption")[0],
      source = video.getElementsByTagName("source"),
      link_list = ,
      vidDir = "C:UsersjohnnDesktopwebsite",
      currentVid = 0,
      allLnks = video_links.children,
      lnkNum = allLnks.length;
      video.removeAttribute("controls");
      video.removeAttribute("poster");

      video.addEventListener('click', () => { video.play(); })

      (function() {
      function playVid(index) {
      video_links.children[index].classList.add("currentvid");
      source[1].src = vidDir + link_list[index] + ".webm";
      source[0].src = vidDir + link_list[index] + ".mp4";
      currentVid = index;
      video.load();
      video.play();
      }

      for (var i=0; i<lnkNum; i++) {
      var filename = allLnks[i].href;
      link_list[i] = filename.match(/([^/]+)(?=.w+$)/)[0];
      (function(index){
      allLnks[i].onclick = function(i){
      i.preventDefault();
      for (var i=0; i<lnkNum; i++) {
      allLnks[i].classList.remove("currentvid");
      }
      playVid(index);
      }
      })(i);
      }
      video.addEventListener('ended', function () {
      allLnks[currentVid].classList.remove("currentvid");
      if ((currentVid + 1) >= lnkNum) { nextVid = 0 } else { nextVid =
      currentVid+1 }
      playVid(nextVid);
      })

      video.addEventListener('mouseenter', function() {
      video.setAttribute("controls","true");
      })

      video.addEventListener('mouseleave', function() {
      video.removeAttribute("controls");
      })

      var indexOf = function(needle) {
      if(typeof Array.prototype.indexOf === 'function') {
      indexOf = Array.prototype.indexOf;
      } else {
      indexOf = function(needle) {
      var i = -1, index = -1;
      for(i = 0; i < this.length; i++) {
      if(this[i] === needle) {
      index = i;
      break;
      }}
      return index;
      };}
      return indexOf.call(this, needle);
      };
      var focusedLink = document.activeElement;
      index = indexOf.call(allLnks, focusedLink);

      document.addEventListener('keydown', function(e) {
      if (index) {
      var focusedElement = document.activeElement;
      if (e.keyCode == 40 || e.keyCode == 39) { // down or right cursor
      var nextNode = focusedElement.nextElementSibling;
      if (nextNode) { nextNode.focus(); } else {
      video_links.firstElementChild.focus(); }
      }
      if (e.keyCode == 38 || e.keyCode == 37) { // up or left cursor
      var previousNode = focusedElement.previousElementSibling;
      if (previousNode) { previousNode.focus(); } else {
      video_links.lastElementChild.focus(); }
      }
      }
      });

      })();
      </script>
      </body>
      </html>`






      html5 video containers






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 17:41









      JohnnyJohnny

      11




      11
























          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54010803%2fhtml-5-video-does-not-play-in-the-container%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54010803%2fhtml-5-video-does-not-play-in-the-container%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith