File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ const maskWidth = ref<number>(0)
111111
112112function drawWaveMask(): void | undefined {
113113 if (! audioController ._playing ) return
114+
114115 requestAnimationFrame (drawWaveMask )
115116 currentTime .value = audioController ._currentTime
116117 maskWidth .value =
@@ -127,6 +128,7 @@ function mouseMoveHandler(e: any): void {
127128
128129function clickHandler(): void {
129130 if (! ready .value || ! props .interact ) return
131+
130132 maskWidth .value = moveX .value
131133 const pickedTime: number =
132134 (moveX .value / wave ._canvas .width ) * audioController ._audioDuration
@@ -157,13 +159,14 @@ function pause(): void {
157159}
158160
159161function finish(): void {
162+ audioController .finish ()
163+ emits (' onPlay' , false )
160164 emits (' onFinish' , true )
161165}
162166
163167function watchIsFinish(): void {
164168 watchEffect (() => {
165- if (currentTime .value < audioController ._audioDuration ) return
166- pause ()
169+ if (currentTime .value <= audioController ._audioDuration ) return
167170 finish ()
168171 })
169172}
Original file line number Diff line number Diff line change @@ -48,8 +48,6 @@ export default class WebAudioController extends WebAudio {
4848 }
4949
5050 public pick ( pickedTime : number ) : void {
51- if ( pickedTime <= 0 ) pickedTime = 0
52- if ( pickedTime >= this . _audioDuration ) pickedTime = this . _audioDuration
5351 this . pickAt = pickedTime
5452 if ( ! this . playing ) return
5553 this . stopSource ( )
@@ -61,6 +59,11 @@ export default class WebAudioController extends WebAudio {
6159 this . play ( )
6260 }
6361
62+ public finish ( ) : void {
63+ this . pauseAt = 0
64+ this . stop ( )
65+ }
66+
6467 private stop ( ) : void {
6568 this . stopSource ( )
6669 this . initializeState ( )
You can’t perform that action at this time.
0 commit comments