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

Enable compatibility with the new Architecture and React Native 0.76 #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hrastnik
Copy link

@hrastnik hrastnik commented Nov 24, 2024

The setMuteListenerInterval method was unused and it's body was not defined which caused a crash when TurboModules are enabled.

Additionally I've explicitly re-exported the default export from native.ts in the index.ts file as calling methods on the default export wasn't working on the new architecture.

@hrastnik hrastnik changed the title Remove unused setMuteListenerInterval method and export VolumeManager as default Enable compatibility with the new Architecture and React Native 0.76 Nov 25, 2024
@hrastnik
Copy link
Author

Can you merge this then @hirbod? It's a confirmed fix in #45

@hirbod
Copy link
Owner

hirbod commented Nov 29, 2024

I'll take care of this library this weekend, test everything and address other problems. Will have a release by Sunday or Monday

@Thenlie
Copy link

Thenlie commented Dec 11, 2024

Thank you both for your work on this repository!

I just wanted to chime in to say the code change here has resolved my crash on RN 76. I applied via patch-package and did not need any additional code change. My use of volume-manager is quite small, so wanted to share the snippet I have that was causing the crash, which has been resolved by this PR.

  const muteUnmuteVideo = useCallback(
    (result: VolumeResult) => {
      if (result.volume > 0 && muted) {
        setMuted(false);
      } else if (result.volume === 0 && !muted) {
        setMuted(true);
      }
    },
    [setMuted, muted]
  );

  useEffect(() => {
    VolumeManager.enableInSilenceMode(true);
    const volumeListener = VolumeManager.addVolumeListener(muteUnmuteVideo);
    return () => volumeListener.remove();
  }, [muteUnmuteVideo]);

@hirbod
Copy link
Owner

hirbod commented Dec 11, 2024

Sorry folks, late to the party, real life is sometimes very demanding. I'll get this fixed soon

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

Successfully merging this pull request may close these issues.

3 participants