title: Problem with NetStream.pause() in ActionScript called from Javascript
body: <p>I am working on a very simple player written in MXML+ActionScript whose functions are exported to be called by a simple Javascript in an HTML page.<br/></p>
  
  <p>Both codes are provided below.</p>
  
  <p>For the mp3 "path" all is working perfectly for playing, pausing, resuming and stopping...<br/>
  For the m4a "path", starting is working well, stopping too but pausing is bugging<br/>
  After having started an m4a, when I clicked on "pause" it rightly stops the stream.<br/>
  But when I am clicking back on the button to resume, it does not start again at all<br/><br/>
  Does anybody know where is the problem? <br/>
  Is the fact that I'm using just a simple Apache Web Server and not a real Flash Streaming server the reason why it does not work?<br/><br/></p>
  
  <p>Thanks in advance for your help.<br/><br/></p>
  
  <p>The MXML+ActionScript 3<br/><br/></p>
  
  <pre><code>   &lt;?xml version="1.0"?&gt;
  &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="callBacks()"&gt;
      &lt;mx:Script&gt;
          &lt;![CDATA[
                  import flash.events.Event;
                  import flash.media.Sound;
                  import flash.net.URLRequest;
                  import flash.external.ExternalInterface;
                  public var playingChannel:SoundChannel;
                  public var playingSound:Sound;
                  public var pausePosition:int=0;
                  public var playingUrl:String="";
                  public var codec:String="";
                  public var playingStream:NetStream;
  
                  public function playSound(url:String):void {
                      if (playingUrl!=url) {
                          if (playingUrl!="") {
                              stopSound();
                          }
                          playingUrl=url;
                          codec=playingUrl.substring(playingUrl.length-3);
                          if (codec=="m4a") {
                              var mySound:SoundTransform;
                              var connect_nc:NetConnection = new NetConnection();
                              connect_nc.connect(null);
                              playingStream=new NetStream(connect_nc);
                              playingStream.play(url);
                          }
                          else if (codec=="mp3") {
                              playingSound=new Sound(new URLRequest(url));
                              playingChannel=playingSound.play();
                          }
                      }
                      else {
                          if (codec=="m4a")
                              playingStream.pause();
                          else
                              playingChannel=playingSound.play(pausePosition);
                      }
                  }
                  public function pauseSound():void {
                      if (codec=="m4a")
                          playingStream.pause();
                      else if (codec=="mp3") {
                          pausePosition=playingChannel.position;
                          playingChannel.stop();
                      }
                  }
                  public function stopSound():void {
                      if (codec=="m4a")
                          playingStream.close();
                      else if (codec=="mp3") {
                          pausePosition=0;
                          playingChannel.stop();
                      }
                      playingUrl="";
                  }
                  public function callBacks():void {
                      ExternalInterface.addCallback("play",playSound);
                      ExternalInterface.addCallback("pause",pauseSound);
                      ExternalInterface.addCallback("stop",stopSound);
                  }
          ]]&gt;
      &lt;/mx:Script&gt; 
  &lt;/mx:Application&gt;
  </code></pre>
  
  <p><br/><br/>
  and the basic HTML+Javascript<br/><br/></p>
  
  <pre><code>   &lt;html&gt;
  &lt;head&gt;
  &lt;script src='jquery.js'&gt;&lt;/script&gt;
  &lt;script&gt;
      function play() {
          //alert('clicked');
          var url=$("#url").val();
          var k=url.substring(url.length-3);
          fromFlash('testFlash').play(url);
          var b=document.getElementById('pp');
          b.setAttribute('src','pauseButton.jpg');
          b.setAttribute('onclick','pause()');
      }
      function pause() {
          fromFlash('testFlash').pause();
          var b=document.getElementById('pp');
          b.setAttribute('src','playButton.jpg');
          b.setAttribute('onclick','play()');
      }
      function stop() {
          fromFlash('testFlash').stop();
          var b=document.getElementById('pp');
          b.setAttribute('src','playButton.jpg');
          b.setAttribute('onclick','play()');
      }
      function fromFlash(movieName) {
          var isIE = navigator.appName.indexOf("Microsoft") != -1;
          return (isIE) ? window[movieName] : document[movieName];
      }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;object id="testFlash" width="0" height="0"&gt;
      &lt;param name="movie" value="player.swf"&gt;&lt;/param&gt;
      &lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;
      &lt;embed name="testFlash" src="player.swf" type="application/x-shockwave-flash" allowfullscreen="true" width="0" height="0"&gt;
      &lt;/embed&gt;
  &lt;/object&gt;
  &lt;input id="url"/&gt;
  &lt;span&gt;&lt;img id="pp" src="playButton.jpg" onclick="play()"/&gt;&lt;/span&gt;
  &lt;span&gt;&lt;img src="stopButton.jpg" onclick="stop()"/&gt;&lt;/span&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>