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

muted property is not a boolean #141

Open
ZKillou opened this issue Jul 23, 2024 · 5 comments
Open

muted property is not a boolean #141

ZKillou opened this issue Jul 23, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@ZKillou
Copy link

ZKillou commented Jul 23, 2024

Describe the bug
When using the property muted returned by useGlobalAudioPlayer, the value of muted is not a boolean but an object (see below)

image

Condensed version of my component code:

const { load, mute, muted } = useGlobalAudioPlayer();
useEffect(() => {
  load(music.path, { html5: true, autoplay: true, onend: () => {/* function */} });
}, [music, load]);
const onMute = () => {
  console.log("onMute", muted);
  mute(!muted);
};
return (<VolumeIcon onClick={onMute} className="cursor-pointer" size={34} />);

To Reproduce
Steps to reproduce the behavior:

  1. Call useGlobalAudioPlayer
  2. Log the value of muted

Expected behavior
muted should be a boolean.

Environment (please complete the following information):

  • Browser/ browser version: Edge 126.0.2592.113
  • Library version: 2.2.0
  • React version: 18.3.1 (Next 14.2.3)
  • Node version: 20.13.1
@E-Kuerschner
Copy link
Owner

@ZKillou interesting it looks like this muted variable is referencing the Howl instance - would you be interested in taking a stab at the fix? I may not be able to get to this for some time due to other priorities but I can certainly review a PR or two and get the changes published for you!

@uncvrd
Copy link
Contributor

uncvrd commented Nov 19, 2024

@E-Kuerschner @ZKillou hey guys, I hit this as well so I checked it out. it looks like this is because the howler.js mute function returns the howler instance (i.e. this/self) instead of the value of the mute

https://github.com/goldfire/howler.js/blob/a2a47933f1ffcee659e4939a65e075fa7f25706c/src/howler.core.js#L1165

and you're calling this method to get the value

muted: howl.mute(),

Some of the other methods return the value or the instance of Howler depending on how many args you pass to the function (like volume or rate) which is why those work, but looks like mute does not return the value and only the instance and is only tracked as a private property as _muted.

So maybe the muted property should just be removed since that's not something that's publicly exposed from Howler anyways?

@E-Kuerschner
Copy link
Owner

@uncvrd great observation! That always puzzled me about the Howler methods 🤔 I wonder if we remove it if we should bump a major version since it will be a breaking change. If that's the case I might consider a few other API changes and a React upgrade when I have some time over the holidays

@uncvrd
Copy link
Contributor

uncvrd commented Nov 22, 2024

@E-Kuerschner yea it def took me a while staring at the howler code to figure that one out! It probably would be best to make it a major version change...that being said, since the property never worked in the first place, I can't imagine it would break any existing applications anyways 😅

@E-Kuerschner
Copy link
Owner

@uncvrd I have some time set aside to work on this project in a couple of weeks. It will likely lead to a major version bump and I can cut this method out then

@E-Kuerschner E-Kuerschner added the bug Something isn't working label Dec 20, 2024
@E-Kuerschner E-Kuerschner added this to the Holiday 2024 Work milestone Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants