Skip to content

Instantly share code, notes, and snippets.

@tana
Created July 25, 2010 06:45
Show Gist options
  • Save tana/489373 to your computer and use it in GitHub Desktop.
Save tana/489373 to your computer and use it in GitHub Desktop.
コンパイル方法:
haxe -main SoundPlayer -swf9 soundplayer.swf
注意:
ローカルで動かす時は、Flashの「グローバルセキュリティ設定パネル」で、soundplayer.swfがあるディレクトリを常に信頼するようにしておく。
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.net.URLRequest;
import flash.text.TextField;
class SoundPlayer {
static function main() {
var text = "Hello";
var url = "http://translate.google.com/translate_tts?tl=en&q=" + StringTools.urlEncode(text);
var snd = new Sound(new URLRequest(url));
var channel = snd.play();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment