Since 0 evaluates to false (1 is true) why in God's name did you make media autoplay options like media.autoplay.default = 0 [0=Allowed, 1=Blocked, 2=Prompt]?
If someone could explain the developer/user/common sense logic behind this implementation?
Alle antwoorden (4)
True and False is a 'toggle' for a pref. When the value has more that 2 choices or settings "logic" goes out the window.
Also, many times when default is used by Mozilla in the preference name the value of 0 or 1 is a double negative. We have seen a half-dozen or more prefs set up in that manner over the years.
Thanks for the answer but it still looks like some made-up excuse that leads to poor user experience, which requires you to search the state you need instead of just toggling it the way it's natural to be. It gets even worse when highly respected company like Mozilla polishing up things to make it look like it's right. A better solution could involve not using an integer f.ex. but rather some self-explanatory states like ['Allowed', 'Blocked', 'Prompt'] - there will not be that much people that will care what's exactly happening under the hood in this case.
It is easier to check in code for a zero value. Such decisions are usually based on making coding this as easy as possible. In this case zero means a default that allows to play media and nothing is blocked. The not zero state means either block or prompt, so only for a not zero state you need to take further action.
OK, that's a valid statement since an integer comparison will be more efficient, comes with lower cost and applies perfectly for this programming case but then again my initial question was why an user app would implement something that misleading. Seriously the states could have been [0: 'Blocked', 1: 'Allowed', ...] and still the evaluation would be the same - 'if not 1 state...' with less ambiguity - just tweak it and go. Still thanks guys for your answers!