This commit is contained in:
Chris Ham
2018-09-18 12:55:28 -07:00
parent 2edeedd66f
commit 799ac3a627
2 changed files with 43 additions and 53 deletions

View File

@@ -871,7 +871,7 @@
{ {
"id": "bodyguard", "id": "bodyguard",
"name": "bodyguard", "name": "bodyguard",
"filePath": "Y:\\media\\videos\\ALttP\\memes\\heroic-pop.mp4", "filePath": "Y:\\media\\videos\\ALttP\\memes\\heroic-popo.mp4",
"sceneItem": "meme1", "sceneItem": "meme1",
"length": 14 "length": 14
}, },

66
fgfm.js
View File

@@ -17,7 +17,7 @@ const randSort = () => { return 0.5 - Math.random() };
let videoQueue = recentlyPlayed = []; let videoQueue = recentlyPlayed = [];
let currentVideo; let currentVideo;
let videoTimer; let videoTimer;
let lastCommercialShown; let lastCommercialShownAt;
// Connect to OBS Websocket // Connect to OBS Websocket
const obs = new OBSWebSocket(); const obs = new OBSWebSocket();
@@ -126,11 +126,11 @@ const streamInit = (config, obs, twitch) => {
let handleVideoFinish = () => { let handleVideoFinish = () => {
obs.setSceneItemProperties({"item": video.sceneItem, "scene-name": config.videoSceneName, "visible": false}) obs.setSceneItemProperties({"item": video.sceneItem, "scene-name": config.videoSceneName, "visible": false})
.then(data => {nextVideo()}); .then(data => {nextVideo()})
.catch(console.error); .catch(console.error);
}; };
obs.setCurrentScene({"scene": config.videoSceneName}) obs.setCurrentScene({"scene-name": config.videoSceneName})
.then(res => { .then(res => {
playVideoInScene(video, config.videoSceneName, handleVideoFinish) playVideoInScene(video, config.videoSceneName, handleVideoFinish)
.then(timer => { .then(timer => {
@@ -152,28 +152,28 @@ const streamInit = (config, obs, twitch) => {
// Also handles "commercial breaks" // Also handles "commercial breaks"
const nextVideo = () => { const nextVideo = () => {
// Show a "commercial break" if it's been long enough since the last one // Show a "commercial break" if it's been long enough since the last one
let secondsSinceLastCommercial = (Date.now() - lastCommercialShown) / 1000; let secondsSinceLastCommercial = (Date.now() - lastCommercialShownAt) / 1000;
console.log(`It has been ${secondsSinceLastCommercial} seconds since the last commercial`); console.log(`It has been ${secondsSinceLastCommercial} seconds since the last commercial`);
/* if (secondsSinceLastCommercial >= config.commercialInterval) { /* if (secondsSinceLastCommercial >= config.commercialInterval) {
console.log(`Showing commercial now...`); console.log(`Showing commercial now...`);
// @TODO: Add a random chance here for it to be "everybody wow" // @TODO: Add a random chance here for it to be "everybody wow"
let commercial = config.memes.sort(randSort)[0]; let commercial = config.memes.sort(randSort)[0];
obs.setCurrentScene({"scene": config.commercialSceneName}) obs.setCurrentScene({"scene-name": config.commercialSceneName})
.then(res => { .then(res => {
return playVideoInScene(commercial, config.commercialSceneName, () => { return playVideoInScene(commercial, config.commercialSceneName, () => {
// hide video // hide video
obs.setSceneItemProperties({"item": commercial.sceneItem, "scene-name": config.commercialSceneName, "visible": false}) obs.setSceneItemProperties({"item": commercial.sceneItem, "scene-name": config.commercialSceneName, "visible": false})
// unmute songrequest audio // unmute songrequest audio
editorChat.say(to, '!volume 50'); twitch.editorChat.say(to, '!volume 50');
// show next video in queue // show next video in queue
lastCommercialShown = Date.now(); lastCommercialShownAt = Date.now();
nextVideo(); nextVideo();
}) })
}) })
.then(res => { .then(res => {
// mute songrequest audio // mute songrequest audio
editorChat.say(to, '!volume 0'); twitch.editorChat.say(to, '!volume 0');
});; })
.catch(console.error); .catch(console.error);
}*/ }*/
@@ -198,7 +198,7 @@ const streamInit = (config, obs, twitch) => {
showVideo(currentVideo); showVideo(currentVideo);
}; };
lastCommercialShown = Date.now(); lastCommercialShownAt = Date.now();
// grab the first video in the queue and show it // grab the first video in the queue and show it
currentVideo = videoQueue.shift(); currentVideo = videoQueue.shift();
@@ -301,7 +301,7 @@ const streamInit = (config, obs, twitch) => {
.catch(console.error); .catch(console.error);
// Black Box "Everybody Wow" config.commercialSceneName // Black Box "Everybody Wow"
} else if (commandNoPrefix === 'auw') { } else if (commandNoPrefix === 'auw') {
obs.setCurrentScene({"scene-name": config.commercialSceneName}) obs.setCurrentScene({"scene-name": config.commercialSceneName})
.then(res => { .then(res => {
@@ -310,7 +310,7 @@ const streamInit = (config, obs, twitch) => {
}) })
.then(res => { .then(res => {
// mute songrequest audio // mute songrequest audio
editorChat.say(to, '!volume 0'); twitch.editorChat.say(to, '!volume 0');
// show owen // show owen
obs.setSceneItemProperties({"item": "owen", "scene-name": config.commercialSceneName, "visible": true}); obs.setSceneItemProperties({"item": "owen", "scene-name": config.commercialSceneName, "visible": true});
// tell chat what's up // tell chat what's up
@@ -322,39 +322,29 @@ const streamInit = (config, obs, twitch) => {
// hide owen // hide owen
obs.setSceneItemProperties({"item": "owen", "scene-name": config.commercialSceneName, "visible": false}); obs.setSceneItemProperties({"item": "owen", "scene-name": config.commercialSceneName, "visible": false});
// unmute songrequest audio // unmute songrequest audio
editorChat.say(to, '!volume 50'); twitch.editorChat.say(to, '!volume 50');
// swap back to fgfm // swap back to fgfm
obs.setCurrentScene({"scene-name": "fgfm"}); obs.setCurrentScene({"scene-name": config.videoSceneName});
}, 246000); }, 246500);
}) })
.catch(console.error); .catch(console.error);
// memes on-demand // memes on-demand
} else if (commandNoPrefix === 'meme') { } else if (commandNoPrefix === 'meme') {
let commercial = config.memes.sort(randSort)[0];
obs.setCurrentScene({"scene-name": config.commercialSceneName}) obs.setCurrentScene({"scene-name": config.commercialSceneName})
/*.then(res => { .then(res => {
// show the video return playVideoInScene(commercial, config.commercialSceneName, () => {
return obs.setSceneItemProperties({"item": "everybody-wow", "scene-name": config.commercialSceneName, "visible": true}); // video is done playing, hide it
obs.setSceneItemProperties({"item": commercial.sceneItem, "scene-name": config.commercialSceneName, "visible": false})
// unmute songrequest audio
twitch.editorChat.say(to, '!volume 50');
// swap back to fgfm
obs.setCurrentScene({"scene-name": config.videoSceneName});
});
}) })
.then(res => { .then(res => {
// mute songrequest audio // mute songrequest audio once video starts playing
editorChat.say(to, '!volume 0'); twitch.editorChat.say(to, '!volume 0');
// show owen
obs.setSceneItemProperties({"item": "owen", "scene-name": config.commercialSceneName, "visible": true});
// tell chat what's up
twitch.botChat.say(to, 'Everybody OwenWow');
// swap back to fgfm scene after the video ends
setTimeout(() => {
// hide video
obs.setSceneItemProperties({"item": "everybody-wow", "scene-name": config.commercialSceneName, "visible": false})
// hide owen
obs.setSceneItemProperties({"item": "owen", "scene-name": config.commercialSceneName, "visible": false});
// unmute songrequest audio
editorChat.say(to, '!volume 50');
// swap back to fgfm
obs.setCurrentScene({"scene-name": "fgfm"});
}, 246000);*/
}) })
.catch(console.error); .catch(console.error);
@@ -554,7 +544,7 @@ const streamInit = (config, obs, twitch) => {
let rockTheVote = () => {}; let rockTheVote = () => {};
let rtvInterval = setInterval(() => {rockTheVote()}, 300000); let rtvInterval = setInterval(() => {rockTheVote()}, 300000);
let videoVoteJob = new schedule.Job(() => { let videoVoteJob = new schedule.Job(async () => {
// Tally votes from previous election (if there was one), add the winner to the queue // Tally votes from previous election (if there was one), add the winner to the queue
let winner; let winner;
if (currentChoices.length > 0) { if (currentChoices.length > 0) {