Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1217402

    Hello
    How can I pause an audio playing at slide change (layerslider wp) ?
    I tried with event callbacks in “slideCHangeDidStart” tab :

    function( event, slider ) {
    $('#layer_slider_1').layerSlider('resetSlide');
    or
    $('#layer_slider_1').layerSlider('pauseMedia');​
    ​}

    Nothing works, I have few experience in this​​…
    Any tips ?
    Thanks

    • This topic was modified 4 years, 6 months ago by romano2.
    #1219345

    Hey romano2,

    Thank you for the inquiry.

    How did you add the media file, and where did you get the above snippet from? Please provide a link to the page containing the layer slider so that we can check it.

    The following documentations might help.

    // https://layerslider.kreaturamedia.com/documentation/#layerslider-api
    // https://www.iolo.com/content/plugins/LayerSlider/docs/api.html

    Best regards,
    Ismael

    #1219430

    Thanx for answer Ismael,
    I added my audio with a HTML layer, with a simple shortcode in the content, like :
    [audio mp3="http://graphikarbre.xyz/voulgre/wp-content/uploads/2020/05/lecivet.mp3"][/audio]

    I found the above snippet from layerslider help :

    Thanks for your tips.
    Romano

    #1220370

    Hi,

    Thank you for the info.

    You can try this script inside the Media Events > mediaDidStart() callback.

    	var audio = document.getElementsByClassName("wp-audio-shortcode"); 
    	for (var i = 0; i < audio.length; i++) {
    		audio.item(i).pause();
                    audio.item(i).currentTime = 0;
            }
    

    It will pause the audio immediately before it actually starts.

    Best regards,
    Ismael

    #1220448

    Ok, many thanks, you show me the way.
    I succeeded with this code :

    function( event, slider ) {
    	var audioz = document.getElementsByTagName("audio"); 
    	for (var i = 0; i < audioz.length; i++) {
    		audioz.item(i).pause();
    		audioz.item(i).currentTime = 0
    	}
    }

    I put it in : SLIDE CHANGE EVENTS > slideChangeWillStart
    With .getElementsByClassName there was too much non-audio object wich cause errors.
    Thanks again.

    #1220491

    Hi,

    I’m glad you found a solution. Should we close this topic?

    Best regards,
    Jordan Shannon

    #1220498

    Yes you can close it, thanks.

    #1220507

    Hi,

    If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Layerslider wp – Stop media at slide change’ is closed to new replies.