Skip to content

Instantly share code, notes, and snippets.

@ton1517
Created September 12, 2011 00:28
Show Gist options
  • Save ton1517/1210361 to your computer and use it in GitHub Desktop.
Save ton1517/1210361 to your computer and use it in GitHub Desktop.
AS3でM4Aファイルを再生するプログラム
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.NetStatusEvent;
import flash.events.UncaughtErrorEvent;
import flash.media.Sound;
import flash.media.SoundTransform;
import flash.net.NetConnection;
import flash.net.NetStream;
public class PlayM4A extends Sprite {
private var nc:NetConnection;
private var ns:NetStream;
private var st:SoundTransform;
public function PlayM4A():void {
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
//これしないとエラーでる
ns.client = {
onXMPData: function(data:Object):void { },
onMetaData: function(data:Object):void { }
}
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
ns.play("MySound.m4a");
st = ns.soundTransform;
st.volume -= 0.3;
ns.soundTransform = st;
}
private function netStatusHandler(e:NetStatusEvent):void {
trace(e.info.code);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment