class MusicControl {

    Node createMuteSwitchButton(final Slider volumeSlider) {
        final Button muteButton = createButton("mute", SPEAKER_ICON, "mute", ICON_SIZE / 2d);
        final Button unmuteButton = createButton("unmute", MUTE_ICON, "unmute", ICON_SIZE / 2d);

        setUpSwitchButton(muteButton);
        setUpSwitchButton(unmuteButton);

        final boolean muted = volumeSlider.getValue() == 0;
        muteButton.setVisible(!muted);
        unmuteButton.setVisible(muted);

        if (muted) {
            beforeMutedValue = Configuration.DEFAULT_VALUE_MUSIC_VOLUME;
        } else {
            beforeMutedValue = volumeSlider.getValue();
        }

        muteButton.setOnAction((event) -> {
            beforeMutedValue = volumeSlider.getValue();
            volumeSlider.setValue(0);
        });

        unmuteButton.setOnAction((event) -> volumeSlider.setValue(beforeMutedValue));

        volumeSlider.valueProperty().addListener((observable, oldValue, newValue) -> {
            final boolean localMuted = newValue.doubleValue() == 0;
            muteButton.setVisible(!localMuted);
            unmuteButton.setVisible(localMuted);
        });

        return new StackPane(muteButton, unmuteButton);
    }

}