Skip to content

Commit bf5e479

Browse files
committed
Added onPlay and onPause parameters to initialization
1 parent a63fa1b commit bf5e479

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/js/app/main.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ function CodeKeyframes(args){
88
this.label = args.label
99
this.autoplay = args.autoplay || false
1010
this.onCanPlay = args.onCanPlay || function(){}
11+
this.onPause = args.onPause || function(){}
12+
this.onPlay = args.onPlay || function(){}
1113

1214
this.activeRegion = null
1315
this.skipLength = 1
@@ -502,6 +504,16 @@ function CodeKeyframes(args){
502504

503505
this.wavesurfer.load(this.audioPath)
504506

507+
// run function passed to codekeyframes on init
508+
this.wavesurfer.on('pause', () => {
509+
this.onPause()
510+
})
511+
512+
// run function passed to codekeyframes on init
513+
this.wavesurfer.on('play', () => {
514+
this.onPlay()
515+
})
516+
505517
this.wavesurfer.on('ready', (e) =>{
506518
this.wavesurfer.zoom(this.zoom)
507519

@@ -546,4 +558,5 @@ function CodeKeyframes(args){
546558

547559
}
548560
})
561+
549562
}

0 commit comments

Comments
 (0)