开发者

Flex 4,image create snapshoot from video display?

my code works on localhost,but not on the server,what could be the problem?I also want to return some string back from php to flex app but I can't solve that. Here is my code :

        [Bindable]
        public var encodedString:String;
        [Bindable]
        public var img_name:String;
        [Bindable]
        public var pid:int;         
        [Bindable]
        public var url_string:String;                   

        protected function btn_save_clickHandler(event:MouseEvent):void
        {
            var bmpData:BitmapData = new BitmapData(videoDisplay.width,videoDisplay.height-25);             
            bmpData.draw(videoDisplay);

            var bm:Bitmap = new Bitmap(bmpData);  
            img.source = bm;  

            var jpg_e:JPEGEncoder = new JPEGEncoder();
            var bytes:ByteArray = new ByteArray();
            bytes = jpg_e.encode(bmpData);

            var b64e:Base64Encoder = new Base64Encoder()开发者_运维知识库
            b64e.encodeBytes(bytes);

            encodedString = b64e.flush();

        }


        protected function btn_save_image_clickHandler(event:MouseEvent):void
        {
            // TODO Auto-generated method stub      
            save_img.send();
        }                       

        <mx:request xmlns="">
            <img_data>                  
                {encodedString}
            </img_data>
            <image_name>
                {img_name}
            </image_name>
            <post_id>
                {pid}
            </post_id>
        </mx:request>

    </mx:HTTPService>

When click save,I want to save snapshoot from videodisplay to img.Also I send image to php,and want to get simple text answer that is done,but I always get object returned.

and I save image with php,and just print message,like this :

print "this is message!";

I think the problem is when I need to save image from control(video display) to image control,but this problem only occure on server but not on localhost


You need to change the last line from:

str = b64e; 

To:

str = b64e.toString(); 

Note that calling toString() will clear the b64e object.

Update:

Let's try placing the video in a container, and then doing the .draw() on that, we'll add some additional content to it so that we can get that if the video doesn't show up.

<s:Group id="videoContainer">
  <mx:Label text="Hello" />
  <mx:VideoDisplay id="videoDisplay" />
</s:Group>

Hopefully you are already doing the VideoDisplay part of this, and you can update your code to add the containing group.

When you do the .draw() use videoContainer instead of videoDisplay ie. :

 bmpData.draw(videoContainer);

This is just to test, if there is a sandbox issue, which it defintely seems to be, only "Hello" will show up in the bitmap, and the video will still not be seen.


Where does that video come from? Camera? FMS?

It might be either a crossdomain issue or something related to FMS (or another streaming server).

This post could help you : How do I specify a crossdomain policy file to allow Flash to grab a bitmap from an RTMP (Wowza) video stream?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜