mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-23 18:30:49 +00:00
register blocks on the event client object
remove running attribute reader
This commit is contained in:
parent
9e84d02707
commit
8d2cc774ac
@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gem "obsws", "~> 0.4.0"
|
gem "obsws", "~> 0.5.8"
|
||||||
|
@ -4,23 +4,11 @@ require "yaml"
|
|||||||
require "pathname"
|
require "pathname"
|
||||||
|
|
||||||
class Main
|
class Main
|
||||||
attr_reader :running
|
|
||||||
|
|
||||||
def initialize(vm, **kwargs)
|
def initialize(vm, **kwargs)
|
||||||
@vm = vm
|
@vm = vm
|
||||||
@obsws = OBSWS::Events::Client.new(**kwargs)
|
@obsws = OBSWS::Events::Client.new(**kwargs)
|
||||||
@obsws.register([
|
|
||||||
method(:on_current_program_scene_changed),
|
|
||||||
method(:on_exit_started)
|
|
||||||
])
|
|
||||||
@running = true
|
|
||||||
end
|
|
||||||
|
|
||||||
def run
|
@obsws.on :on_current_program_scene_changed do |data|
|
||||||
sleep(0.1) while running
|
|
||||||
end
|
|
||||||
|
|
||||||
def on_current_program_scene_changed(data)
|
|
||||||
scene = data.scene_name
|
scene = data.scene_name
|
||||||
puts "Switched to scene #{scene}"
|
puts "Switched to scene #{scene}"
|
||||||
if respond_to?("on_#{scene.downcase}")
|
if respond_to?("on_#{scene.downcase}")
|
||||||
@ -28,11 +16,17 @@ class Main
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_exit_started
|
@obsws.on :on_exit_started do |data|
|
||||||
puts "OBS closing!"
|
puts "OBS closing!"
|
||||||
@obsws.close
|
@obsws.close
|
||||||
@running = false
|
@running = false
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def run
|
||||||
|
@running = true
|
||||||
|
sleep(0.1) while @running
|
||||||
|
end
|
||||||
|
|
||||||
def on_start
|
def on_start
|
||||||
@vm.strip[0].mute = true
|
@vm.strip[0].mute = true
|
||||||
|
Loading…
Reference in New Issue
Block a user