Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

voice chat as3 #358

Open
AxelDeathBR opened this issue Oct 4, 2024 · 0 comments
Open

voice chat as3 #358

AxelDeathBR opened this issue Oct 4, 2024 · 0 comments

Comments

@AxelDeathBR
Copy link

Issue

Short description

Brief description of what happened

Environment

[] Operating system and version:
[] Java version:
[] Red5 version:

Expected behavior

Put as much detail here as possible

Actual behavior

Put as much detail here as possible

Steps to reproduce

CODE
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.*;
import flash.media.Microphone;
import flash.media.Sound;

// Variáveis globais
var Mic: Microphone;
var nc: NetConnection = new NetConnection();
var istream: NetStream;
var ostream: NetStream;

// Permitir configurações de segurança
Security.showSettings("2");

// Configurar o microfone
if (Microphone.names.length > 0) {
Mic = Microphone.getMicrophone();
Mic.setUseEchoSuppression(true);
Mic.setLoopBack(false);
Mic.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
Mic.addEventListener(StatusEvent.STATUS, statusHandler);
} else {
trace("Nenhum microfone encontrado.");
}

btnTalk.addEventListener(MouseEvent.MOUSE_DOWN, talkDown);
btnTalk.addEventListener(MouseEvent.MOUSE_UP, talkUp);
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect("rtmp://localhost:1935/oflaDemo");

function talkDown(e: MouseEvent): void {
trace("Iniciando transmissão...");
ostream.publish("charchar"); // Publicar o stream
}

function talkUp(e: MouseEvent): void {
trace("Parando transmissão...");
ostream.close(); // Fechar o stream
}

function netStatusHandler(event: NetStatusEvent): void {
trace(event.info.code);
switch (event.info.code) {
case "NetConnection.Connect.Success":
// Criar NetStreams quando a conexão for bem-sucedida
ostream = new NetStream(nc);
istream = new NetStream(nc);
istream.play("charchar"); // Iniciar reprodução do stream
ostream.attachAudio(Mic); // Conectar o microfone ao NetStream
break;
case "NetConnection.Connect.Rejected":
trace("Conexão rejeitada.");
break;
case "NetConnection.Connect.Failed":
trace("Falha na conexão.");
break;
default:
trace("Código: " + event.info.code);
}
}

function activityHandler(event: ActivityEvent): void {
trace("Atividade do microfone: " + event);
}

function statusHandler(event: StatusEvent): void {
trace("Status do microfone: " + event);
}

LOG: NetConnection.Connect.Success
Status do microfone: [StatusEvent type="status" bubbles=false cancelable=false eventPhase=2 code="Microphone.Unmuted" level="status"]
Atividade do microfone: [ActivityEvent type="activity" bubbles=false cancelable=false eventPhase=2 activating=true]
Atividade do microfone: [ActivityEvent type="activity" bubbles=false cancelable=false eventPhase=2 activating=false]
Atividade do microfone: [ActivityEvent type="activity" bubbles=false cancelable=false eventPhase=2 activating=true]
Iniciando transmissão...
Parando transmissão...

SHOULDN'T netStatusHandler BE SENDING SOMETHING?

Logs

Place logs on pastebin or elsewhere and put links here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant