taikoo / rubyizumi

Automatically exported from code.google.com/p/rubyizumi
GNU Affero General Public License v3.0
0 stars 0 forks source link

NetStream.close() doesn't work #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. ruby server.rb -v 0 -d -l rubyizumi.log /home/rubyizumi/mp4s/
2. in the Player ns.close();
3. doesn't stop NetStream

What is the expected output? What do you see instead?
I need the stream closed.
Multiple streams in action after two ns.close()...
From log:
[2008-06-06T00:15:00.976619 #7936] DEBUG -- : > func:closeStream
D, [2008-06-06T00:15:01.176998 #7936] DEBUG -- : < time:13.961
D, [2008-06-06T00:15:01.324992 #7936] DEBUG -- : < time:385.111
D, [2008-06-06T00:15:02.241006 #7936] DEBUG -- : < time:15.025
D, [2008-06-06T00:15:02.329124 #7936] DEBUG -- : < time:386.115
D, [2008-06-06T00:15:03.261018 #7936] DEBUG -- : < time:16.045
D, [2008-06-06T00:15:03.334524 #7936] DEBUG -- : > #<RTMP::Packet:0xb7c6e370 
@types={}, @parsed=false, @frame=2, @data="\005\252}P", @obj=0, @size=4, 
@data_type=3, 
@parsed_data=nil, @timer=0>
D, [2008-06-06T00:15:03.341061 #7936] DEBUG -- : < time:387.127
D, [2008-06-06T00:15:04.293019 #7936] DEBUG -- : < time:17.077
D, [2008-06-06T00:15:04.437012 #7936] DEBUG -- : < time:388.223

What version of the product are you using? On what operating system?
rubyizumi_0.12_r41 on 2.6.24-gentoo-r4

Please provide any additional information below.
I'm using states to manage buttons play & stop.
Follow modified Player.as:
/* Minimal Player for RubyIZUMI */

package {

    import flash.display.Sprite;  
    import flash.net.NetConnection;
    import flash.events.NetStatusEvent;
    import flash.events.SecurityErrorEvent;
    import flash.events.AsyncErrorEvent;
    import flash.media.Video;
    import flash.net.NetStream;
    import flash.net.ObjectEncoding;
    import flash.text.TextField;
    import flash.text.TextFieldType;
    import flash.events.MouseEvent;

    public class Player extends Sprite 
    {
        private var _connection : NetConnection;
        private var _stream : NetStream;
        private var _video : Video=new Video(498, 373);
        private var playBtn : NetBtn;
        private var stopBtn : NetBtn;
        private var vidTest : VideoWorks;
        private var flv : String="test.mp4";
        public function Player() 
        {
            _connection = new NetConnection();
            _connection.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
            _connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, 
onSecurityError);
            _connection.objectEncoding = ObjectEncoding.AMF0;
            _connection.connect("rtmp://localhost/");

            _video.x=1;
            _video.y=1;
            addChild(_video);

            //Instantiate State Machine
         vidTest=new VideoWorks();

            //Play and Stop Buttons
            playBtn=new NetBtn("PLAY ");
            addChild (playBtn);
            playBtn.x=(stage.stageWidth/2)-34;
            playBtn.y=354;
            stopBtn=new NetBtn("STOP ");
            addChild (stopBtn);
            stopBtn.x=(stage.stageWidth/2)+12;
            stopBtn.y=354;

//Add Event Listeners
         playBtn.addEventListener (MouseEvent.CLICK,doPlay);
         stopBtn.addEventListener (MouseEvent.CLICK,doStop);

        }

        private function onNetStatus( event : NetStatusEvent ) : void
        {
            switch(event.info.code){
            case "NetConnection.Connect.Success":
                _stream = new NetStream(_connection);
                _stream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                _stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);

                //var video : Video = new Video(498, 373);
                _video.attachNetStream(_stream);
                _video.deblocking = 2;
                _video.smoothing = true;
                /*video.x=(stage.stageWidth/2)-(video.width/2);
                video.y=(stage.stageHeight/2)-(video.height/2);*/

                _stream.play(flv);

                //_video = video

                break;

            case "NetStream.Play.StreamNotFound":
                trace("File not found");
                break;
            }
        }

        //Start play
        private function doPlay (e:MouseEvent):void
        {
            vidTest.startPlay (_stream,flv);
            _video.attachNetStream (_stream);
        }
        //Stop play
        private function doStop (e:MouseEvent):void
        {
            vidTest.stopPlay (_stream);
            _video.clear();
        }

        private function onSecurityError( event : SecurityErrorEvent ) : void
        {
        }

        private function onAsyncError( event : AsyncErrorEvent ) : void
        {
        }
    }
}

Original issue reported on code.google.com by fralos...@gmail.com on 5 Jun 2008 at 10:34

GoogleCodeExporter commented 9 years ago
PlayState.as:
package 
{
  import flash.net.NetStream;
  //Play State

  public class PlayState implements State
  {
    private var videoWorks:VideoWorks;
    public function PlayState(videoWorks:VideoWorks)
    {
      trace("--Play State--");
      this.videoWorks=videoWorks;
    }
    public function startPlay(ns:NetStream,flv:String):void
    {
      trace("You're already playing");
    }
    public function stopPlay(ns:NetStream):void
    {

    ns.close();
      trace("Stop playing.");
      videoWorks.setState(videoWorks.getStopState());
    }
  }
}

Original comment by fralos...@gmail.com on 7 Jun 2008 at 10:07