Tone.js icon indicating copy to clipboard operation
Tone.js copied to clipboard

Pitch change does not affect to the html5 video audio.

Open rrehltp opened this issue 1 year ago • 1 comments

Hi there.

I am building a browser extension that plays video in Chrome and Safari. I want to change the pitch of the Video audio in the HTML5 video tag.

Here is some codebase that I implemented.

    // Play the video content to start the audio context.
    this.player.play();

    // Initialize the pitch shift effect and set its window size.
    pitchShift = new Tone.PitchShift().toDestination();
    pitchShift.windowSize = 0.01;

    // Create a media source from the video container and connect it to the pitch shift effect.
    const mediaSource = Tone.context.createMediaElementSource(this.player.container);
    Tone.connect(mediaSource, pitchShift);


   pitchSlider.addEventListener('change', (e) => { 
      pitchShift.pitch = parseFloat(e.target.value);
    });

Fortunately, it works well in Chrome but not in Safari.

Is it possible to change the pitch level in Safari for HTML5 video audio?

Expected behavior

I want to change the video audio pitch using a slider bar.

What I've tried I noticed that Tone.context.state was "suspended", so I implemented the resume() mechanism with video playing. I also activated the auto-play video in Safari and found that Tone.context.state was changed to "running". However, the pitch doesn't change in Safari.

Hoping to hear from you soon. All the best.

rrehltp avatar Jul 12 '24 16:07 rrehltp

+1 hope for ur reply!

yasz avatar Sep 26 '24 04:09 yasz