-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.rb
executable file
·48 lines (38 loc) · 1.09 KB
/
example.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- encoding : utf-8 -*-
#!/usr/bin/env ruby
# Stream all the files given on the commandline to the Icecast server on localhost.
#
# Use the mp3 in the test directory:
#
# ./example.rb spec/test.mp3
BASE_DIR = File.expand_path File.dirname(__FILE__)
VERSION = File.open(File.join(BASE_DIR, 'VERSION')).readline.strip
require File.join(BASE_DIR, "spec/test_gem_installation/gems/ruby-shout-#{VERSION}/lib/shout")
BLOCKSIZE = 16384
s = Shout.new
s.mount = "/some_mountpoint"
# s.charset = "UTF-8"
# s.mount = "/utf8"
s.port = 8080
s.host = "127.0.0.1"
s.user = "source"
s.pass = "hackme"
s.format = Shout::MP3
s.description ='çaffé düdeldø … dikşîne ΞŁΞϾТЯФЛłϾ MUSłϾ ☼ ☺'
s.connect
puts "open VLC and open network -> http://#{s.host}:#{s.port}/#{s.mount}"
ARGV.each do |filename|
File.open(filename) do |file|
puts "sending data from #{filename}"
m = ShoutMetadata.new
m.add 'filename', filename
m.add 'title', 'title ☼ ☺'
s.metadata = m
while data = file.read(BLOCKSIZE)
print '.'
s.send data
s.sync
end
end
end
s.disconnect