当前位置: 首页 > wzjs >正文

家教补习中心网站建设北京商场开门吗

家教补习中心网站建设,北京商场开门吗,onedrive结合WordPress,wordpress 发文章 慢说明: 用vue做一款录音系统 1.点击按钮,开始录制音频 2.录制过程中,可以暂停和停止录制 有时长显示 3.点击停止录制 可以保存音频,保存在本地 4.找到刚刚保存的音频路径,可以点击播放 ,需要显示音频总时…

说明:
用vue做一款录音系统

1.点击按钮,开始录制音频

2.录制过程中,可以暂停和停止录制 有时长显示

3.点击停止录制 可以保存音频,保存在本地

4.找到刚刚保存的音频路径,可以点击播放 ,需要显示音频总时长

5.可以下载音频

效果图:
在这里插入图片描述

step1:

<template><div class="container"><h1>录音系统</h1><!-- 录音控制 --><div class="controls"><button @click="toggleRecording" :disabled="isPaused">{{ isRecording ? '正在录音...' : '开始录音' }}</button><button @click="togglePause" :disabled="!isRecording">{{ isPaused ? '继续录音' : '暂停录音' }}</button><button @click="stopRecording" :disabled="!isRecording && !isPaused">停止并保存</button></div><!-- 录音时长 --><div class="duration">当前时长: {{ formatTime(currentDuration) }}</div><!-- 保存的录音 --><div class="recordings" v-if="currentRecording"><h2>保存的录音</h2><div class="audio-item"><audio ref="audioPlayer" controls @loadedmetadata="updateDuration"></audio><div><button @click="playRecording">播放</button><span>时长: {{ formatTime(currentRecording.duration) }}</span><a :href="currentRecording.url" download="recording.webm">下载</a><button @click="deleteRecording" class="delete-btn">删除</button></div></div></div></div>
</template><script>
export default {data() {return {isRecording: false,isPaused: false,currentDuration: 0,timer: null,mediaRecorder: null,audioChunks: [],currentRecording: null};},methods: {async toggleRecording() {if (!this.isRecording) {try {const stream = await navigator.mediaDevices.getUserMedia({ audio: true });this.mediaRecorder = new MediaRecorder(stream);this.mediaRecorder.ondataavailable = event => {this.audioChunks.push(event.data);};this.mediaRecorder.onstop = () => {const audioBlob = new Blob(this.audioChunks, { type: 'audio/webm' });const audioUrl = URL.createObjectURL(audioBlob);// 只保留最新录音this.currentRecording = {url: audioUrl,duration: this.currentDuration};this.audioChunks = [];stream.getTracks().forEach(track => track.stop());};this.mediaRecorder.start();this.startTimer();this.isRecording = true;this.isPaused = false;} catch (err) {console.error('无法访问麦克风:', err);}}},// 新增删除方法deleteRecording() {if (this.currentRecording) {URL.revokeObjectURL(this.currentRecording.url);this.currentRecording = null;}},togglePause() {if (this.isPaused) {this.mediaRecorder.resume();this.startTimer();} else {this.mediaRecorder.pause();clearInterval(this.timer);}this.isPaused = !this.isPaused;},stopRecording() {this.mediaRecorder.stop();clearInterval(this.timer);this.isRecording = false;this.isPaused = false;this.currentDuration = 0;},startTimer() {this.timer = setInterval(() => {this.currentDuration++;}, 1000);},playRecording() {const audioElement = this.$refs.audioPlayer;audioElement.src = this.currentRecording.url;audioElement.play();},updateDuration() {const audioElement = this.$refs.audioPlayer;if (this.currentRecording) {this.currentRecording.duration = Math.round(audioElement.duration);}},formatTime(seconds) {const mins = Math.floor(seconds / 60);const secs = seconds % 60;return `${mins}:${secs.toString().padStart(2, '0')}`;}},beforeUnmount() {clearInterval(this.timer);if (this.currentRecording) {URL.revokeObjectURL(this.currentRecording.url);}}
};
</script><style>
/* 新增删除按钮样式 */
.delete-btn {background-color: #ff4444;margin-left: 10px;
}.container {max-width: 600px;margin: 0 auto;padding: 20px;
}.controls {margin: 20px 0;display: flex;gap: 10px;
}.audio-item {margin: 10px 0;padding: 10px;border: 1px solid #ddd;border-radius: 4px;
}.duration {font-size: 1.2em;margin: 10px 0;
}button {padding: 8px 16px;cursor: pointer;background-color: #4CAF50;color: white;border: none;border-radius: 4px;
}button:disabled {background-color: #cccccc;cursor: not-allowed;
}a {margin-left: 10px;color: #2196F3;text-decoration: none;
}</style>

end

http://www.dtcms.com/wzjs/820967.html

相关文章:

  • 福州网站运营宜家家居官网网上商城app
  • 怎么做类似站酷的网站大连网站快速排名
  • 高端做网站公司北京正规网站建设公司哪家好
  • 西宁电商网站制作公司手机网站域名查询
  • 廊坊网站建设代理网站建设
  • 网络营销的专业网站实验仪器销信应做何网站
  • 免费刷赞网站推广免费星子网易云
  • 网站科技感颜色温州网络问政平台
  • 需要做网站的企业职业生涯规划大赛心得
  • 微信 app 微网站 整合企业策划是做什么的
  • 上海网站建设百度推广公司wordpress生成速度显示代码
  • wordpress文章同步到微博网站的排名优化怎么做
  • 湘潭大学迎新自助网站企业简介封面设计
  • 网站开发常见模块东莞网站快速排名优化
  • 东莞市手机网站建设网络营销方案撰写的内容与要求
  • 微信公众号免费模板素材网站网络推广怎么找客户资源
  • 哪家公司做网站便宜seo公司seo教程
  • 营销型网站哪家好wordpress网站制作app
  • 镇江网站定制wordpress用oss图床
  • yahoo怎么提交网站做网站用phpcms还是
  • 华为云网站定制宿迁网站开发
  • 关于建设校园网站申请沈阳网络seo公司
  • 具有价值的做网站哪个做企业网站
  • 做物流网站电话wordpress如何做云盘搜索
  • 原型样网站wordpress 更改用户名密码
  • 南庄建网站湖北民族建设集团网站
  • 临汾花果街网站建设在线设计网站排名
  • 微企业网站模板免费网页设计模板html代码教程图片
  • 网站建设和媒体渠道服装毕业设计代做网站
  • 江西省建设监督网站免费seo营销软件