automated commercials

This commit is contained in:
Chris Ham
2018-09-18 21:02:30 -07:00
parent 799ac3a627
commit d6ae3aedbd
2 changed files with 23 additions and 19 deletions

View File

@@ -59,7 +59,7 @@
"commercialSceneName": "commercial", "commercialSceneName": "commercial",
"videoPollSize": 5, "videoPollSize": 5,
"currentActivitySceneItemName": "now-showing-txt", "currentActivitySceneItemName": "now-showing-txt",
"commercialInterval": 60, "commercialInterval": 3600,
"vods": [ "vods": [
{ {
"id": "ot-seg-escape", "id": "ot-seg-escape",

14
fgfm.js
View File

@@ -154,7 +154,7 @@ const streamInit = (config, obs, twitch) => {
// 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() - lastCommercialShownAt) / 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];
@@ -164,7 +164,7 @@ const streamInit = (config, obs, twitch) => {
// 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
twitch.editorChat.say(to, '!volume 50'); twitch.editorChat.say(twitchChannel, '!volume 50');
// show next video in queue // show next video in queue
lastCommercialShownAt = Date.now(); lastCommercialShownAt = Date.now();
nextVideo(); nextVideo();
@@ -172,13 +172,15 @@ const streamInit = (config, obs, twitch) => {
}) })
.then(res => { .then(res => {
// mute songrequest audio // mute songrequest audio
twitch.editorChat.say(to, '!volume 0'); twitch.editorChat.say(twitchChannel, '!volume 0');
}) })
.catch(console.error); .catch(console.error);
}*/
return;
}
// Keep track of recently played videos // Keep track of recently played videos
if (recentlyPlayed.length === 3) { if (recentlyPlayed.length === 5) {
recentlyPlayed.shift(); recentlyPlayed.shift();
} }
recentlyPlayed.push(currentVideo.id); recentlyPlayed.push(currentVideo.id);
@@ -195,6 +197,8 @@ const streamInit = (config, obs, twitch) => {
}); });
currentVideo = freshVods.sort(randSort).slice(0, 1).shift(); currentVideo = freshVods.sort(randSort).slice(0, 1).shift();
} }
// @TODO: if a commercial/meme is playing (manually triggered), wait until it's done
showVideo(currentVideo); showVideo(currentVideo);
}; };