The best way to send voice using Photon

edited September 2013 in Flash (deprecated)

I'm trying to send and receive voice using Photon, but I faced some problems... could you please show me the best way that I can send and receive voice using Photon.

what I did so far:
[code2=as3]function onSoundChunk(e) {


if(soundQ.length % 10 == 0) {
//dict = [fromX, fromY, newX, newY, size, color];
var dict = new Dictionary();
dict = soundQ;"sound", dict);
trace("sound chunk sent");
soundQ = [];


[code2=as3]var soundCounter = 0;
var SQ:ByteArray;
var channel:SoundChannel;
var mySound:Sound
function onRecieveSoundChunck(type, data) {

trace("got data!");
SQ = new ByteArray();
for(var i in data) {
SQ.position = 0;
var sound:Sound = new Sound();
sound.addEventListener(SampleDataEvent.SAMPLE_DATA, sampleDataHandler, false, 0, true);;


private function sampleDataHandler(e):void {
trace("Playing Sound...");
for (var i:int = 0; i < 8192 && SQ.bytesAvailable > 0; i++)
var sample:Number = SQ.readFloat();;;



  • Hi salahassi,

    this thread gives some general info about "Voice over Photon": viewtopic.php?f=5&t=2852&p=13222#p13222

    It's in general recommended to use UDP (unreliable) for voice transmission, but as that is not available in the Flash library, you need to see if you can get it to work with TCP, which should definitely be possible as well... however, we don't have a sample at hand, sorry. If someone from the community has done Voice over Photon with a Flash client, we'd be happy to hear about it. :)

    Can you explain what your problems are?
  • The problem is that I receive data but the sound does not work! I mean 'trace("got data!");' and 'trace("Playing Sound...");' work, but the speaker/earphone doesn't work... I don't know where the problem is :/

    Thank you for the reply btw :)
  • Okay, seems like it's a general Flash programming question and not a Photon issue then - sorry, I can't help with that.

    Maybe my colleague Vadim has an idea, otherwise you might get better answers at a pure Flash development forum. Good luck!