How to load a MOV file into Flash 9

actionscript-3flashmoviequicktime

I am having issues loading an MOV file into Flash 9. When I google the question, I get alot of people say sure you can do it, but nobody provides working sample code.

Best Solution

The following is from http://en.wikipedia.org/wiki/Adobe_Flash#Flash_Video

Flash Video

Flash Video (.flv files) is a container format, meaning that it is not a video format in itself, but can contain other formats. The video in Flash is encoded in H.263, and starting with Flash player 8, it may alternatively be encoded in VP6. The audio is in MP3. The use of VP6 is common in many companies, because of the large adoption rates of Flash Player 8 and Flash Player 9.[16]

On August 20, 2007, Adobe announced on its blog that with Update 3 of Flash Player 9, Flash Video will also support the MPEG-4 international standard.[31] Specifically, Flash Player will have support for video compressed in H.264 (MPEG-4 Part 10), audio compressed using AAC (MPEG-4 Part 3), the MP4, M4V, M4A, 3GP and MOV multimedia container formats (MPEG-4 Part 14), 3GPP Timed Text specification (MPEG-4 Part 17) which is a standardized subtitle format and partial parsing support for the 'ilst' atom which is the ID3 equivalent iTunes uses to store metadata. Adobe also announced that they will be gradually moving away from the proprietary FLV format to the standard MP4 format owing to functional limits with the FLV structure when streaming H.264. The final release of the Flash Player supporting MPEG-4 had become available in Fall 2007.[32]

package com.yourdomain.packageName
{
    import flash.display.Sprite;
    import flash.media.Video;
    import flash.net.NetConnection;
    import flash.net.NetStream;

    public class DocumentClass extends Sprite
    {
        private var _video:Video;
        private var _nc:NetConnection;
        private var _ns:NetStream;

        public function DocumentClass():void
        {
            _video = new Video(800, 600);
            addChild(_video);

            _nc = new NetConnection();
            _nc.connect(null);

            _ns = new NetStream(nc);
            _video.attachNetStream(_ns);
           _ns.play("path/to/file.extension");
        }
    }
}

-This is a very basic implementation and does not include handling of meta-data.

First, we instantiate a Video object that is 800 wide and 600 tall and add it to the display list.

Second, we instantiate a NetConnection object and call it's connect method passing null as a parameter. (This is required)

Third, we create a NetStream object, passing the previously made NetConnection object to it's constructor.

Fourth, we set attachNetStream of the Video object to _ns, the NetStream we instantiated.

Finally, we call the play method of the NetStream object, _ns, and pass it a string to where our media is located. (The FLV/F4V/MOV/etc.)

Hope this helps.