Skip to content

Instantly share code, notes, and snippets.

@releu
Created March 21, 2019 12:34
Show Gist options
  • Save releu/f181d4b47a69b4ed50d9c051f8a8341f to your computer and use it in GitHub Desktop.
Save releu/f181d4b47a69b4ed50d9c051f8a8341f to your computer and use it in GitHub Desktop.
tv
@channel = 1
@channel_map = {
1 => "./ocean.mp4",
2 => "./fireplace.mp4",
3 => "./ocean.mp4",
4 => "./fireplace.mp4",
}
@emulator = Thread.new do
loop do
@channel = [1,2,3,4].sample
sleep 10
puts @channel
end
end
@player = Thread.new {}
@watcher = Thread.new do
last_channel = nil
loop do
if last_channel != @channel
last_channel = @channel
Thread.kill(@player)
@player = Thread.new do
`/Applications/VLC.app/Contents/MacOS/VLC -f -L #{@channel_map[@channel]}`
end
end
sleep 0.5
end
end
[@emulator, @watcher, @player].map(&:join)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment