音频上传 加audio标签播放
<input type="text" class="audio-input" placeholder="请填写音频链接">
<a href="javascript:;" class="file">选择音频<input id="test1" placeholder=""
accept="audio/*" type="file" ></a>
.file {
position: relative;
display: inline-block;
background: #6098ef;
border-radius: 4px;
padding: 4px 12px;
overflow: hidden;
color: white;
text-decoration: none;
text-indent: 0;
line-height: 20px;
}
.file input {
position: absolute;
font-size: 100px;
right: 0;
top: 0;
opacity: 0;
}
.file:hover {
background: #6098ef;
border-color: #6098ef;
color: white;
text-decoration: none;
}
$('#test').change(function () {
filename = this.files[0];
var formData = new FormData();
formData.append('file', filename);
formData.append('activity_id', act_id);
formData.append('openid', openid);
let size = 0;
if (size > 10000) {
layer.msg('音频不得大于10M')
return false;
} else {
// 音频上传请求接口
var index = layer.load(2, { shade: [0.1, '#fff'] });
$.ajax({
url: api_url3 + "/attachment/fans/uploadVoice",
type: "POST",
processData: false,
contentType: false,
data: formData,
dataType: 'json',
success: function (result) {
result = typeof result === 'string' ? $.parseJSON(result) : result;
console.log(result)
layer.close(index);
if (result.code == 0) {
layer.msg('上传成功!');
} else {
layer.msg(result.msg);
}
}
})
}
});
<!-- 音乐播放器 -->
<div style="display: none;width: 95%;margin: auto;border-radius: 0; " class="ready-player-1" >
<audio class="htmleaf-container" src="" type="audio/mpeg" height="420px;">
</div>
@keyframes spin {
from {
transform: rotateZ(0); }
to {
transform: rotateZ(1turn); } }
.green-audio-player {
min-width: 300px;
height: 56px;
box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.07);
display: flex;
justify-content: space-between;
align-items: center;
padding-left: 10px;
border-radius: 4px;
user-select: none;
background-color: #fff; }
.green-audio-player svg,
.green-audio-player img {
display: block; }
/* .green-audio-player .play-pause-btn {
display: none;
cursor: pointer; } */
.volume {
display: none;
}
.green-audio-player .slider {
flex-grow: 1;
background-color: #d8d8d8;
cursor: pointer;
position: relative; }
.green-audio-player .slider .progress {
background-color: #44bfa3;
border-radius: inherit;
position: absolute;
pointer-events: none; }
.green-audio-player .slider .progress .pin {
height: 16px;
width: 16px;
border-radius: 8px;
background-color: #44bfa3;
position: absolute;
pointer-events: all;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.32); }
.green-audio-player .controls {
font-family: "Roboto", sans-serif;
font-size: 16px;
line-height: 18px;
color: #55606e;
display: flex;
flex-grow: 1;
justify-content: space-between;
align-items: center;
margin-left: 24px;
margin-right: 24px; }
.green-audio-player .controls .controls__slider {
margin-left: 16px;
margin-right: 16px;
border-radius: 2px;
height: 4px; }
.green-audio-player .controls .controls__slider .controls__progress {
width: 0;
height: 100%; }
.green-audio-player .controls .controls__slider .controls__progress .progress__pin {
right: -8px;
top: -6px; }
.green-audio-player .controls span {
cursor: default; }
.green-audio-player .volu