bbc / peaks.js

JavaScript UI component for interacting with audio waveforms
https://waveform.prototyping.bbc.co.uk
GNU Lesser General Public License v3.0
3.16k stars 277 forks source link

[Question] Show/hide playhead #420

Closed rowild closed 2 years ago

rowild commented 2 years ago

In order to toggle the visibility of the wave, the axis and the markers I dig down to those private variables:

this.zoomview = this.peaks.getViews('zoom')

this.zoomview._waveformLayer.hide()
this.zoomview._pointsLayer.hide()
[...]

(This is probably not very nice, since I change private variables directly, but I did not find any other way so far.)

I would like to toggle the visibility of the playhead layer and tried things like these:

this.zoomview._playheadLayer._playheadVisible = true
this.zoomview._playheadLayer._playheadGroup.show() 

("playgroup" can be found in the source code, but not in the documentation. I assume it should not be touched anyway?) This did not work, so I tried to set the colors to transparent:

this.zoomview.playheadColor = 'transparent'
this.zoomview.playheadTextColor = 'transparent'

// Updating reactive objects in Vue would have to be done like this:
// Vue.set(this.peaksOptions, 'zoomview.playheadColor', 'transparent')

This also ignores my wishes completely.

What do I have to do to hide/show the playhead? (I would like to implement this functionality in both views.)

Thank you!

rowild commented 2 years ago

...damn, 5 minutes too early. Found my error (forgot to switch a boolean variable, so the state was always true):

this.zoomview._playheadLayer._playheadGroup.show() does exactely what I need.

Sorry for bothering!