nginx-mod-rtmp/test/rtmp-publisher/RtmpPublisher.mxml

87 lines
2.7 KiB
Plaintext
Raw Normal View History

2012-08-15 22:02:08 +02:00
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="500" minHeight="350" creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.core.FlexGlobals;
import mx.events.FlexEvent;
import spark.skins.spark.PanelSkin;
2012-08-15 22:02:08 +02:00
private var streamer:String;
private var file:String;
private var camera:Camera;
private var microphone:Microphone;
private var connection:NetConnection;
private var stream:NetStream;
2012-10-01 12:37:30 +02:00
private var h264Settings:H264VideoStreamSettings;
2012-08-15 22:02:08 +02:00
private function publishButtonListener(event:MouseEvent):void {
if(publishButton.label == 'Publish') {
publishButton.label = 'Stop';
connection = new NetConnection();
connection.connect(streamer);
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHander);
2012-08-15 22:02:08 +02:00
} else {
publishButton.label = 'Publish';
2012-08-15 22:02:08 +02:00
stream.close();
connection.close();
stream = null;
connection = null;
2012-08-15 22:02:08 +02:00
}
}
private function netStatusHander(event:NetStatusEvent):void {
switch(event.info.code) {
case 'NetConnection.Connect.Success':
stream = new NetStream(connection);
stream.attachCamera(camera);
stream.attachAudio(microphone);
2012-10-01 12:37:30 +02:00
h264Settings = new H264VideoStreamSettings();
h264Settings.setProfileLevel(H264Profile.BASELINE, H264Level.LEVEL_3_1);
2012-10-01 12:37:30 +02:00
stream.videoStreamSettings = h264Settings;
stream.publish(file, 'live');
2012-08-15 22:02:08 +02:00
break;
}
}
private function init():void {
streamer = FlexGlobals.topLevelApplication.parameters.streamer;
if(streamer == null) {
Alert.show('Missing flashvars: streamer');
return;
}
2012-08-15 22:02:08 +02:00
file = FlexGlobals.topLevelApplication.parameters.file;
if(file == null) {
Alert.show('Missing flashvars: file');
return;
}
publishButton.addEventListener(MouseEvent.CLICK, publishButtonListener);
2012-08-15 22:02:08 +02:00
camera = Camera.getCamera();
camera.setMode(640, 480, 30);
camera.setQuality(131072, 70);
//videoDisplay.attachCamera(camera);
var localCam:Video = new Video(640,480);
localCam.attachCamera(camera);
videoDisplay.addChild(localCam);
2012-08-15 22:02:08 +02:00
microphone = Microphone.getMicrophone();
2012-10-01 12:37:30 +02:00
microphone.setSilenceLevel(0);
microphone.codec = "Speex";
microphone.encodeQuality = 6;
2012-08-15 22:02:08 +02:00
}
]]>
</fx:Script>
<s:BorderContainer x="0" y="0" width="100%" height="100%">
<s:VideoDisplay width="100%" height="100%" id="videoDisplay"></s:VideoDisplay>
2013-07-25 23:29:05 +02:00
<s:Button label="Publish" id="publishButton" horizontalCenter="0" bottom="10"></s:Button>
</s:BorderContainer>
2012-08-15 22:02:08 +02:00
</s:Application>