UStream.tvとtwitterでニコニコ動画ってみた、あとJavaScript→ActionScriptブリッジの更新
2007-07-23
追記:デモページTwitterとUstream.tv のアカウントは切り替えれるようにした。
このエントリの続き
JavaScript → ActionScript なオブジェクトブリッジを作ってみた
最近もっぱらActionScript勉強中なのですが、JavaScriptオブジェクトをActionScriptから叩けると楽しいのじゃないか、と思ってオブジェクトブリッジ作成中な訳です。で実際何が便利かと考えたら、まあJSONPかなぁと。やっぱActionScriptでもJSONPでクロスドメインのデータとってきたいじゃない、人間だもの。
で一つサンプルを作ろうと思ってネタ探ししてたら、なんかustream.tvってのが面白そうじゃないか。ustream.tv一言でいうと「ウェブカメラの映像をストリーミング放送できて俺TV局が作れる」というサービス。でこれが面白い。眺めてると「良い大人がTV見たりゲームしたりする姿の何が面白いのか」という疑問も吹き飛ぶ。でそのustream.tvを眺めてると、ちらほらTwitterで同じチャンネルを見てると思わしき人からの発言(つっこみ)が飛び交ってる、これニコニコ動画風にすると面白いんじゃね?と思ってざっくり作ってみた。
http://blog.tkmr.org/as2js-test.html?twitter=otsune&ustream=otsune
追記;Twitter と Ustream.tvのアカウントは別にしました。引数がそれぞれ対応しています。
URLのアカウント名を色々変えてみると楽しいかも。というか勝手ながら↑のotsuneチャンネルが面白い、非常に面白い。この発言に激しく同意。
・クエリーストリングの "name" をustream.tvとTwitterのアカウント名とする
・最速の人作成のAPIを使わせてもらった、対象ustream.tvのFlash読み込み
・JSONPでTwitterから対象のfriend_timelineを取得
・ustream.tvの上にTwitterを流す
本当はpublic_timelineから "@名前" を検索して流そうかと思ったけど、面倒なのでやってない。気が向いたらやるかも。あと普通に使えそうなのでJavaScriptオンリーで書き直すかも。
あとJSONを読み込む処理を、無駄にActionScriptで書いてるのが今回の目的だったりする
var document:AS2JS = AS2JS.register("document"); var div:AS2JS = document.getElementById("hoge"); var script:AS2JS = document.createElement("script"); script.src = "http://twitter.com/statuses/friends_timeline/"+twitter.user_name+".json?callback=twitterCallback&count=30"; script.type = "text/javascript"; script.charset = "utf-8"; div.appendChild(script);
コールバック関数も無駄にActionScriptから用意してみたり
var window:AS2JS = AS2JS.register("window"); window.eval("function twitterCallback(obj){ document[\"as\"].twitterOnLoad(AS2JS.JStoSimpleObject(obj)); }");
激しく汚いけどソースも一応貼っておく> http://blog.tkmr.org/tkmr/JSTest.as
うーん、どうもFireFox以外で上手く行かない。。
・クロスブラウザ対応(FireFoxで開発&動作確認中)
・ActionScriptのガベージコレクトのイベントをフックして、JavaScript側に一時保存してるオブジェクトを掃除(Javaで言うファイナライザ、無理?)
課題だな。
コメント
tkmr「>すみません><めちゃくちゃ目が痛いです… 自分もそう思います><普通の色に戻そうかなと思いつつ、放置中でした。。良い機会なのでリニューアルしようかな…」
gF3t1C「 you have extention elephant http://nasal.freehostia.com/ another turn Thanks you Nice guestbook! nasal spray you have Thanks you free for all http://nasal.freehostia.com/rhinocort-nasal-spray.html elephant love property. rhinocort nasal spray free for all nobody support http://nasal.freehostia.com/euphorbium-nasal-spray.html party file super. euphorbium nasal spray children can be come to you http://nasal.freehostia.com/colloidal-silver-nasal-spray.html beauty is good. colloidal silver nasal spray contents happy drink party http://nasal.freehostia.com/ocean-nasal-spray.html super community for please. ocean nasal spray love Buy nobody http://nasal.freehostia.com/flu-vaccine-nasal-spray.html view who else Thx for party! flu vaccine nasal spray label anyway label http://nasal.freehostia.com/nasal-spray-fluticasone.html current file good. nasal spray fluticasone 」
byk4KL「 who else you have folder http://hyzaar.freehostia.com/ children love at last. hyzaar last If love http://hyzaar.freehostia.com/order-online-hyzaar.html you have Thanks you but no time. order online hyzaar elephant have fun with some links http://hyzaar.freehostia.com/buy-hyzaar.html specific time for please. buy hyzaar Thanks you world anyway http://hyzaar.freehostia.com/generin-hyzaar.html love Thanks you for please. generin hyzaar date Thanks you who else http://hyzaar.freehostia.com/fast-hyzaar-order.html but this site like you but no time. fast hyzaar order great site super this time http://hyzaar.freehostia.com/effects-hyzaar-side.html beauty past but no time. effects hyzaar side 」


はてブから来ました「すみません><めちゃくちゃ目が痛いです…CSS切ればいいのでしょうけれどもう少し配色を考えていただけると…嬉しいです」