Support » Plugin: Cue by AudioTheme.com » Disable auto playing next track

  • Resolved CloudedDottedMind

    (@cloudeddottedmind)


    We love Cue, however, I’m looking to disable the next track auto-playing on a playlist as it is proving very disruptive for our listeners. When looking for how to do this, the solution previously used by others no longer works.

    I found this code bit in the plugin files that appears to dictate that the next track should autoplay after one ends, but I do not understand how to prevent it / what to add to my theme’s js file to prevent it.

    On line 577 of the file jquery.cue.js :

    // Play the next track when one ends.
                                $media.on( 'ended.cue', function() {
                                        var index = player.cueCurrentTrack + 1 >= player.options.cuePlaylistTracks.length ? 0 : player.cueCurrentTrack + 1;
        
                                        // Determine if the playlist shouldn't loop.
                                        if ( ! player.options.cuePlaylistLoop && 0 === index ) {
                                                return;
                                        }
        
                                        // Give other 'end' events a chance to grab the current track.
                                        setTimeout(function() {
                                            $( player.node ).trigger( 'nextTrack.cue', player );
                                                player.cuePlayNextTrack();
                                        }, 250 );
                                });

    This is the file: https://plugins.trac.wordpress.org/browser/cue/trunk/assets/js/vendor/jquery.cue.js

    This is the previous solution: https://wordpress.org/support/topic/how-to-stop-playing-at-the-end-of-each-track/

    Do you know what code I could add to my jquery theme file to do this?

    Thank you

Viewing 1 replies (of 1 total)
  • Thread Starter CloudedDottedMind

    (@cloudeddottedmind)

    Hi,

    if anyone is looking for an answer, this is what I’ve ended up with that works:

    If you have a js file inside your child theme:

           var endedHandler = function () {
        		var playHandler = function () {
        			$(".cue-audio")[0].pause();
        			$(".cue-audio").unbind("play", playHandler);
        			$(".cue-audio").unbind("play", endedHandler);			
        		}
        		$(this).on("play", playHandler);
        	}
        	$(".cue-audio").on("ended", endedHandler);
        });

    If you don’t and need to add it somewhere else:

        jQuery(".cue-audio").on("ended", function () {
        var playHandler = function () {
        jQuery(".cue-audio")[0].pause();
        jQuery(".cue-audio").unbind("play", playHandler);
        }
        jQuery(this).on("play", playHandler);
        });
Viewing 1 replies (of 1 total)
  • The topic ‘Disable auto playing next track’ is closed to new replies.