首页 | 长发 | 娱乐 | 健康 | 美妆 |

| 生活 | 知识 | 儿童 | 老年 | 男性 | 女性 | 运动 | 保健 | 饮食 | 预防 | 科普 | 疾病 |

亿缕阳光丨医者本能

本文转自:人民视频00:0000:00详请收起00:0000:00// 音频播放var audioPlayer = document.querySelector('.audio-box');// var playPause = audioPlayer.querySelector('#playPause');var playpauseBtn = audioPlayer.querySelector('.audio-bottom-control-play');var playpauseBtnSmall = audioPlayer.querySelector('.audio-left');// var loading = audioPlayer.querySelector('.loading');var progress = audioPlayer.querySelector('.progress');var progressSmall = audioPlayer.querySelector('.progresssmall');var sliders = audioPlayer.querySelectorAll('.slider');var volumeBtn = audioPlayer.querySelector('.volume-btn');var volumeControls = audioPlayer.querySelector('.volume-controls');var volumeProgress = volumeControls.querySelector('.slider .progress');var player = audioPlayer.querySelector('#audio-resource');var currentTime = audioPlayer.querySelector('.audio-bottom-time-now');var currentTimeSmall = audioPlayer.querySelector('.audio-time-now');var totalTime = audioPlayer.querySelector('.audio-bottom-time-all');var totalTimeSmall = audioPlayer.querySelector('.audio-time-all');var refreshbtn = audioPlayer.querySelector('.audio-bottom-control-refresh');// var speaker = audioPlayer.querySelector('#speaker');var draggableClasses = ['pin'];var currentlyDragged = null;window.addEventListener('mousedown', function (event) {if (!isDraggable(event.target)) return false;currentlyDragged = event.target;var handleMethod = 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) {var pin = slider.querySelector('.pin');slider.addEventListener('click', window[pin.dataset.method]);});// directionAware();function isDraggable(el) {var canDrag = false;var classes = Array.from(el.classList);draggableClasses.forEach(function (draggable) {if (classes.indexOf(draggable) !== -1) canDrag = true;});return canDrag;}function inRange(event) {var rangeBox = getRangeBox(event);var rect = rangeBox.getBoundingClientRect();var direction = rangeBox.dataset.direction;if (direction == 'horizontal') {var min = rangeBox.offsetLeft;var max = min + rangeBox.offsetWidth;if (event.clientX < min || event.clientX > max) return false;} else {var min = rect.top;var max = min + rangeBox.offsetHeight;if (event.clientY < min || event.clientY > max) return false;}return true;}function updateProgress() {var current = player.currentTime;var percent = current / player.duration * 100;progress.style.width = percent + '%';progressSmall.style.width = percent + '%';currentTime.textContent = formatTime(current);currentTimeSmall.textContent = formatTime(current);}function updateVolume() {volumeProgress.style.height = player.volume * 100 + '%';if (player.volume >= 0.5) {// speaker.attributes.d.value = '';} else if (player.volume < 0.5 && player.volume > 0.05) {// speaker.attributes.d.value = '';} else if (player.volume <= 0.05) {// speaker.attributes.d.value = '';}}function getRangeBox(event) {var rangeBox = event.target;var el = currentlyDragged;if (event.type == 'click' && isDraggable(event.target)) {rangeBox = event.target.parentElement.parentElement;}if (event.type == 'mousemove') {rangeBox = el.parentElement.parentElement;}return rangeBox;}function getCoefficient(event) {var slider = getRangeBox(event);var rect = slider.getBoundingClientRect();var K = 0;if (slider.dataset.direction == 'horizontal') {var offsetX = event.clientX - slider.offsetLeft;var width = slider.clientWidth;K = offsetX / width;} else if (slider.dataset.direction == 'vertical') {var height = slider.clientHeight;var offsetY = event.clientY - rect.top;K = 1 - offsetY / height;}return K;}function rewind(event) {if (inRange(event)) {player.currentTime = player.duration * getCoefficient(event);}}function changeVolume(event) {if (inRange(event)) {player.volume = getCoefficient(event);}}function formatTime(time) {var min = Math.floor(time / 60);var sec = Math.floor(time % 60);return (min < 10 ? '0' + min : min) + ':' + (sec < 10 ? '0' + sec : sec);}function togglePlay() {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();}}function makePlay() {// playpauseBtn.style.display = 'block';// playpauseBtnSmall.style.display = 'block';// loading.style.display = 'none';}// function directionAware() {//if (window.innerHeight < 250) {// volumeControls.style.bottom = '-54px';// volumeControls.style.left = '54px';//} else if (audioPlayer.offsetTop < 154) {// volumeControls.style.bottom = '-164px';// volumeControls.style.left = '-3px';//} else {// volumeControls.style.bottom = '52px';// volumeControls.style.left = '-3px';//}// }function refreshAll() {player.currentTime = 0;progress.style.width = 0;progressSmall.style.width = 0;currentTime.textContent = '00:00';currentTimeSmall.textContent = '00:00';}

不着白衣,亦是“天使”。

编辑:吴方舟

  • 上一篇:宁武:金莲花要茶产业助农增收
  • 下一篇:没有了
  • 相关文章
    热点内容