Frage

$(document).ready(function() {
    var widget = SC.Widget(document.getElementById('soundcloud_widget'));

    widget.bind(SC.Widget.Events.READY, function() {
        console.log('Ready...');
    });

    $('#soundcloudbutton').click(function() {
        $('#soundcloudbutton').toggleClass('soundcloudpause');
        $('#soundcloudbutton').toggleClass('soundcloudplay');
        widget.toggle();
    });

    $('.mute-the-music').click(function() {
        $('#soundcloudbutton').toggleClass('soundcloudplay');
        widget.false();
    });
});

How do you make the widget.false line trigger the soundcloud player to stop playing? I can't work out the the singular version of the toggle function.

Cheers, Sam

War es hilfreich?

Lösung

To play and mute the sound, you have .play() and .pause(), which is the on / off setting for .toggle().

You may also want to replace .toggleClass() with .removeClass() since you want it to stop in this case, not toggle.

$('.mute-the-music').click(function() {
    $('#soundcloudbutton').removeClass('soundcloudplay');
    widget.pause();
});
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top