当前位置:网站首页>Swiper轮播图片并播放背景音乐
Swiper轮播图片并播放背景音乐
2022-07-30 18:27:00 【letisgo5】
需求:把文件夹下图片在浏览器上轮播,并播放音乐!!!
一开始也是从网上找,各种收费于是自己想法整了一个,目前只实现了轮播与播放音乐
效果图: 目前仅支持点击开始,然后开始播放音乐与轮播图片
代码(图片与html在同一目录,如不在同一目录则需调整src图片路径)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>Swiper demo</title>
<!-- Link Swiper's CSS -->
<link href="https://cdn.bootcss.com/Swiper/4.3.0/css/swiper.min.css" rel="stylesheet">
<!-- Demo styles -->
<style>
html, body {
position: relative;
width: 100%;
height: 100%;
}
body {
margin: 0;
padding: 0;
}
.m-swiper-container{
width: 100%;}
.m-swiper-slide{
display: block; background-size: 100% 100%;}
.m-swiper-img{
width: 100%;}
</style>
</head>
<body>
<!--bgm-->
<audio id="myAudio" src="http://music.163.com/song/media/outer/url?id=1901371647.mp3" controls="controls" autoplay loop="true" hidden="true"></audio>
<button id="goBut">GO!!!!!</button>
<!-- Swiper -->
<div class="swiper-container m-swiper-container" id="m-swiper-container">
<div class="swiper-wrapper" id="m-swiper-wrapper"></div>
</div>
<!-- Swiper JS -->
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/Swiper/4.3.0/js/swiper.min.js"></script>
<!-- Initialize Swiper -->
<script>
var hdfiles = ['1.png','2.png','3.png'];
$("#goBut").click(function () {
vMP3 = document.getElementById("myAudio");
vMP3.play();
document.getElementById("goBut").style.display = "none";
var swiperWrapper = $('#m-swiper-wrapper');
var html = '';
for (var i = 0; i < hdfiles.length; i++) {
html += '<a class="swiper-slide m-swiper-slide">' +
'<img src="' + hdfiles[i] + '" class="m-swiper-img">' +
'</a>';
}
swiperWrapper.html(html);
var swiper = new Swiper('#m-swiper-container', {
speed:300,
autoplay : {
delay:3000
},
loop: true
});
});
</script>
</body>
边栏推荐
- OSPF详解(4)
- 毕业1年从事软件测试拿下11.5k,没有给98后丢脸吧...
- 【HMS core】【Analytics Kit】【FAQ】如何解决华为分析付费分析中付款金额显示为0的问题?
- 中集世联达飞瞳全球工业人工智能AI领军者,全球顶尖AI核心技术高泛化性高鲁棒性稀疏样本持续学习,工业级高性能成熟AI产品规模应用
- 「Redis应用与深度实践笔记」,深得行业人的心,这还不来看看?
- Anaconda Navigator stuck on loading applications
- ESP8266-Arduino programming example-HC-SR04 ultrasonic sensor driver
- SQL存储过程详解
- 线性筛求积性函数
- Two-point answer naked question (plus a little pigeonhole principle)
猜你喜欢
MySQL data types
线性筛求积性函数
【Swords Offer】Swords Offer 17. Print n digits from 1 to the largest
【剑指 Offe】剑指 Offer 17. 打印从1到最大的n位数
Scrapy框架介绍
Pytorch foundation -- tensorboard use (1)
Deepen school-enterprise cooperation and build an "overpass" for the growth of technical and skilled talents
这玩意儿都能优化?果然是细节都在魔鬼里。
时序数据库在船舶风险管理领域的应用
【HMS core】【Analytics Kit】【FAQ】如何解决华为分析付费分析中付款金额显示为0的问题?
随机推荐
Two-point answer naked question (plus a little pigeonhole principle)
固定资产可视化智能管理系统
第14章 类型信息
The use of terminal split screen tool Terminalx
【HMS core】【Analytics Kit】【FAQ】如何解决华为分析付费分析中付款金额显示为0的问题?
linux 安装mysql8.0 超详细教程(实战多次)
积性函数
第十六期八股文巴拉巴拉说(MQ篇)
Pagoda builds PHP adaptive lazy website navigation source code measurement
3D机器视觉厂商的场景争夺战役
设计消息队列存储消息数据的 MySQL 表格
Pytorch foundation -- tensorboard use (1)
《自然语言处理实战入门》---- 文本样本扩展小技巧:使用回译技术进行样本增强
mysql的多实例
ByteArrayInputStream 类源码分析
AI基础:图解Transformer
linux 下MySQL本地安装mysql - u root - p 无法登入
Multiple instances of mysql
千亿级、大规模:腾讯超大 Apache Pulsar 集群性能调优实践
【开发者必看】【push kit】推送服务典型问题合集3