随机视频API

首先打开服务器创建一个html文件也可以不创建


代码如下

点击查看代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charSet="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta http-equiv="Cache-Control" content="no-transform" /> 
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta name="referrer" content="never">
    <meta name="renderer" content="webkit" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>小姐姐在线随机播放</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <section id="main">
        <video id="player" src="video.php" controls webkit-playsinline playsinline></video>
    </section>
    <section id="buttons">
        <button id="switch">连续: 开</button>
        <button id="next">播放下一个</button>
    </section>
    <script>
    (function (window, document) {
        if (top != self) {
            window.top.location.replace(self.location.href);
        }
        var get = function (id) {
            return document.getElementById(id);
        }
        var bind = function (element, event, callback) {
            return element.addEventListener(event, callback);
        }
        var auto = true;
        var player = get('player');
        var randomm = function () {
            player.src = 'video.php?_t=' + Math.random();
            player.play();
        }
        bind(get('next'), 'click', randomm);
        bind(player, 'error', function () {
            randomm();
        });
        bind(get('switch'), 'click', function () {
            auto = !auto;
            this.innerText = '连续: ' + (auto ? '开' : '关');
        });
        bind(player, 'ended', function () {
            if (auto) randomm();
        });
    })(window, document);
    </script>
</body>
</html>

接下来我们给html创建一个简单的css美化


代码如下

点击查看代码
* {
    border: 0;
    margin: 0;
    padding: 0;
    outline: none;
    box-sizing: border-box;
}

body {
    background: #000;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}


#main {
    height: calc(100vh - 60px);
    display: flex;
    justify-content: center;
    align-items: center;
}

#player {
    width: 100%;
    height: auto;
    max-height: 100%;
}

#buttons {
    height: 60px;
    padding: 10px;
}

#switch,
#next {
    background: #FFF;
    background: linear-gradient(to bottom, #FF2,#FB0);
    color: #AF2E08;
    font-size: 16px;
    font-weight: bold;
    height: 40px;
    padding: 0px 20px;
    margin: 0px 5px;
    border-radius: 20px;
}

随后添加API如下

点击查看代码
<?php

function read(...$filelist) {
    $list = [];
    foreach ($filelist as $file) {
        $handle = fopen($file, 'r');
        while (($line = fgets($handle)) !== false) {
            array_push($list, trim($line));
        }
        fclose($handle);
    }
    return $list;
}

$list = read('ks.txt');
$url = $list[array_rand($list)];

header("Location: {$url}");

接下来就是最简单的创建一个txt文件将你想要展示的链接粘贴进去即可


这里我提供一些

点击查看
https://dwz.mk/FvQVNb
https://dwz.mk/Q3YBjm
https://dwz.mk/MVZVjy
http://b6i.cn/6yHq3
http://mtw.so/66fctR
http://mtw.so/6d5rQ6
http://mtw.so/6llOO4
http://mtw.so/5JKMrO
http://mtw.so/66faVz
http://mtw.so/6llPR4
http://mtw.so/6sS2VL
http://mtw.so/5YNa04
http://mtw.so/6llPRe
http://mtw.so/5Ceznr
http://mtw.so/6d5qi8
http://mtw.so/5uImiU
http://mtw.so/6d5qii
http://mtw.so/5JKMu4
http://mtw.so/6llPRI
http://mtw.so/5uImkQ
http://mtw.so/5YNa2k
http://mtw.so/6llPRS
http://mtw.so/5JKMuo
http://mtw.so/6d5qiM
http://mtw.so/6llPS2
http://mtw.so/5JKMuy
http://mtw.so/5YNa2E
posted @ 2021-11-19 21:33  小kBlog  阅读(2640)  评论(0编辑  收藏  举报