Skip to content

Instantly share code, notes, and snippets.

@PowZone
Forked from ton1517/PlayM4A.as
Last active August 29, 2015 14:09
Show Gist options
  • Save PowZone/3b6a0edccb36f948c28e to your computer and use it in GitHub Desktop.
Save PowZone/3b6a0edccb36f948c28e to your computer and use it in GitHub Desktop.
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