To stop a video from playing on any webpage

I am trying to add a button in my chrome extension that pause and play any video from playing on that current webpage. Nothing seems to work

<style>

  button {

    height: 30px;

    width: 100px;

    font-size: 14px;

  }

</style>
<button id="pause-button">Pause Video</button>

<script>

  document.getElementById("pause-button").addEventListener("click", function() {

    chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {

      chrome.tabs.executeScript({

        code: "var videos = document.getElementsByTagName('video'); for (var i = 0; i < videos.length; i++) { videos[i].pause(); }"

      });

    });

  });

</script>

Doesn’t seem to work