1 Star 0 Fork 7

风的旋轮 / 仿羊了个羊web网页版h5源码

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.html 3.29 KB
一键复制 编辑 原始数据 按行查看 历史
方先生123 提交于 2022-09-24 17:29 . up
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/sheep.css" />
<script type="text/javascript" src="js/jquery-2.2.0.js" ></script>
<script type="text/javascript" src="js/main.js" ></script>
<script type="text/javascript" src="js/resources.js" ></script>
<script type="text/javascript" src="js/grass.js" ></script>
<script type="text/javascript" src="js/goods.js" ></script>
<script type="text/javascript" src="js/box.js" ></script>
<script type="text/javascript" src="js/button.js" ></script>
<script type="text/javascript" src="js/star.js" ></script>
<script type="text/javascript" src="js/level.js" ></script>
<script type="text/javascript" src="js/toast.js" ></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js" type="text/javascript"></script>
<title>羊了个羊</title>
</head>
<body>
<div class="div">
<canvas id="canvas" width="460px" height="800px"></canvas>
<audio controls autoplay hidden="True" loop id="bgmusic">
<source src="music/bg.mp3" type="audio/mpeg" >
您的浏览器不支持 audio 元素。
</audio>
</div>
<div id="wenzi" style="text-align:center;">
仿羊了个羊web h5版本正式上线,有疑问加微信fbao9394
<br>
<a href="https://gitee.com/fangxiansheng123">源码下载地址</a>
</div>
</body>
<script type="text/javascript">
/**
* @author ccbbs
* @file 解决安卓webview自动播放背景音乐的问题
*/
function BGMAutoPlayMgr/* solveAndroidBGMAutoplay */(url) {
this.audioContext = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)();
this.sourceNode = null;
this.buffer = null;
this.isPlayingBGM = false;
this.toggleBGM = function () {
if (typeof this.sourceNode == 'object') {
if (this.isPlayingBGM) {
this.sourceNode.stop();
this.isPlayingBGM = false;
} else this._playSourceNode();
}
}
this._playSourceNode = function () {
const audioContext = this.audioContext;
audioContext.resume();
const _sourceNode = audioContext.createBufferSource();
_sourceNode.buffer = this.buffer;
_sourceNode.loop = true;
_sourceNode.connect(audioContext.destination);
_sourceNode.start(0);
this.sourceNode = _sourceNode;
this.isPlayingBGM = true;
}
let loadAndAutoPlay = (audioUrl) => {
const audioContext = this.audioContext;
const xhr = new XMLHttpRequest();
xhr.open('GET', audioUrl, true);
xhr.responseType = 'arraybuffer';
xhr.onreadystatechange = () => {
if (xhr.status < 400 && xhr.status >= 200 && xhr.readyState === 4) {
audioContext.decodeAudioData(xhr.response, buffer => {
this.buffer = buffer;
WeixinJSBridge.invoke("getNetworkType", {}, () => this._playSourceNode());
});
}
}
xhr.send();
}
loadAndAutoPlay(url);
loadAndAutoPlay = null;
}
const bgm = new BGMAutoPlayMgr('music/bg.mp3');
function toggleBGM() {
bgm.toggleBGM();
}
</script>
</html>
JavaScript
1
https://gitee.com/fengdexuanlun/sheep.git
git@gitee.com:fengdexuanlun/sheep.git
fengdexuanlun
sheep
仿羊了个羊web网页版h5源码
master

搜索帮助