From 875213201262c88671190325a7b3d3a94ae06a81 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Tue, 25 Oct 2022 00:05:12 +0100 Subject: [PATCH] scene rotate example added --- examples/scene_rotate/Gemfile | 9 +++++++++ examples/scene_rotate/Gemfile.lock | 27 +++++++++++++++++++++++++++ examples/scene_rotate/main.rb | 22 ++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 examples/scene_rotate/Gemfile create mode 100644 examples/scene_rotate/Gemfile.lock create mode 100644 examples/scene_rotate/main.rb diff --git a/examples/scene_rotate/Gemfile b/examples/scene_rotate/Gemfile new file mode 100644 index 0000000..0950401 --- /dev/null +++ b/examples/scene_rotate/Gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +# gem "rails" + +gem "obsws", path: "../.." + +gem "perfect_toml", "~> 0.9.0" diff --git a/examples/scene_rotate/Gemfile.lock b/examples/scene_rotate/Gemfile.lock new file mode 100644 index 0000000..19ee640 --- /dev/null +++ b/examples/scene_rotate/Gemfile.lock @@ -0,0 +1,27 @@ +PATH + remote: ../.. + specs: + obsws (0.0.3) + observer (~> 0.1.1) + waitutil (~> 0.2.1) + websocket-driver (~> 0.7.5) + +GEM + remote: https://rubygems.org/ + specs: + observer (0.1.1) + perfect_toml (0.9.0) + waitutil (0.2.1) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + x64-mingw-ucrt + +DEPENDENCIES + obsws! + perfect_toml (~> 0.9.0) + +BUNDLED WITH + 2.3.22 diff --git a/examples/scene_rotate/main.rb b/examples/scene_rotate/main.rb new file mode 100644 index 0000000..f308b26 --- /dev/null +++ b/examples/scene_rotate/main.rb @@ -0,0 +1,22 @@ +require "obsws" +require "perfect_toml" + +OBSWS::LOGGER.info! + +def conn_from_toml + PerfectTOML.load_file("obs.toml", symbolize_names: true)[:connection] +end + +def main + r_client = OBSWS::Requests::Client.new(**conn_from_toml) + r_client.run do + resp = r_client.get_scene_list + resp.scenes.reverse.each do |s| + puts "Switching to scene #{s[:sceneName]}" + r_client.set_current_program_scene(s[:sceneName]) + sleep(0.5) + end + end +end + +main if $0 == __FILE__