Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement