Quantcast
Channel: Tópicos
Viewing all articles
Browse latest Browse all 14700

Flex Player

$
0
0
Boas tardes pessoal,
estou a usar um flex player rtmp-publisher com o seguinte codigo xml

Código :
<?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:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.core.FlexGlobals;
private var streamer:String;
private var file:String;
private var camera:Camera;
private var microphone:Microphone;
private var connection:NetConnection;
private var stream:NetStream;
private var h264Settings:H264VideoStreamSettings;
private function toggleFeedListener(event:MouseEvent):void {
if(toggleFeed.label == 'Start Feed') {
toggleFeed.label = 'Stop Feed';
stream.publish(file, 'live');
videoDisplay.attachCamera(camera);
toggleVideo.enabled = true;
toggleAudio.enabled = true;
} else {
toggleFeed.label = 'Start Feed';
stream.close();
videoDisplay.attachCamera(null);
toggleVideo.enabled = false;
toggleAudio.enabled = false;
}
}
private function toggleVideoListener(event:MouseEvent):void {
if(toggleVideo.label == 'Start Video') {
toggleVideo.label = 'Stop Video';
videoDisplay.attachCamera(camera);
stream.attachCamera(camera);
} else {
toggleVideo.label = 'Start Video';
videoDisplay.attachCamera(null);
stream.attachCamera(null);
}
}
private function toggleAudioListener(event:MouseEvent):void {
if(toggleAudio.label == 'Start Audio') {
toggleAudio.label = 'Stop Audio';
stream.attachAudio(microphone);
} else {
toggleAudio.label = 'Start Audio';
stream.attachAudio(null);
}
}
private function initListeners():void {
toggleFeed.addEventListener(MouseEvent.CLICK, toggleFeedListener);
toggleVideo.addEventListener(MouseEvent.CLICK, toggleVideoListener);
toggleAudio.addEventListener(MouseEvent.CLICK, toggleAudioListener);
}
private function netStatusHander(event:NetStatusEvent):void {
switch(event.info.code) {
case 'NetConnection.Connect.Success':
stream = new NetStream(connection);
stream.attachCamera(camera);
stream.attachAudio(microphone);
h264Settings = new H264VideoStreamSettings();
h264Settings.setProfileLevel(H264Profile.BASELINE, H264Level.LEVEL_1_2);
stream.videoStreamSettings = h264Settings;
break;
}
}
private function init():void {
streamer = FlexGlobals.topLevelApplication.parameters.streamer;
file = FlexGlobals.topLevelApplication.parameters.file;
if(file == null) {
Alert.show('Missing flashvars: file');
return;
}
if(streamer == null) {
Alert.show('Missing flashvars: streamer');
return;
}
initListeners();
camera = Camera.getCamera();
microphone = Microphone.getMicrophone();
microphone.setSilenceLevel(0);
microphone.codec = "Speex";
microphone.encodeQuality = 6;
camera.setMode(704, 576, 25);
camera.setQuality(131072, 70);
connection = new NetConnection();
connection.connect(streamer);
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHander);
}
]]>
</fx:Script>
<s:Panel x="0" y="0" width="100%" height="100%" title="RTMP Publisher">
<mx:VideoDisplay width="100%" height="100%" id="videoDisplay">
</mx:VideoDisplay>
<s:controlBarContent>
<s:Button label="Start Feed" id="toggleFeed"></s:Button>
<s:Spacer width="100%" height="100%"/>
<s:Button label="Stop Video" id="toggleVideo" enabled="false"></s:Button>
<s:Button label="Stop Audio" id="toggleAudio" enabled="false"></s:Button>
</s:controlBarContent>
</s:Panel>
</s:Application>


No html tenho o seguinte codigo


Código :
<!DOCTYPE html>
<html>
<head>
    <title>RTMP Publisher</title>
    <script type="text/javascript" src="swfobject.js"></script>
    <script type="text/javascript">
            var flashVars = {
                    streamer: 'rtmp://localhost/xx',
                    file:'stream'
            };
            swfobject.embedSWF("RtmpPublisher.swf", "rtmp-publisher", "500", "400", "9.0.0", null, flashVars);
    </script>
</head>
<body>
    <div id="rtmp-publisher">
            <p>Flash not installed</p>
    </div>
</body>
</html>

acontece que queria colocar botoes externos a comandar o stream, e tou com algumas dificuldades andei a pesquisar e tentei isto mas sem sucesso.
o player trabalha bem mas nao consigo por os botoes externos a dar

Código :
<!DOCTYPE html>
<html>
<head>
    <title>RTMP Player</title>
    <script type="text/javascript" src="swfobject.js"></script>
    <script type="text/javascript">
var flashVars = {
                    streamer: 'rtmp://localhost/xx',
                    file:'stream'
            };
params = { AllowScriptAccess: 'always' };
function livestreamPlayerCallback(event) {
          if (event == 'ready') {
            player = document.getElementById("rtmp-publisher");
            player.load('rtmp://localhost/xx/stream');
          }
          log = document.getElementById('log');
          log.innerHTML = log.innerHTML + '<br/>' + event;
    }
            swfobject.embedSWF("RtmpPublisher.swf", "rtmp-publisher", "500", "400", "9.0.0", null, flashVars);
    </script>
</head>
<body>
    <div id="rtmp-publisher">
            <p>Flash not installed</p>
    </div>
<br/>
  <input type="button" value="play" onclick="player.startPlayback()"/>
  <input type="button" value="pause" onclick="player.stopPlayback()"/>
  <input type="button" value="vol +" onclick="player.volumeUp()"/>
  <input type="button" value="vol -" onclick="player.volumeDown()"/>
  <div id="log"></div>
</body>
</html>
Alguem me pode dar uma ajuda?
desde ja obrigado

Viewing all articles
Browse latest Browse all 14700