开发者

Definition fl.video.FLVPlayback could not be found

I'm 开发者_如何学Cstumped. I have two flash files I'm authoring.

File A has a MovieClip on stage that has a linkage to a class in which I import fl.video.FLVPlayback File B also attempts to import fl.video.FLVPlayback.

File B throws a COMPILE TIME error that it cannot locate the definition for fl.video.FLVPlayback. I'm noticing that my FlashDevelop also offers no syntax highlighting for that line.

Both are exporting for the same version of FlashPlayer (10). Both are being authored on the same platform, the same software (CS4).I have not messed with any Publish settings, other than that File B is associated with a Document Class.

Of interest may be that File A will eventually be loaded into File B, into the context of File B.

What is up? I have no idea where to even start looking.

Thanks in advance.


If you're not using the FLVPlayback component (dragged from the component library onto the stage), then Flash does not have access to the fl package out of the box for publishing.

You would have to include either the component source folder or .swc on your class path (source folder would go in the "Source Path" tab of your as3 publish settings, .swc in the "Library Path" tab) in order for your class to work.

The source folder is: C:\Program Files (x86)\Adobe\Adobe Flash CS4\Common\Configuration\Component Source\ActionScript 3.0\FLVPlayback

The .swc is in the directory: C:\Program Files (x86)\Adobe\Adobe Flash CS4\Common\Configuration\Components\Video

The swc is probably easier to include as you can copy and paste the .swc directly into your project folder if you like.


Building on Sapptime's answer, I would like to add that you can create different profiles under Publish Settings.

So you can make a profile which includes the FLVPlayback component by importing the .swc file and use that profile when you need to work with the FLVPlayer. Adds about 100 KB to the project.

This way you don't need a FLVPlayback component in your library or on your stage. Instead, you can import the FLVPlayback class like any other class in your project and make instances of FLVPlayback in your actionscript code.

//import:
import fl.video.FLVPlayback;

//Instantiate:
private var player:FLVPlayback = new FLVPlayback();

I have added a Videoplayer.as class (because I can't find a way to attach it) I made for a project and stripped it quick and dirty for some additional content, but it should work :) Feel free to use it as is, modify it or get some inspiration.

Put Videoplayer.as in the src folder of your project and make a new instance of it. Use the setters to control it.

//Instantiate
var MyPLayer:Videoplayer = new Videoplayer();

//Use setters
MyPLayer.SetVideopath = path to flv file;
MyPLayer.SetVideoAutoplay = true; // or false
//... and so on

// add to displaylist
this.addChild(MyPlayer);

// Load video
MyPlayer.Load();

// start playing
MyPlayer.Play();

and here is the Videoplayer class...

package  {
import fl.video.*;
import flash.events.*;
import flash.display.Sprite;
import flash.display.Shape;

public class Videoplayer extends Sprite {

    // VIDEO
    private var player:FLVPlayback = new FLVPlayback();
    private static var videoPath:String="";
    private var w:Number = 1280;
    private var h:Number = 720;
    private var vol:Number = 0;
    private var autoplay:Boolean = false;
    private var autorewind:Boolean = false;
    private var Loop:Boolean = false;
    private var bgcolor:uint = 0x000000;
    private var HasError:Boolean=false;
    private var playerid:Number;
    private var SeekSecToStop:Number=0;
    private var BufferTime:Number=0;

    private var videoBG:Shape;

    // ===============================================================================================
    // CONSTRUCTOR
    // ===============================================================================================
    public function Videoplayer() {
        super();

        trace("Videoplayer");

        this.addChild(player);

        player.addEventListener(VideoEvent.STATE_CHANGE, VidState, false, 0, true);
        player.addEventListener(VideoEvent.READY, VidReady, false, 0, true);
        player.addEventListener(VideoEvent.AUTO_REWOUND, VidRewinded, false, 0, true);
        player.addEventListener(VideoEvent.STOPPED_STATE_ENTERED, VidStopped, false,0,true);

    }

    // ===============================================================================================
    // SET VIDEO PROPS
    // ===============================================================================================
    private function setVidProps():void {
        player.name = "player";
        player.skinBackgroundColor = getVideoBGcolor;
        player.skinBackgroundAlpha = 0;
        player.registrationX = 0;
        player.registrationY = 0;
        player.setSize(getVideoWidth,getVideoHeight);
        player.scaleMode = "maintainAspectRatio"; // exactFit, noScale, maintainAspectRatio
        //player.fullScreenTakeOver = false;
        player.isLive = false;
        player.bufferTime = BufferTime;
        player.autoRewind = getVideoAutorewind;

        player.volume = vol;

    }

    // ===============================================================================================
    // LOAD
    // ===============================================================================================
    public function Load():void {
        trace("Load");
        setVidProps();
        player.source = getVideopath;
    }

    // ===============================================================================================
    // PLAY
    // ===============================================================================================
    public function Play():void {
        player.playWhenEnoughDownloaded();
        UnMute();
    }

    public function Pause():void {
        player.pause();
    }

    public function Stop():void {
        //player.seek(SeekSecToStop);
        player.stop();
        //player.pause();
    }

    public function SeekAndStop():void {
        player.seek(SeekSecToStop);
        player.pause();
    }

    public function SeekAndPlay(n:Number=0):void {
        player.seek(n);
        Play();
    }

    public function Fullscreen():void {
        //player.fullScreenTakeOver = true;
        //player
    }

    public function Mute():void {
        player.volume = 0;
    }

    public function UnMute():void {
        player.volume = 1;
    }

    public function Volume(n:Number):void {
        player.volume=n;
    }

    // ===============================================================================================
    // VidReady
    // ===============================================================================================
    private function VidReady(e:Event):void {
        trace("VidReady");
        //player.removeEventListener(VideoEvent.READY, VidReady);
        player.fullScreenTakeOver = false;
        if (autoplay) {
            player.autoPlay = autoplay;
            Play();
        } else {
            player.play();
            SeekAndStop();
        }
        dispatchEvent(new VideoEvent(VideoEvent.READY));
    }

    // ===============================================================================================
    // VidStopped
    // ===============================================================================================
    private function VidStopped(e:Event):void {
        trace("VidStopped");
        //dispatchEvent(new VideoEvent(VideoEvent.STOPPED));
        if(Loop) {
            //SeekAndPlay();
            Play();
        } else {
            dispatchEvent(new VideoEvent(VideoEvent.STOPPED_STATE_ENTERED));
        }
    }

    // ===============================================================================================
    // VidRewinded
    // ===============================================================================================
    private function VidRewinded(e:Event):void {
        trace("VidRewinded");
    }

    // ===============================================================================================
    // VidState
    // ===============================================================================================
    private function VidState(e:Event):void {

        var flvPlayer:FLVPlayback = e.currentTarget as FLVPlayback;

        //Log("VideoState 1 : "+flvPlayer.state);

        if (flvPlayer.state==VideoState.CONNECTION_ERROR)   {
            trace("FLVPlayer Connection Error! -> path : "+flvPlayer.source);
            //dispatchEvent(new VideoEvent(VideoEvent.CONNECTION_ERROR));
            HasError=true;
            //CleanUp();
        } else if (flvPlayer.state==VideoState.BUFFERING)   {
            trace("BUFFERING");
        } else if (flvPlayer.state==VideoState.DISCONNECTED)    {
            trace("DISCONNECTED");
        } else if (flvPlayer.state==VideoState.LOADING) {
            trace("LOADING");
        } else if (flvPlayer.state==VideoState.PAUSED)  {
            trace("PAUSED");
        } else if (flvPlayer.state==VideoState.RESIZING)    {
            trace("RESIZING");
        } else if (flvPlayer.state==VideoState.REWINDING)   {
            trace("REWINDING");
        } else if (flvPlayer.state==VideoState.SEEKING) {
            trace("SEEKING");
        } else if (flvPlayer.state==VideoState.PLAYING) {
            trace("PLAYING");
        } else if (flvPlayer.state==VideoState.STOPPED) {
            trace("STOPPED");
            //flvPlayer.pause();
        } else if (flvPlayer.state==VideoState.RESIZING)    {
            trace("RESIZING");
        }
    }

    // ===============================================================================================
    // SETTERS & GETTERS
    // ===============================================================================================
    public function set SetPlayerId(n:Number):void {
        playerid=n;
    }
    public function get getPlayerId():Number {
        return playerid;
    }
    public function set SetSeekSecToStop(n:Number):void {
        SeekSecToStop=n;
    }
    public function get getSeekSecToStop():Number {
        return SeekSecToStop;
    }
    public function set SetVideoLoop(b:Boolean):void {
        Loop = b;
    }
    public function get getVideoLoop():Boolean {
        return Loop;
    }       
    public function set SetVideoAutorewind(b:Boolean):void {
        autorewind = b;
    }
    public function get getVideoAutorewind():Boolean {
        return autorewind;
    }
    public function set SetVideoAutoplay(b:Boolean):void {
        autoplay = b;
    }
    public function get getVideoAutoplay():Boolean {
        return autoplay;
    }
    public function set SetVideopath(s:String):void {
        videoPath = s;
    }
    public function get getVideopath():String {
        return videoPath;
    }
    public function set SetVideoWidth(n:Number):void {
        w = n;
    }
    public function get getVideoWidth():Number {
        return w;
    }
    public function set SetVideoHeight(n:Number):void {
        h = n;
    }
    public function get getVideoHeight():Number {
        return h;
    }
    public function set SetVideoBGcolor(n:uint):void {
        bgcolor = n;
    }
    public function get getVideoBGcolor():uint {
        return bgcolor;
    }
    public function get getPlayerState():String {
        return player.state;
    }
    public function get GetHasError():Boolean {
        return HasError;
    }
}
}


You need to make sure that the FLVPlayback component is present in you library and exported for ActionScript (which should be the default setting).

To add it to the library, simply open the Components panel (Window -> Components) and expand the group named Video and drag FLVPlayback in your library. No need to put it on the stage.

It should be exported by default as "fl.video.FLVPlayback".

Cheers

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜