0 Replies Latest reply on Dec 1, 2007 8:59 PM by golfmat

    Audio playback issue

    golfmat
      Hi,

      I am relatively new to Flash/Flex/FMS. I am currently using FMS2 and Flex 3 Beta 2 and Flash 9 Player, all on XP. However, I was also experiencing the same issue with Flex 2.

      Issue: I am experiencing problems playing back audio+data streams that users have recorded. Specifically, an early segment of the stream is playing very rapidly (almost instantly). This segment always occurs just prior to the time when the first audio was recorded (which can be any arbitrary time after publishing starts). The length of this segment is also dependent upon the buffer size set for the stream: the larger the buffer, the larger the segment (setting the buffer time to 0 still results in about 2 secs worth of the stream playing instantly). In order to understand what was happening, I started using NetStream.send() during recording to send a timestamp every 100ms. If I print these timestamps during playback, the timestamps during this "segment" print almost instantly, before returning to their expected time interval as the audio commences. This is a problem because I am trying to approximately synchronize multiple audio streams with an event stream. I'm aware that this synchronization cannot be done precisely, but this multi-second "fast-forward" is making it impossible for me to even come close (esp. since the length of the "segment" appears to be unpredictable). Interestingly, my data-only event stream does not suffer this problem. If I have it similarly send timestamps, the two streams' timestamps match up closely prior to this "segment", then the audio stream sends a flurry of timestamps during this bizarre segment, and finally the two streams continue to send timestamps at the correct rate (only now the audio stream is some number of seconds ahead).

      I am not doing anything special, but for the sake of clarity, here are some snippets of my code pertaining to the audio stream:

      //Recording
      m_ns = new NetStream(m_nc);
      m_ns.attachAudio(m_mic);
      m_ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
      m_ns.publish(m_prefix + m_userid, "record");
      m_timer = new Timer(100, 0);
      m_timer.addEventListener(TimerEvent.TIMER, onTimeStampTick);
      m_timer.start();

      public function onTimeStampTick(event:TimerEvent):void {
      m_ns.send("timeStamp", getLiveSessionTime());
      }
      //

      //Playback
      stream = new NetStream(m_nc);
      stream.bufferTime = 5;
      stream.client = new Object();
      stream.client.onMetaData = function(info:Object):void {
      for(var i:String in info)
      writeln("onMetaData: " + i + " -> " + info );
      }
      stream.client.onPlayStatus = function(info:Object):void {
      writeln("onPlayStatus: " + info.code);
      }
      stream.client.timeStamp = function(time:Number):void {
      writeln("###TIMESTAMP: " + time);
      }
      stream.addEventListener(NetStatusEvent.NET_STATUS, function(event:NetStatusEvent):void { writeln("onStatus: " + event.info.code); });
      stream.receiveAudio(true);
      stream.play(m_prefix + userid, -2, -1, true);
      //

      My hope is that someone with more expertise than I can explain where this problem is occuring. Is it something I am most likely causing? Is it a problem with the Flex/Flash client's recording and/or playing of the audio stream? Or is it a server-side FMS2 issue? Are there ways to fix or work around this issue?

      Thanks so much for any help!
      Matt