Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Pause Callback #37

Closed
wants to merge 1 commit into from
Closed

Conversation

Duhduh1973
Copy link

Adds a callback for the pause function. Example usage: Pause a song without removing the "amplitude-active-song-container" class - allowing the active element to retain its styling while in pause mode.

Amplitude.config function:

"callbacks":
    "debug": true,
    "after_pause": "active_pause"
    }

});
function active_pause(){
    console.log('PAUSED');
    $('.amplitude-active-song-container').collapse('hide');
    $('.amplitude-active-song-container').prev().removeClass('active-panel');
    $('.amplitude-active-song-container').prev().find('.amplitude-play-pause').removeClass('amplitude-playing').addClass('amplitude-paused');
    $('.amplitude-active-song-container').prev().find('.playlist-play').removeClass('playlist-play').addClass('playlist-paused');
}

Functional Method in Amplitude.js

/*
Pauses the active song. If it's live, it disconnects the stream.
*/
function privatePause(){
privateRunCallback('before_pause');


if( config.active_metadata.live ){
    privateDisconnectStream();
}
config.active_song.pause();
privateRunCallback('after_pause');
}

Amplitude.config function:

'''
function active_pause(){
	console.log('PAUSED');
	$('.amplitude-active-song-container').collapse('hide');
	$('.amplitude-active-song-container').prev().removeClass('active-panel');
	$('.amplitude-active-song-container').prev().find('.amplitude-play-pause').removeClass('amplitude-playing').addClass('amplitude-paused');
	$('.amplitude-active-song-container').prev().find('.playlist-play').removeClass('playlist-play').addClass('playlist-paused');
}
'''
@danpastori
Copy link
Contributor

Thanks for the pull request. Sorry for not getting back sooner, its been a bit crazy around here. We released Amplitude 3.0, so now this has a merge conflict.

What I will do is take what you have and updated it to work in Amplitude 3.1 on the next release.

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants