From a197b379e4af2ddfb49fdd1f2e6fb0096f7ebdf5 Mon Sep 17 00:00:00 2001 From: Chris Ham Date: Tue, 25 Sep 2018 15:41:53 -0700 Subject: [PATCH] init encap --- fgfm.TODO | 16 ++++++++-------- fgfm.js | 23 ++++++++++++----------- lib/ghobs.js | 4 ++-- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/fgfm.TODO b/fgfm.TODO index eccb6d1..0abbc1a 100755 --- a/fgfm.TODO +++ b/fgfm.TODO @@ -1,19 +1,16 @@ TODO: - ☐ Modularize OBS and Twitch code ☐ Room vid requests / import + ☐ Support viewer skip voting + ☐ Command to add sets of videos to the queue at once (like the entire ttas or all gold segments) + ☐ support for $pause + ☐ Command to stop video rotation / timers (shutdown) + ☐ Start/stop stream automation ☐ Rotating background images (leftside) ☐ Stream alerts for chat - ☐ support for $pause ☐ remove currently playing video from vote choices ☐ restrict # of requests a user can have in the queue at once ☐ Add cooldowns - ☐ Start/stop stream automation - ☐ Move vods to their own config ☐ Tool to output list of video ID's / descriptions - ☐ Support viewer skip voting - ☐ Command to add sets of videos to the queue at once (like the entire ttas or all gold segments) - ☐ Command to stop video rotation / timers (shutdown) - ☐ Ability to include/exclude vods from shuffle in config Ideas: ☐ Web interface for viewers to issue commands -- twitch extension?! @@ -21,6 +18,9 @@ Ideas: ___________________ Archive: + ✔ Move vods to their own config @done (18-09-25 15:40) @project(TODO) + ✔ Modularize OBS and Twitch code @done (18-09-25 15:39) @project(TODO) + ✔ Ability to include/exclude vods from shuffle in config @done (18-09-25 15:39) @project(TODO) ✔ Add random chance for room grind playlist to show for certain amount of time @done (18-09-21 12:28) @project(TODO) ✔ show commercials after a video length cap is hit -- show at conclusion of video @done (18-09-19 11:11) @project(TODO) ✔ add memes to commercial scene @done (18-09-19 11:11) @project(TODO) diff --git a/fgfm.js b/fgfm.js index 00460a8..c2b06fe 100755 --- a/fgfm.js +++ b/fgfm.js @@ -72,18 +72,22 @@ const twitchInit = (config) => { // Initialize Stream automation const streamInit = (config, twitch) => { return new Promise((resolve, reject) => { - // Set up the initial queue by randomly choosing the configured amount of vods included in shuffling - state.videoQueue = config.vods.alttp.filter(e => e.includeInShuffle === true).sort(util.randSort).slice(0, config.initialQueueSize); - console.log(`Initial video queue: ${state.videoQueue.map((c, i) => `[${i+1}] ${c.chatName}`).join(' | ')}`); + // Set up initial queue + start playback + const init = () => { + // Set up the initial queue by randomly choosing the configured amount of vods included in shuffling + state.videoQueue = config.vods.alttp.filter(e => e.includeInShuffle === true).sort(util.randSort).slice(0, config.initialQueueSize); + console.log(`Initial video queue: ${state.videoQueue.map((c, i) => `[${i+1}] ${c.chatName}`).join(' | ')}`); + + // Start queue playback + state.currentVideo = state.videoQueue.shift(); + showVideo(state.currentVideo); + } // Show a gameplay vod const showVideo = video => { console.log(`Showing video: ${video.chatName}`); - // play the next video when the previous finishes - let handleVideoEnd = () => {nextVideo()}; - - obs.playVideoInScene(video, config.defaultSceneName, handleVideoEnd) + obs.playVideoInScene(video, config.defaultSceneName, nextVideo) .then(timer => { // track timer so we can cancel callback later on if necessary state.videoTimer = timer; @@ -157,10 +161,6 @@ const streamInit = (config, twitch) => { showVideo(state.currentVideo); }; - // Start queue playback - state.currentVideo = state.videoQueue.shift(); - showVideo(state.currentVideo); - // "Commercials" const showCommercial = (video, callback) => { return new Promise((resolve, reject) => { @@ -502,6 +502,7 @@ const streamInit = (config, twitch) => { rtvInterval = setInterval(() => {rockTheVote()}, 300000); }); + init(); resolve(obs); }); }; diff --git a/lib/ghobs.js b/lib/ghobs.js index ae655a9..4f112aa 100755 --- a/lib/ghobs.js +++ b/lib/ghobs.js @@ -97,7 +97,7 @@ function GHOBS(config) { return this.websocket.setSceneItemProperties({"item": item, "scene-name": scene, "visible": visible}); }; - this.toggleVisible(item) => { + this.toggleVisible = (item) => { return new Promise((resolve, reject) => { this.websocket.getSceneItemProperties({"item": item}) .then(data => { @@ -116,7 +116,7 @@ function GHOBS(config) { return this.setVisible(item, scene, false); }; - this.switchToScene(scene) => { + this.switchToScene = (scene) => { return new Promise((resolve, reject) => { if (this.currentScene === scene) { resolve(true);