diff --git a/ews.rb b/ews.rb index 67b212d..228be7a 100755 --- a/ews.rb +++ b/ews.rb @@ -24,27 +24,6 @@ Logger: WEBrick::Log.new("/dev/null") ) -http_server.mount_proc '/music_list.json' do |req, res| - files = Dir.glob("public/music/*.{mp3,wav,ogg}") - .map { |f| File.basename(f) } - .sort_by { |f| f[/^\d+/].to_i } # ← 番号の順に並べるよ! - res['Content-Type'] = 'application/json' - res['Access-Control-Allow-Origin'] = '*' - res.body = { files: files }.to_json -end - -http_server.mount_proc '/music/' do |req, res| - path = "./public/music/#{File.basename(req.path)}" - if File.exist?(path) - res['Content-Type'] = 'audio/mpeg' - res['Access-Control-Allow-Origin'] = '*' - res.body = File.open(path, 'rb') { |f| f.read } - else - res.status = 404 - res.body = 'Not Found' - end -end - # HTTP サーバーをバックグラウンドで開始 Thread.new { http_server.start } @@ -73,7 +52,7 @@ data = JSON.parse(msg) case data["type"] when "select" - selected_url = "http://localhost:#{HTTP_PORT}/music/#{URI.encode_www_form_component(data["file"])}" + selected_url = "http://172.20.16.49:8890/#{URI.encode_www_form_component(data["file"])}" #ここのIPを、playerを建てるPCのIPに clients.each { |c| c.send({ type: "select", url: selected_url }.to_json) } when "play"