当前位置:网站首页>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>
边栏推荐
- 第4章 控制执行流程
- 使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported
- CCNA-NAT协议(理论与实验练习)
- 【HMS Core】【FAQ】运动健康、音频编辑、华为帐号服务 典型问题合集7
- What ARC does at compile time and runtime
- arcpy获取要素类(属性表)包含的数目
- 网络基础(三)01-网络的基础概念——URL地址组成之协议、主机地址、路径和参数&127.0.0.1本地回环地址& 查看网址IP地址并访问之ping空格+网址&netstat -anb查看本机占用端口
- DTSE Tech Talk丨第2期:1小时深度解读SaaS应用系统设计
- 【剑指 Offe】剑指 Offer 18. 删除链表的节点
- NC | 西湖大学陶亮组-TMPRSS2“助攻”病毒感染并介导索氏梭菌出血毒素的宿主入侵...
猜你喜欢

DevEco Studio3.0下载失败,提示An unknown error occurred

SQL行列转换

Mysql execution principle analysis

网络基础(三)01-网络的基础概念——URL地址组成之协议、主机地址、路径和参数&127.0.0.1本地回环地址& 查看网址IP地址并访问之ping空格+网址&netstat -anb查看本机占用端口

OSPF详解(4)

载誉而归,重磅发布!润和软件亮相2022开放原子全球开源峰会

一文读懂“语言模型”

Read the "Language Model" in one article

Graphic LeetCode -- 11. Containers of most water (difficulty: medium)

《痞子衡嵌入式半月刊》 第 59 期
随机推荐
【Swords Offer】Swords Offer 17. Print n digits from 1 to the largest
[Solved] The problem that Unity Hub fails to obtain a license or does not respond and cannot develop
网络基础(二)-Web服务器-简介——WampServer集成服务器软件之Apache+MySQL软件安装流程 & netstat -an之检测计算机的端口是否占用
The large-scale application of artificial intelligence AI products in industrial-grade mature shipping ports of CIMC World Lianda will create a new generation of high-efficiency smart ports and innova
Anaconda Navigator stuck on loading applications
Network Basics (3) 01-Basic Concepts of Networks - Protocols, Host Addresses, Paths and Parameters of URL Addresses & 127.0.0.1 Local Loopback Address & View URL IP Address and Access Ping Space + URL
积性函数
Confluence OGNL注入漏洞复现(CVE-2022-26134)
Multiple instances of mysql
OSPF详解(4)
Hello, my new name is "Bronze Lock/Tongsuo"
One year after graduation, I was engaged in software testing and won 11.5k. I didn't lose face to the post-98 generation...
Pytorch基础--tensorboard使用(一)
SQL存储过程详解
[Summary] 1396- 60+ VSCode plugins to create a useful editor
mysql的多实例
The sixteenth issue of eight-part article Balabala said (MQ)
SwiftUI iOS Boutique Open Source Project Complete Baked Food Recipe App based on SQLite (tutorial including source code)
微博广告分布式配置中心的构建与实践(有彩蛋)
基础架构之Redis