随机视频API

4 min

效果预览:

使用方法

方法一:新建独立页面

适用场景:创建一个专门的视频播放页面

步骤

  1. 新建一个HTML页面
  2. 将以下完整代码复制到页面中
  3. 配置参数(见下方说明)
<!DOCTYPE html>
<html lang="zh">
<head>
    <!--
 * Copyright (c) 2024 by xn--otsr53afot.com  All Rights Reserved.
-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>视频播放器</title>
    <link href="https://api.xn--otsr53afot.com/videos/css/muziqingcss.css" rel="stylesheet">
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background-color: #fff;
        }
    </style>
</head>
<body>
    <div class="video-container">
        <video id="videoPlayer" muted playsinline>
            <source id="videoSource" type="video/mp4">
        </video>
        <button class="play-button" id="playButton"></button>
        <div class="volume-control">
            <input id="volumeSlider" class="volume-slider" type="range" min="0" max="1" step="0.01" value="0">
        </div>
        <button class="next-button" id="nextButton">下一个</button>
    </div>

    <script>
        document.addEventListener('dragstart', (e) => { e.preventDefault(); });
        const videoPlayer = document.getElementById('videoPlayer');
        const playButton = document.getElementById('playButton');
        const nextButton = document.getElementById('nextButton');
        const volumeSlider = document.getElementById('volumeSlider');
        const videoSource = document.getElementById('videoSource');
        const apiKey = "你的key";  // 自定义API密钥(8-12位,a-z, 0-9)
        const domain = "你的域名";  // 部署此代码的网站域名
        const baseUrl = "https://api.xn--otsr53afot.com/videos/open.php";
    </script>
    <script src="https://api.xn--otsr53afot.com/videos/js/open.js"></script>
</body>
</html>

方法二:嵌入现有页面

适用场景:在现有页面中嵌入视频播放器

步骤

  1. 将以下代码复制到页面的HTML容器中
  2. 配置参数(见下方说明)
<link href="https://api.xn--otsr53afot.com/videos/css/muziqingcss.css" rel="stylesheet">
    <!--
 * Copyright (c) 2024 by xn--otsr53afot.com  All Rights Reserved.
-->
<meta charset="UTF-8">
<div class="video-container">
    <video id="videoPlayer" muted playsinline>
        <source id="videoSource" type="video/mp4">
    </video>
    <button class="play-button" id="playButton"></button>
    <div class="volume-control">
        <input id="volumeSlider" class="volume-slider" type="range" min="0" max="1" step="0.01" value="0">
    </div>
    <button class="next-button" id="nextButton">下一个</button>
</div>

<script>
    document.addEventListener('dragstart', (e) => { e.preventDefault(); });
    const videoPlayer = document.getElementById('videoPlayer');
    const playButton = document.getElementById('playButton');
    const nextButton = document.getElementById('nextButton');
    const volumeSlider = document.getElementById('volumeSlider');
    const videoSource = document.getElementById('videoSource');
    const apiKey = "你的key";  // 自定义API密钥(8-12位,a-z, 0-9)
    const domain = "你的域名";  // 部署此代码的网站域名
    const baseUrl = "https://api.xn--otsr53afot.com/videos/open.php";
</script>
<script src="https://api.xn--otsr53afot.com/videos/js/open.js"></script>

参数配置说明

API密钥(apiKey)

  • 格式要求:8-12位,仅包含字母(a-z)和数字(0-9)
  • 生成方式:随意输入,如:myvideo123randomkey456
  • 注意事项:如果某个key不工作,可以尝试更换其他key

域名(domain)

  • 含义:部署此代码的网站域名
  • 填写格式
    • 主域名:example.com
    • 二级域名:www.example.com
    • 无需包含协议(http:// 或 https://)
  • 示例
    • 如果代码部署在 https://example.com,则填写 example.com
    • 如果部署在 https://www.example.com,则填写 www.example.com

重要提醒

  • 域名必须准确:API会根据域名进行验证,填写错误的域名将无法正常工作
  • 保持一致性:同一个域名下的所有页面应该使用相同的域名配置
  • 测试建议:部署后先测试功能是否正常,如有问题检查域名配置