本文转自:新华网00:0000:00详情收起00:0000:00// 音频播放var a...|元宇宙数字人、AI画屏......沉浸式探馆西洽会 “渝”见未来新生活
本文转自:新华网00:0000:00详情收起00:0000:00//音频播放varaudioPlayer=document.querySelector('.audio-box');//varplayPause=audioPlayer.querySelector('#playPause');varplaypauseBtn=audioPlayer.querySelector('.audio-bottom-control-play');varplaypauseBtnSmall=audioPlayer.querySelector('.audio-left');//varloading=audioPlayer.querySelector('.loading');varprogress=audioPlayer.querySelector('.progress');varprogressSmall=audioPlayer.querySelector('.progresssmall');varsliders=audioPlayer.querySelectorAll('.slider');varvolumeBtn=audioPlayer.querySelector('.volume-btn');varvolumeControls=audioPlayer.querySelector('.volume-controls');varvolumeProgress=volumeControls.querySelector('.slider.progress');varplayer=audioPlayer.querySelector('#audio-resource');varcurrentTime=audioPlayer.querySelector('.audio-bottom-time-now');varcurrentTimeSmall=audioPlayer.querySelector('.audio-time-now');vartotalTime=audioPlayer.querySelector('.audio-bottom-time-all');vartotalTimeSmall=audioPlayer.querySelector('.audio-time-all');varrefreshbtn=audioPlayer.querySelector('.audio-bottom-control-refresh');//varspeaker=audioPlayer.querySelector('#speaker');vardraggableClasses=['pin'];varcurrentlyDragged=null;window.addEventListener('mousedown',function(event){if(!isDraggable(event.target))returnfalse;currentlyDragged=event.target;varhandleMethod=currentlyDragged.dataset.method;this.addEventListener('mousemove',window[handleMethod],false);window.addEventListener('mouseup',function(){currentlyDragged=false;window.removeEventListener('mousemove',window[handleMethod],false);},false);});playpauseBtn.addEventListener('click',togglePlay);playpauseBtnSmall.addEventListener('click',togglePlay);player.addEventListener('timeupdate',updateProgress);refreshbtn.addEventListener('click',refreshAll);player.addEventListener('volumechange',updateVolume);player.addEventListener('loadedmetadata',function(){totalTime.textContent=formatTime(player.duration);totalTimeSmall.textContent=formatTime(player.duration);});player.addEventListener('canplay',makePlay);player.addEventListener('ended',function(){//playPause.attributes.d.value="";//player.currentTime=0;$('.audio-left,.audio-yuan').addClass('pause');$('.audio-left,.audio-yuan').removeClass('play');$('.audio-pointer').addClass('stopplaydeg');$('.audio-pointer').removeClass('playdeg');$('.audio-bottom-control-play').removeClass('audio-bottom-control-ing');$('.audio-bottom-control-play').addClass('audio-bottom-control-stop');});volumeBtn.addEventListener('click',function(){volumeBtn.classList.toggle('open');volumeControls.classList.toggle('hidden');});//window.addEventListener('resize',directionAware);sliders.forEach(function(slider){varpin=slider.querySelector('.pin');slider.addEventListener('click',window[pin.dataset.method]);});//directionAware();functionisDraggable(el){varcanDrag=false;varclasses=Array.from(el.classList);draggableClasses.forEach(function(draggable){if(classes.indexOf(draggable)!==-1)canDrag=true;});returncanDrag;}functioninRange(event){varrangeBox=getRangeBox(event);varrect=rangeBox.getBoundingClientRect();vardirection=rangeBox.dataset.direction;if(direction=='horizontal'){varmin=rangeBox.offsetLeft;varmax=min+rangeBox.offsetWidth;if(event.clientX<min||event.clientX>max)returnfalse;}else{varmin=rect.top;varmax=min+rangeBox.offsetHeight;if(event.clientY<min||event.clientY>max)returnfalse;}returntrue;}functionupdateProgress(){varcurrent=player.currentTime;varpercent=current/player.duration*100;progress.style.width=percent+'%';progressSmall.style.width=percent+'%';currentTime.textContent=formatTime(current);currentTimeSmall.textContent=formatTime(current);}functionupdateVolume(){volumeProgress.style.height=player.volume*100+'%';if(player.volume>=0.5){//speaker.attributes.d.value='';}elseif(player.volume<0.5&&player.volume>0.05){//speaker.attributes.d.value='';}elseif(player.volume<=0.05){//speaker.attributes.d.value='';}}functiongetRangeBox(event){varrangeBox=event.target;varel=currentlyDragged;if(event.type=='click'&&isDraggable(event.target)){rangeBox=event.target.parentElement.parentElement;}if(event.type=='mousemove'){rangeBox=el.parentElement.parentElement;}returnrangeBox;}functiongetCoefficient(event){varslider=getRangeBox(event);varrect=slider.getBoundingClientRect();varK=0;if(slider.dataset.direction=='horizontal'){varoffsetX=event.clientX-slider.offsetLeft;varwidth=slider.clientWidth;K=offsetX/width;}elseif(slider.dataset.direction=='vertical'){varheight=slider.clientHeight;varoffsetY=event.clientY-rect.top;K=1-offsetY/height;}returnK;}functionrewind(event){if(inRange(event)){player.currentTime=player.duration*getCoefficient(event);}}functionchangeVolume(event){if(inRange(event)){player.volume=getCoefficient(event);}}functionformatTime(time){varmin=Math.floor(time/60);varsec=Math.floor(time%60);return(min<10?'0'+min:min)+':'+(sec<10?'0'+sec:sec);}functiontogglePlay(){if(player.paused){//playPause.attributes.d.value="";$('.audio-left,.audio-yuan').addClass('play');$('.audio-left,.audio-yuan').removeClass('pause');$('.audio-pointer').addClass('playdeg');$('.audio-pointer').removeClass('stopplaydeg');$('.audio-bottom-control-play').removeClass('audio-bottom-control-stop');$('.audio-bottom-control-play').addClass('audio-bottom-control-ing');player.play();}else{//playPause.attributes.d.value="";$('.audio-left,.audio-yuan').addClass('pause');$('.audio-left,.audio-yuan').removeClass('play');$('.audio-pointer').addClass('stopplaydeg');$('.audio-pointer').removeClass('playdeg');$('.audio-bottom-control-play').removeClass('audio-bottom-control-ing');$('.audio-bottom-control-play').addClass('audio-bottom-control-stop');player.pause();}}functionmakePlay(){//playpauseBtn.style.display='block';//playpauseBtnSmall.style.display='block';//loading.style.display='none';}//functiondirectionAware(){//if(window.innerHeight<250){//volumeControls.style.bottom='-54px';//volumeControls.style.left='54px';//}elseif(audioPlayer.offsetTop<154){//volumeControls.style.bottom='-164px';//volumeControls.style.left='-3px';//}else{//volumeControls.style.bottom='52px';//volumeControls.style.left='-3px';//}//}functionrefreshAll(){player.currentTime=0;progress.style.width=0;progressSmall.style.width=0;currentTime.textContent='00:00';currentTimeSmall.textContent='00:00';}
那天 , 朋友约我一起去逛第四届中国西部国际投资贸易洽谈会 ,
- ! 今日大暑,聊聊高温天那些事儿……
- 本文转自:闽东日报1234编辑:蓝青审核:周邦在| 最高温43.■闽东日报7月23日版面速览(今日4版)
- 本文转自:新华网问天实验舱“问天”在即中国空间站建造任务即将迎来一个重大节点问天|问天密码,中国,这样解开
- 本文转自:人民网23日下午|长征五号B火箭被发射塔架包裹 问天实验舱静待发射
- 本文转自:央广网视频:龙丹 肖鸿瑶央广网重庆7月23日消息(记者白刁尹 实习生刘禹汐 凌...|“科技范儿”十足 西洽会一大波新产品亮相
- 本文转自:劳动报经典计算机需要100年才能破译的密码|量子计算机或将在5-10年后诞生
- 本文转自:淄博日报口淄博日报/淄博晚报/博览新闻记者耿雪为加力推动淄博市MCN产业发展|“淄博百名城市文化达人”培育计划等你来
- 本文转自:江苏新闻经过近十个月的技术升级改造|方便快捷 7月23日起常州可“刷脸”乘地铁
- 本文转自:央广网7月21日|中科院新疆天文台在墨玉县开展天文科普知识活动
- 本文转自:中国电子报近日|中国电科45所湿法设备进入国内主流8英寸芯片产线