Skip to content

Instantly share code, notes, and snippets.

@nk-gears
Created April 26, 2020 09:57
Show Gist options
  • Save nk-gears/7ca6d695b1c1b9b3dcfa76954f2a0be8 to your computer and use it in GitHub Desktop.
Save nk-gears/7ca6d695b1c1b9b3dcfa76954f2a0be8 to your computer and use it in GitHub Desktop.
Start & End the Live (Go Live & End Stream)
function updateTransition(transitionState){
YouTube.setTokenService(function(){ return getYouTubeService().getAccessToken(); });
var resp=YouTube.liveBroadcastsList("snippet,status", {id:videoId});
return YouTube.liveBroadcastsTransition(transitionState, videoId, "status", {});
}
function startLive(videoId){
const transitionState="live";
updateTransition(transitionState);
}
function endLive(videoId){
const transitionState="completed";
updateTransition(transitionState);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment