无论如何,我可以将鼠标悬停在影片剪辑上以自动播放电影吗? [英] Is there anyway that I can put an movie clip on mouse-over to autoplay my movie?

查看:204
本文介绍了无论如何,我可以将鼠标悬停在影片剪辑上以自动播放电影吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在鼠标悬停时自动播放视频. 有人可以告诉我如何通过媒体播放器或Flash播放器播放它吗?

I want to autoplay my video on mouse over. Can anybody tell me how to make it play via media player or flash player?

PS:我可以在Flash Player中播放WMV/ASF/MP4吗?

PS: Can I play WMV/ASF/MP4 in flash player?

推荐答案

好吧,我发现最容易使用swf文件在浏览器中显示电影的原因有两个:易于使用javascript控制它们并且它们可以在旧的浏览器. (很容易将任何电影格式转换为swf).

Well I have found that it is easiest to use swf files to show movies in the browser for two reasons: Easy to use javascript to control them and they work in old browsers. (It is easy to convert any movie format to swf).

还有瑞士法郎的简单性,我当时进行了相当深入的调查,即使我愿意花时间研究和编程,也找不到一个Flash Player可以让我100%地控制它.

Also there is the simplistic freedom of the swf, I looked into at the time quite intensively and could not find a single flashplayer that allowed me to control it 100% even if I was willing to spend time researching and programming.

幸运的是,我有一个简单的JS框架,我使自己可以在网页中嵌入和控制电影(应该在所有浏览器中都可以使用)[注意:我对JS类的了解要比现在少. /p>

And luckily for you I have a simple JS framework I made myself for embedding and controlling movies in a webpage (should work in all browsers) [Note: I understood JS classes back then even less then I do now so].

//http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html

function FlashController(name)
{
    this.flashMovie = this.getFlashMovieObject(name);

    this.getXPos =        function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 0));
                };

    this.getYPos =        function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 1));
                };

    this.getXScale =    function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 2));
                };

    this.getYScale =    function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 3));
                };

    this.getNextFrame =    function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 4));
                };

    this.getCurrentFrame =    function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 4) - 1);
                };

    this.getTotalFrames =    function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 5));
                };

    this.getAlpha =        function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 6));
                };

    this.getVisibility =    function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 7));
                };

    this.getWidth =        function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 8));
                };

    this.getHeight =    function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 9));
                };

    this.getRotation =    function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 10));
                };

    this.getTarget =    function()
                {
                    return (this.flashMovie.TGetProperty("/", 11));
                }
    this.getFramesLoaded =    function()
                {
                    return (this.flashMovie.TGetPropertyAsNumber("/", 12));
                };

    this.getName =        function()
                {
                    return (this.flashMovie.TGetProperty("/", 13));
                };

    this.getDropTarget =    function()
                {
                    return (this.flashMovie.TGetProperty("/", 14));
                };

    this.getURL =        function()
                {
                    return (this.flashMovie.TGetProperty("/", 15));
                };

    this.getHighQuality =    function()
                {
                    return (this.flashMovie.TGetProperty("/", 16));
                };

    this.getFocusRect =    function()
                {
                    return (this.flashMovie.TGetProperty("/", 17));
                };

    this.getSoundBufTime =    function()
                {
                    return (this.flashMovie.TGetProperty("/", 18));
                };

    this.setXPos =        function(value)
                {
                    this.flashMovie.TSetProperty("/", 0, value);
                };

    this.setYPos =        function(value)
                {
                    this.flashMovie.TSetProperty("/", 1, value);
                };

    this.setXScale =    function(value)
                {
                    this.flashMovie.TSetProperty("/", 2, value);
                };

    this.setYScale =    function(value)
                {
                    this.flashMovie.TSetProperty("/", 3, value);
                };

    this.setAlpha =        function(value)
                {
                    this.flashMovie.TSetProperty("/", 6, value);
                };

    this.setVisibility =    function(value)
                {
                    this.flashMovie.TSetProperty("/", 7, value);
                };

    this.setRotation =    function(value)
                {
                    this.flashMovie.TSetProperty("/", 10, value);
                };

    this.setName =        function(value)
                {
                    this.flashMovie.TSetProperty("/", 13, value);
                };

    this.setHighQuality =    function(value)
                {
                    this.flashMovie.TSetProperty("/", 16, value);
                };

    this.setFocusRect =    function(value)
                {
                    this.flashMovie.TSetProperty("/", 17, value);
                };

    this.setSoundBufTime =    function(value)
                {
                    this.flashMovie.TSetProperty("/", 18, value);
                };

    this.getVariable =    function(path)
                {
                    return (this.flashMovie.GetVariable(path));
                };

    this.gotoFrame =    function(num)
                {
                    var loaded = getFramesLoaded();
                    if(num > loaded)
                    {
                        return (this.flashMovie.GoToFrame(loaded));
                    }
                    return (this.flashMovie.GoToFrame(num));
                };

    this.isPlaying =    function()
                {
                    return (this.flashMovie.IsPlaying());
                };

    this.loadMovie =    function(layerNum, url)
                {
                    return (this.flashMovie.loadMovie(layerNum, url));
                };

    this.panPixels =    function(hPx, vPx)
                {
                    this.flashMovie.Pan(hPx, vPx, 0);
                };

    this.panPercent =    function(hP, vP)
                {
                    this.flashMovie.Pan(hP, vP, 1);
                };

    this.getPercentLoaded =    function()
                {
                    var value = Math.round(movieControls.getFramesLoaded()/movieControls.getTotalFrames() * 100);
                    if(isNaN(value))
                    {
                        value = 0;
                    }
                    return (value);
                };

    this.play =        function()
                {
                    this.flashMovie.Play();
                };

    this.rewind =        function()
                {
                    this.flashMovie.Rewind();
                };

    this.setVariable =    function(path, value)
                {
                    this.flashMovie.setVariable(path, value);
                };

    this.zoomRect =        function(left, top, right, bottom)
                {
                    this.flashMovie.SetZoomRect(left, top, right, bottom);
                };

    this.stop =        function()
                {
                    this.flashMovie.StopPlay();
                };

    this.zoom =        function(percent)
                {
                    this.flashMovie.Zoom(percent);
                };

    this.zoomReset =    function()
                {
                    this.flashMovie.Zoom(0);
                };

    this.callFrame =    function(frame)
                {
                    this.flashMovie.TCallFrame("/", frame);        
                };

    this.callLabel =    function(label)
                {
                    this.flashMovie.TCallLabel("/", label);        
                };

    this.currentLabel =    function()
                {
                    return (this.flashMovie.TCallLabel("/"));        
                };

    this.goToFrame =    function(num)
                {
                    this.flashMovie.TGotoFrame("/", num);
                };

    this.goToLabel =    function(label)
                {
                    this.flashMovie.TGotoLabel("/", label);
                };
/*
//Description: Generated as the Flash movie is downloading. The argument type is integer.
    this.OnProgress =    function(percent)
                {
                };

//Description: Generated when the ready state of the control changes.
//The possible states are:
//0=Loading, 1=Uninitialized, 2=Loaded, 3=Interactive, 4=Complete.
    this.OnReadyStateChange =    function(state)
                    {
                    };    

//Description: Generated when an FSCommand action is performed in the movie with a URL
//and the URL starts with FSCommand :
//Use this to create a response to a frame or button action in the Flash movie.
//The argument type is string.
    this.FSCommand =    function(command, args)
                {
                };*/        

    this.nextFrame =    function()
                {
                    var nextFrame = getNextFrame();
                    if(nextFrame >= getTotalFrames())
                    {
                        nextFrame = 0;
                    }

                    goToFrame(nextFrame);
                };
}

FlashController.prototype.getFlashMovieObject = function(movieName)
{
    if (window.document[movieName])
    {
        return (window.document[movieName]);
    }
    if (navigator.appName.indexOf("Microsoft Internet")==-1)
    {
        if (document.embeds && document.embeds[movieName])
        {
            return (document.embeds[movieName]);
        }
    }
    else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
    {
        return (document.getElementById(movieName));
    }
}

FlashController.embedVideo = function(location, name, filePath, bgColor, width, height)
{
    location.innerHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
                + 'codebase="" id="' + name + '" width=' + width + ' height=' + height + '>'
                + '<param name="movie" value="' + filePath + '">'
                + '<embed play=false swliveconnect=true name="' + name + '" '
                + 'src="' + filePath + '" quality="high" '
                + 'bgcolor=' + bgColor + ' width=' + width + ' height=' + height + ' type="application/x-shockwave-flash">'
                + '</embed></object>';

}

要使用(我想已经有一段时间了):

To use (I think, it has been awhile):

FlashController.embedVideo(nodeToPutItIn, "movie.swf", fullPathToSWF, backGroundColor, width, height); //Or simply hard code into the webpage.
var myMovie = new FlashController("movie.swf");
nodeToPutItIn.onMouseOver = "myMovie.play();";  //never actually done this command before so syntax might be off.
//Note: you have to wait for the movie to load if it is over a slow connection or it is big.

如果您还有其他具体问题,请随时提出.

If you have any more specific questions then feel free to ask.

这篇关于无论如何,我可以将鼠标悬停在影片剪辑上以自动播放电影吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆