|
@@ -58,6 +58,7 @@ import audioBga2 from "./images/rightCloud.json";
|
|
|
import videobg from "./images/videobg.png";
|
|
|
import playProgressData from "./playCreation/playProgress"
|
|
|
import Loading from './loading';
|
|
|
+import { generateMixedData } from "./audioVisualDraw"
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'creation-detail',
|
|
@@ -271,10 +272,10 @@ export default defineComponent({
|
|
|
canvasDom.width = width
|
|
|
canvasDom.height = height
|
|
|
// audio
|
|
|
- let audioCtx : AudioContext | null = null
|
|
|
- let analyser : AnalyserNode | null = null
|
|
|
- let source : MediaElementAudioSourceNode | null = null
|
|
|
- const dataArray = new Uint8Array(fftSize / 2)
|
|
|
+ // let audioCtx : AudioContext | null = null
|
|
|
+ // let analyser : AnalyserNode | null = null
|
|
|
+ // let source : MediaElementAudioSourceNode | null = null
|
|
|
+ // const dataArray = new Uint8Array(fftSize / 2)
|
|
|
const draw = (data: Uint8Array, ctx: CanvasRenderingContext2D, { lineGap, canvWidth, canvHeight, canvFillColor, lineColor }: propsType) => {
|
|
|
if (!ctx) return
|
|
|
const w = canvWidth
|
|
@@ -321,8 +322,8 @@ export default defineComponent({
|
|
|
}
|
|
|
const requestAnimationFrameFun = () => {
|
|
|
requestAnimationFrame(() => {
|
|
|
- analyser?.getByteFrequencyData(dataArray)
|
|
|
- draw(dataArray, canvasCtx, {
|
|
|
+ //analyser?.getByteFrequencyData(dataArray)
|
|
|
+ draw(generateMixedData(48), canvasCtx, {
|
|
|
lineGap: 2,
|
|
|
canvWidth: width,
|
|
|
canvHeight: height,
|
|
@@ -336,14 +337,14 @@ export default defineComponent({
|
|
|
}
|
|
|
let isPause = true
|
|
|
const playVisualDraw = () => {
|
|
|
- if (!audioCtx) {
|
|
|
- audioCtx = new AudioContext()
|
|
|
- source = audioCtx.createMediaElementSource(audioDom)
|
|
|
- analyser = audioCtx.createAnalyser()
|
|
|
- analyser.fftSize = fftSize
|
|
|
- source?.connect(analyser)
|
|
|
- analyser.connect(audioCtx.destination)
|
|
|
- }
|
|
|
+ // if (!audioCtx) {
|
|
|
+ // audioCtx = new AudioContext()
|
|
|
+ // source = audioCtx.createMediaElementSource(audioDom)
|
|
|
+ // analyser = audioCtx.createAnalyser()
|
|
|
+ // analyser.fftSize = fftSize
|
|
|
+ // source?.connect(analyser)
|
|
|
+ // analyser.connect(audioCtx.destination)
|
|
|
+ // }
|
|
|
//audioCtx.resume() // 重新更新状态 加了暂停和恢复音频音质发生了变化 所以这里取消了
|
|
|
isPause = false
|
|
|
requestAnimationFrameFun()
|