Created
December 28, 2010 06:00
-
-
Save deguchi/756941 to your computer and use it in GitHub Desktop.
TVにつないだMacに、iPhoneからUstreamを再生させるスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#利用方法: このスクリプトをTVにつないだMac上で実行、以下のブックマークレットのloccalip部分をMacのIPに変更。それをiPhoneに送ってブックマーク登録する。(ブックマークに登録後、?より前は削除) | |
#Bookmarklet: http://www.google.com/?javascript:window.open('http://localip:9191/run?url='+document.getElementsByTagName('video')[0].src) | |
#iPhone用の配信をしているUstreamの個別ページでブックマークレットを実行。 | |
#TVでUstreamがフルスクリーン再生される | |
require 'webrick' | |
document_root = '/Users/deguchi/Desktop/' | |
server = WEBrick::HTTPServer.new({ | |
:DocumentRoot => document_root, | |
:BindAddress => '0.0.0.0', | |
:Port => 9191 | |
}) | |
['INT', 'TERM'].each {|signal| | |
Signal.trap(signal){ server.shutdown } | |
} | |
server.mount_proc("/run") { |req, res| | |
result = system( | |
'osascript', | |
'-e', "tell application \"QuickTime Player\" to quit", | |
'-e', "tell application \"QuickTime Player\"", | |
'-e', "open URL \""+req.query['url']+"\"", | |
'-e', "activate", | |
'-e', "play every document", | |
'-e', "delay 5", | |
'-e', "present document 1", | |
'-e', "delay 5", | |
'-e', "present document 1", | |
'-e', "delay 5", | |
'-e', "present document 1", | |
'-e', "end tell" | |
); | |
# result = system('osascript', '/Users/deguchi/Desktop/ustream.scpt', req.query['url']) | |
print result | |
res["content-type"] = "text/html; charset=utf-8" | |
res.body = "ok<br><br><a href='/stop'>Stop</a>" | |
} | |
server.mount_proc("/stop") { |req, res| | |
result = system('osascript', '-e', "tell application \"QuickTime Player\" to quit"); | |
print result | |
res["content-type"] = "text/html; charset=utf-8" | |
res.body = "close ok" | |
} | |
server.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment