Jump to content

Flash video not working.


The Little Guy

Recommended Posts

I have a flash player that when loaded works in my browser on my local machine (file:///C:/Flash/player.swf) but when I upload it to my web server, it stops working.

 

I am using the YouTube ActionScript API I can get the video. and show it in my player and all, its jut that my custom play/stop buttons don't display/work on my web server. This is very confusing, why would this be happening?

 

I am appending a unique query string to the end of the file:

 

/incl/flash/player.swf?md5=<?php echo md5(time()); ?>

 

That should be requiring it to not cache. I am using swfobject to embed it, but that shouldn't matter because if you view just the swf file it still doesn't work.

 

ActionScript:

package{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.system.Security;
    import flash.display.Loader;
    import flash.net.URLRequest;
    public class Main extends Sprite{
        Security.allowDomain("www.youtube.com");
        
        public var player:Object;
        public var vidid:String = 'CUBrA_cD_Io';
        public var loader:Loader = new Loader();
        public var playBtn:Play = new Play();
        public var pauseBtn:Pause = new Pause();
        
        public function Main(){
            loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
            loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
        }
        function onLoaderInit(event:Event):void {
            addChild(loader);
            loader.content.addEventListener("onReady", onPlayerReady);
            loader.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
            playBtn.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
            pauseBtn.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
            
            loader.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
            
            loader.addEventListener(MouseEvent.CLICK, onClick);
            playBtn.addEventListener(MouseEvent.CLICK, onClick);
            pauseBtn.addEventListener(MouseEvent.CLICK, onClick);
            
            
            /*loader.content.addEventListener("onError", onPlayerError);
            loader.content.addEventListener("onStateChange", onPlayerStateChange);
            loader.content.addEventListener("onPlaybackQualityChange", 
                onVideoPlaybackQualityChange);*/
        }
        function onPlayerReady(e:Event):void {
            player = loader.content;
            player.setSize(stage.stageWidth, stage.stageHeight);
            //vidid = stage.loaderInfo.parameters["id"];
            player.cueVideoById(vidid, 0);
        }
        function onMouseOver(e:MouseEvent){
            addPP();
        }
        
        function addPP(){
            if(player.getPlayerState()==1){
                pauseBtn.x = (stage.stageWidth - pauseBtn.width) / 2;
                pauseBtn.y = (stage.stageHeight - pauseBtn.height) / 2;
                addChild(pauseBtn);
            }
            if(player.getPlayerState()==2){
                playBtn.x = (stage.stageWidth - playBtn.width) / 2;
                playBtn.y = (stage.stageHeight - playBtn.height) / 2;
                addChild(playBtn);
            }
        }
        
        function onMouseOut(e:MouseEvent){
            removePP();
        }
        function removePP(){
            try{
                removeChild(pauseBtn);
            }catch(ev){}
            try{
                removeChild(playBtn);
            }catch(ev){}
        }
        function onClick(e:MouseEvent){
            if(player.getPlayerState()==1){
                player.pauseVideo();
            }else if(player.getPlayerState()==2){
                player.playVideo();
            }
            removePP();
            addPP();
        }
    }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.