如何在Chrome扩展程序中播放随机视频?

时间:2016-04-18 17:29:56

标签: javascript html google-chrome

您好我正在尝试制作镀铬扩展程序,因此我将列出我拥有的2件物品!

这是我的popup.html

<!DOCTYPE html>
<html>
  <head>
    <title>NFKRZ</title>
    <style>
        body {
            width: 150px;
        }
        .blaze {
            margin: auto;
            display: block;
            width: 144px;
            height: 144px;
        }
        .button {
            margin: auto;
            background-color: #62009F;
            padding: 8px 16px;
            text-align: center;
            color: #FFFFFF;
            font-size: 18px;
            display: block;
            cursor: pointer;
            border-radius: 4px;
            transition-duration: 0.1s;
            border: none;
            width: 140px;
        }
        .button:hover {
            background-color: #A240DF;
        }
    </style>
    <script src="Video.js"></script>
  </head>
  <body>
    <img src="blaze.png" alt="Kill yourself m9" class="blaze"><br>
    <button id="anotherOne" class="button">Another one</button>
  </body>
</html>

接下来是我的javascript     var video = new Video();

function playRandomVideo() {

    if(video != null) {
        video.pause();
    }

    var num = Math.floor(Math.random() * 90) + 1;
    //var video = new Video();
    Video.src = num + ".mp4";
    Video.load();
    Video.play();
}

document.addEventListener('DOMContentLoaded', function() {
    playRandomVideo();

    document.getElementById('anotherOne').addEventListener('click',                playRandomVideo);
});

感谢您的任何回复我真的只想完成这个!我也很新,所以你要告诉我锄头做的!谢谢!

0 个答案:

没有答案