亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長(zhǎng)資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    html5 音頻播放圖文實(shí)例

    根據(jù)html5實(shí)現(xiàn)的簡(jiǎn)單的音頻播放,還是挺好的,可以借鑒,下面上代碼了

    <!doctype html>  <html lang="en">  <head>  	<meta charset="UTF-8">  	<meta name="viewport" content="width=device-width,initial-scale=1 user-scalable=0"/>  	<link rel="shortcut icon" href="img/logo.png">  	<title>html5 audio音頻播放</title>  	<style>  		*{ margin: 0; padding:0;}  		body{-webkit-tap-highlight-color: rgba(0,0,0,0); font-family: "微軟雅黑"}  		h1{ width: 100%; font-size: 1.5em; text-align: center; line-height: 3em; color:#47c9af; }  		#audio{ width: 100%;}  		#control{ width: 150px; height: 150px; line-height: 150px; text-align: center; border-radius: 200px; border:none; color:#fff; margin-top: -75px; margin-left:-75px; left:50%; top:50%; position: absolute; box-shadow: #888 0 0 8px;}  		.color_gray{ background: #e4e4e4}  		.hide{ display: none;}  		.show{ display: block;}  		.play{ background:  #f06060;}  		.pause{ background:skyblue}  		/*進(jìn)度條樣式*/  		.progressBar{ width: 100%; height: 10px;margin: 30px auto 30px auto; position:absolute; left: 0; bottom: 35px;}  		.progressBar p{ position: absolute;}  		.progressBar .progressBac{ width: 100%; height: 10px;  left: 0; top:0; background: #e4e4e4;}  		.progressBar .speed{width: 100%; height: 10px; left: -100%; background: #f06060; }  		.progressBar .drag{ width: 30px; height: 30px; left: 0; top:-10px;  background: skyblue; opacity: 0.8; border-radius: 50px; box-shadow: #fff 0 0 5px;}  		/*時(shí)間樣式*/  		#time{ width: 100%; height: 20px;position: absolute; left: 0; bottom:30px; color:#888;}  		.tiemDetail{ position: absolute; right:10px; top:0;}  		#songInfo{overflow: hidden; width: 200px; height:50px; line-height: 50px; text-align: center; color:#34495e;   margin-top: -25px; margin-left:-100px; left:50%; top:70%; position: absolute;}  		.shareImg{ position: absolute; left: 100000px;}  	</style>  </head>  	  <body>  	<script>  $(function() {  	getSong();  })    //獲取歌曲鏈接并插入dom中  function getSong() {   	var audio = document.getElementById("audio");  	audio.src = "http://frontman.qiniudn.com/songnotime.mp3";  	audio.loop = true; //歌曲循環(huán)  	playCotrol(); //播放控制函數(shù)    }    //點(diǎn)擊播放/暫停  function clicks() {  	var audio = document.getElementById("audio");  	$("#control").click(function() {  		if ($("#control").hasClass("play")) {  			$("#control").addClass("pause").removeClass("play");  			audio.play();//開(kāi)始播放  			dragMove();//并且滾動(dòng)條開(kāi)始滑動(dòng)  			$("#control").html("暫停播放");  		} else {  			$("#control").addClass("play").removeClass("pause");  			$("#control").html("點(diǎn)擊播放");  			audio.pause();  		}  	})  }    //播放時(shí)間  function timeChange(time, timePlace) {//默認(rèn)獲取的時(shí)間是時(shí)間戳改成我們常見(jiàn)的時(shí)間格式  	var timePlace = document.getElementById(timePlace);  	//分鐘  	var minute = time / 60;  	var minutes = parseInt(minute);  	if (minutes < 10) {  		minutes = "0" + minutes;  	}  	//秒  	var second = time % 60;  	seconds = parseInt(second);  	if (seconds < 10) {  		seconds = "0" + seconds;  	}  	var allTime = "" + minutes + "" + ":" + "" + seconds + ""  	timePlace.innerHTML = allTime;  }    //播放事件監(jiān)聽(tīng)  function playCotrol() {  	audio.addEventListener("loadeddata", //歌曲一經(jīng)完整的加載完畢( 也可以寫(xiě)成上面提到的那些事件類(lèi)型)  		function() {  			$("#control").addClass("play").removeClass("color_gray");  			$("#control").html("點(diǎn)擊播放");  			addListenTouch(); //歌曲加載之后才可以拖動(dòng)進(jìn)度條  			var allTime = audio.duration;  			timeChange(allTime, "allTime");  			setInterval(function() {  				var currentTime = audio.currentTime;  				$("#time .currentTime").html(timeChange(currentTime, "currentTime"));  			}, 1000);  			clicks();  		}, false);    	audio.addEventListener("pause",  		function() { //監(jiān)聽(tīng)暫停  			$("#control").addClass("play").removeClass("pause");  			$("#control").html("點(diǎn)擊播放");  			if (audio.currentTime == audio.duration) {  				audio.stop();  				audio.currentTime = 0;  			}  		}, false);  	audio.addEventListener("play",  		function() { //監(jiān)聽(tīng)暫停  			$("#control").addClass("pause").removeClass("play");  			$("#control").html("暫停播放");  			dragMove();  		}, false);  	audio.addEventListener("ended", function() {  		alert(0)  	}, false)  }  	  //進(jìn)度條  這里我用的是事件實(shí)現(xiàn)進(jìn)度拖動(dòng) 如果不太熟悉touch的可以看下我之前寫(xiě)的一個(gè)小demo http://www.cnblogs.com/leinov/p/3701951.html   var startX, x, aboveX = 0; //觸摸時(shí)的坐標(biāo) //滑動(dòng)的距離  //設(shè)一個(gè)全局變量記錄上一次內(nèi)部塊滑動(dòng)的位置     //1拖動(dòng)監(jiān)聽(tīng)touch事件  function addListenTouch() {  	document.getElementById("drag").addEventListener("touchstart", touchStart, false);  	document.getElementById("drag").addEventListener("touchmove", touchMove, false);  	document.getElementById("drag").addEventListener("touchend", touchEnd, false);  	var drag = document.getElementById("drag");  	var speed = document.getElementById("speed");  }    //touchstart,touchmove,touchend事件函數(shù)   function touchStart(e) {     	e.preventDefault();   	var touch = e.touches[0];   	startX = touch.pageX;    }   function touchMove(e) { //滑動(dòng)             	e.preventDefault();   	var touch = e.touches[0];   	x = touch.pageX - startX; //滑動(dòng)的距離   	//drag.style.webkitTransform = 'translate(' + 0+ 'px, ' + y + 'px)';  //也可以用css3的方式        	drag.style.left = aboveX + x + "px"; //     	speed.style.left = -((window.innerWidth) - (aboveX + x)) + "px";   }   function touchEnd(e) { //手指離開(kāi)屏幕   	e.preventDefault();   	aboveX = parseInt(drag.style.left);   	var touch = e.touches[0];   	var dragPaddingLeft = drag.style.left;   	var change = dragPaddingLeft.replace("px", "");   	numDragpaddingLeft = parseInt(change);   	var currentTime = (numDragpaddingLeft / (window.innerWidth - 30)) * audio.duration;//30是拖動(dòng)圓圈的長(zhǎng)度,減掉是為了讓歌曲結(jié)束的時(shí)候不會(huì)跑到window以外   	audio.currentTime = currentTime;   }  //3拖動(dòng)的滑動(dòng)條前進(jìn)  function dragMove() {  	setInterval(function() {  		drag.style.left = (audio.currentTime / audio.duration) * (window.innerWidth - 30) + "px";  		speed.style.left = -((window.innerWidth) - (audio.currentTime / audio.duration) * (window.innerWidth - 30)) + "px";  	}, 500);  }  </script>    <h1>html5 audio 音頻播放demo</h1>    <!--audiostart-->  <audio id="audio" src=""  loop="loop" autoplay="autoplay" ></audio>  <!--audio End-->        <!--播放控制按鈕start-->  <button id="control" class="">loading</button>  <!--播放控制按鈕end-->    <!--時(shí)間進(jìn)度條塊兒start-->  <section class="progressBar">  	<p class="progressBac"></p>  	<p class="speed" id="speed"></p>  	<p class="drag" id="drag"></p>  </section>  <!--時(shí)間進(jìn)度條塊兒end-->    <!--播放時(shí)間start-->  <p id="time"><p class="tiemDetail"><span class="currentTime" id="currentTime">00:00</span>/<span class="allTime" id="allTime">00:00</span></p></p>  <!--播放時(shí)間end-->  <!--歌曲信息start-->  <p id="songInfo">沒(méi)時(shí)間-Leinov<p class="shareImg"><img src="img/html5audio.jpg" alt=""></p></p>  <!--歌曲信息end-->  <script src="js/zepto.js"></script>  </body>  </html>

    2. [圖片] audioplay.png

    html5 音頻播放圖文實(shí)例

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)