Commit 5b21dd65 authored by liwei's avatar liwei

添加了遗漏的字段,补了参数校验

parent 6eee0911
...@@ -812,7 +812,7 @@ export default defineComponent({ ...@@ -812,7 +812,7 @@ export default defineComponent({
audioTitle: '', audioTitle: '',
detailOpen: false, detailOpen: false,
audioId: '', audioId: '',
AudioUrlList: [], AudioUrlIdList: [],
audioList: [], audioList: [],
mapBackPostion: [{ lan: "38.854713", lon: "117.481685" }], mapBackPostion: [{ lan: "38.854713", lon: "117.481685" }],
fullscreenLoading: false, fullscreenLoading: false,
...@@ -3338,85 +3338,87 @@ export default defineComponent({ ...@@ -3338,85 +3338,87 @@ export default defineComponent({
}, },
/** 获取音频*/ /** 获取音频*/
playAudio(id) { playAudio(id) {
let audioUrl = this.audioList.find(item => item.businessId === id).audioUrl if (this.audioList.length >0 ) {
if(this.audioStatus !== false){ let audioUrl = this.audioList.find(item => item.businessId === id).audioUrl
console.log("当前播放的音频zt",this.audioStatus) if (this.audioStatus !== false) {
console.log("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-") console.log("当前播放的音频zt", this.audioStatus)
return console.log("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
} return
this.audioStatus = true
// 如果有波形图,则摧毁现有波形图,渲染新的波形图
console.log('wavesurfer.value',this.wavesurfer)
if (this.wavesurfer) {
this.wavesurfer.destroy();
}
const url = getVideoUrl(audioUrl);
fetch(url).then(response => {
if (!response.ok) {
throw new Error('Network response was not ok ' + response.statusText);
} }
return response.blob(); // 将响应转换为blob this.audioStatus = true
}).then(res => { // 如果有波形图,则摧毁现有波形图,渲染新的波形图
this.audioTitle = this.audioList.find(item => item.businessId === id).deviceName console.log('wavesurfer.value', this.wavesurfer)
const audioSrc = URL.createObjectURL(new Blob([res])); if (this.wavesurfer) {
// 播放器和波形图赋值 this.wavesurfer.destroy();
this.$refs.audioPlayer.src = audioSrc; }
// 创建 WaveSurfer 实例 const url = getVideoUrl(audioUrl);
this.wavesurfer = WaveSurfer.create({ fetch(url).then(response => {
container: this.$refs.waveform, if (!response.ok) {
// 未播放波形的颜色 throw new Error('Network response was not ok ' + response.statusText);
waveColor: 'violet', }
// 已播放波形的颜色 return response.blob(); // 将响应转换为blob
progressColor: 'purple', }).then(res => {
// 波形图的高度,单位为px this.audioTitle = this.audioList.find(item => item.businessId === id).deviceName
height: 150, const audioSrc = URL.createObjectURL(new Blob([res]));
// 波形条的宽度 // 播放器和波形图赋值
barWidth: 2, this.$refs.audioPlayer.src = audioSrc;
responsive: true, // 创建 WaveSurfer 实例
normalize: true, this.wavesurfer = WaveSurfer.create({
plugins: [ container: this.$refs.waveform,
// 区域选择插件 // 未播放波形的颜色
RegionsPlugin.create( waveColor: 'violet',
{ // 已播放波形的颜色
regionsMinLength: 2, progressColor: 'purple',
regions: [ // 波形图的高度,单位为px
{ height: 150,
start: 5, // 波形条的宽度
end: 15, barWidth: 2,
loop: false, responsive: true,
color: 'hsla(200, 50%, 70%, 0.4)', normalize: true,
minLength: 1, plugins: [
// 区域选择插件
RegionsPlugin.create(
{
regionsMinLength: 2,
regions: [
{
start: 5,
end: 15,
loop: false,
color: 'hsla(200, 50%, 70%, 0.4)',
minLength: 1,
}
],
// 拖动选择
dragSelection: {
slop: 5
} }
],
// 拖动选择
dragSelection: {
slop: 5
} }
} ),
), // 时间轴插件
// 时间轴插件 TimelinePlugin.create({
TimelinePlugin.create({ container: this.$refs.timeline,
container: this.$refs.timeline, fontSize: 14,
fontSize: 14, //主要时间标签颜色
//主要时间标签颜色 primaryColor: "#9191a5",
primaryColor: "#9191a5", //主要时间文字颜色
//主要时间文字颜色 primaryFontColor: "#9191a5",
primaryFontColor: "#9191a5", //次要时间标签颜色
//次要时间标签颜色 secondaryColor: "#9191a5",
secondaryColor: "#9191a5", //次要时间文字颜色
//次要时间文字颜色 secondaryFontColor: "#9191a5",
secondaryFontColor: "#9191a5", })
}) ]
] });
// 使用 WaveSurfer 加载音频流
this.wavesurfer.load(audioSrc);
this.audioStatus = false
this.waveformLoading = false
}).catch(error => {
console.error('There was a problem with the fetch operation:', error);
}); });
// 使用 WaveSurfer 加载音频流 }
this.wavesurfer.load(audioSrc);
this.audioStatus = false
this.waveformLoading = false
}).catch(error => {
console.error('There was a problem with the fetch operation:', error);
});
}, },
/** 播放区域*/ /** 播放区域*/
playAudioRegion() { playAudioRegion() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment