其他源码·随机小姐姐视频源码(内置api)

源码演示

图片[1]-随机小姐姐视频源码下载 - 内置API接口|多格式转换|免费开源程序

源码下载

<div class="beauty-video-widget">
    <h3 class="video-widget-title">随机美女视频</h3>
    
    <div class="video-container">
        <!-- 视频加载状态 -->
        <div class="loading-state">
            <div class="loader"></div>
            <p>获取视频中...</p>
        </div>
        
        <!-- 视频播放区域(添加自动播放属性) -->
        <video id="beautyVideo" class="video-player" controls poster="" loop muted autoplay>
            您的浏览器不支持视频播放
        </video>
        
        <!-- 错误提示 -->
        <div class="error-state" style="display: none;">
            <p>视频加载失败,请稍后重试</p>
            <button class="retry-btn">重试</button>
        </div>
    </div>
    
    <!-- 信息与刷新按钮区域 -->
    <div class="video-footer">
        <p class="video-info">每日更新,多种风格随机展示</p>
        <button class="refresh-btn" title="刷新视频">
            <svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M23 4V10H17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M1 20V14H7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
            </svg>
            刷新视频
        </button>
    </div>
</div>

<style>
.beauty-video-widget {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.video-widget-title {
    margin: 0;
    padding: 12px 15px;
    background: linear-gradient(90deg, #ff6b6b, #feca57);
    color: white;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.video-container {
    position: relative;
    padding-top: 56.25%; /* 16:9比例 */
    background: #f8f9fa;
}

.video-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

/* 底部信息与按钮区域 */
.video-footer {
    padding: 12px 15px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.video-info {
    margin: 0;
    font-size: 12px;
    color: #7f8c8d;
    text-align: center;
}

/* 刷新按钮样式(移至下方) */
.refresh-btn {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 15px;
    background: linear-gradient(90deg, #ff6b6b, #feca57);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(255, 107, 107, 0.3);
}

.refresh-btn:active {
    transform: translateY(0);
}

.loading-state {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid #f1f1f1;
    border-top: 3px solid #ff6b6b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.error-state {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    color: #e74c3c;
}

.retry-btn {
    padding: 6px 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.retry-btn:hover {
    background: #2980b9;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 响应式调整 */
@media (max-width: 480px) {
    .video-widget-title {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .refresh-btn {
        font-size: 12px;
        padding: 5px 12px;
    }
    
    .video-info {
        font-size: 11px;
    }
}
</style>

<script>
// API地址
const API_URL = 'https://v2.xxapi.cn/api/meinv';
const videoElement = document.getElementById('beautyVideo');
const loadingState = document.querySelector('.loading-state');
const errorState = document.querySelector('.error-state');
const refreshBtn = document.querySelector('.refresh-btn');

// 获取视频函数
function fetchVideo() {
    // 显示加载状态
    loadingState.style.display = 'flex';
    videoElement.style.display = 'none';
    errorState.style.display = 'none';
    
    // 调用API
    fetch(API_URL)
        .then(response => {
            if (!response.ok) throw new Error('网络错误');
            return response.json();
        })
        .then(data => {
            if (data.code === 200 && data.data) {
                // 成功获取视频
                videoElement.src = data.data;
                videoElement.poster = '';
                
                // 视频加载完成后显示并自动播放
                videoElement.onloadeddata = function() {
                    loadingState.style.display = 'none';
                    videoElement.style.display = 'block';
                    videoElement.play().catch(e => {
                        console.log('自动播放可能被浏览器阻止:', e);
                    });
                };
            } else {
                throw new Error('数据格式错误');
            }
        })
        .catch(error => {
            console.error('视频加载失败:', error);
            loadingState.style.display = 'none';
            errorState.style.display = 'flex';
        });
}

// 刷新按钮点击事件
refreshBtn.addEventListener('click', fetchVideo);

// 重试按钮事件
document.querySelector('.retry-btn').addEventListener('click', fetchVideo);

// 页面加载时获取视频
document.addEventListener('DOMContentLoaded', fetchVideo);
</script>

免责声明

该资源仅供学习和研究传播,请在下载后24小时内删除,一切关于该资源的商业行为和违法行为与本站无关。

© 版权声明
THE END
喜欢就支持一下吧
点赞14赞赏作者 分享
相关推荐