Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Hide/Remove Playhead And Axis Label from Graph Canvas #464

Open
sagharfrancis20 opened this issue Sep 19, 2022 · 4 comments
Open

Comments

@sagharfrancis20
Copy link

image

I don't want to use the waveform playhead and top axis label on the waveform. Is there any way to achieve it?

I tried giving a playhead a transparent color but it is still showing on waveform now it's very small in width and when I am trying to do the same with the axis but it applies on the bottom also.

@chrisn
Copy link
Member

chrisn commented Sep 19, 2022

This can't really be done at the moment, and would require new options to be added to the library.

@alxpsr
Copy link

alxpsr commented Nov 4, 2022

@sagharfrancis20 regarding playhead you can use workaround

let peaksInstance = // your preaks instance;

peaksInstance
  .views
  .getView('overview')
  ._playheadLayer
  ._playheadLayer.hide()

I suppose this feature is not supported by design, but... it's javascript, so we can use private fields ;D

@BhubanPadun123
Copy link

BhubanPadun123 commented Jul 17, 2023

image

I don't want to use the waveform playhead and top axis label on the waveform. Is there any way to achieve it?

I tried giving a playhead a transparent color but it is still showing on waveform now it's very small in width and when I am trying to do the same with the axis but it applies on the bottom also.

Following code is remove the time frame from the label

import React, { useEffect, useRef } from "react";
import Peaks from "peaks.js";
import "./WaveFormView.css";

function WaveFormView({ audioUrl, audioContentType, waveformDataUrl }) {
  const zoomviewWaveformRef = useRef(null);
  const overviewWaveformRef = useRef(null);
  const audioElementRef = useRef(null);
  let peaks = null;

  useEffect(() => {
    console.log("WaveformView component mount");
    initPeaks();
    return () => {
      console.log("WaveformView will unmound!!!");
      if (peaks) {
        peaks.destroy();
      }
    };
  }, [audioUrl]);

  const initPeaks = () => {
    const audioContext = new AudioContext();
    const options = {
      zoomview: {
        container: zoomviewWaveformRef.current,
        showAxisLabels: false,
      },
      overview: {
        container: overviewWaveformRef.current,
        showAxisLabels: false,
      },
      mediaElement: audioElementRef.current,
      webAudio: {
        audioContext: audioContext,
        multiChannel: false,
      },

      //showPlayheadTime: true,
    };
    Peaks.init(options, (err, peaks) => {
      if (err) {
        console.log("Error===>", err, peaks);
        //return;
      }
      console.log("===>", peaks);
      peaks = peaks;
      onPeaksReady();
    });
  };

  const onPeaksReady = () => {
    console.log("Peaks.js is now ready");
  };

  return (
    <div>
      <div className="zoomview-container" ref={zoomviewWaveformRef}></div>
      <div className="overview-container" ref={overviewWaveformRef}></div>
      <audio controls="controls" ref={audioElementRef}>
        <source src={audioUrl} />
      </audio>
    </div>
  );
}

export default WaveFormView;

@chrisn
Copy link
Member

chrisn commented Sep 3, 2023

ba3c78f adds options to control the top/bottom axis markers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants