使用JQuery(swfobject)动态加载新的Flash视频

时间:2012-03-29 11:58:14

标签: jquery video swfobject

我使用swfobject将Flash视频加载到我的网站中,如下所示 -

<div class="home-video-fade">
<div id="homevideo">
            <p class="noflash">Sorry, you must have JavaScript enabled, and have <a href="http://get.adobe.com/flashplayer/" title="Install Adobe Flash player.">Flash installed</a> in order to view this video.</p>
        </div>
</div>
<script type="text/javascript">
    //<![CDATA[
        var flashvars = {
                flvSource:      "_promo.f4v",
                playerWidth:    892,
                playerHeight:   380,
                iconOutHex:     "0xFFFFFF",
                iconOverHex:    "0x4992CE",
                iconToneOneHex: "0x929497",
                iconToneTwoHex: "0x6D6E70",
                navItemsBkgHex: "0x232323",
                hasMute:        "true",
                hasTimeDisplay: "true",
                hasVolume:      "true",
                hasFullScreen:  "true",
                hasAutoPlay:    "false",
                hasProgressBar: "true",
                posterURL:      "images/video-cover.jpg"
            },
            params = {
                wmode:          "transparent",
                allowscriptaccess:  "always",
                allowfullscreen:    true
            },

            attributes = null;

            swfobject.embedSWF(
                "flash/player.swf",
                "homevideo",
                "892", "380",
                "10.0.0",
                null,
                flashvars, params, attributes
            );
    //]]>
</script>

然后我有2个按钮。 按下每个按钮,我想淡出当前视频,
删除当前的Flash视频,
加载新的一个 然后在

中淡化新视频

我可以删除视频,我的问题是我无法弄清楚如何使用不同的flvsource再次调用swfobject。我目前的代码如下。

$('.video-thumb').each(function(index){
    var $this = $(this);
    $this.on('click', function(){

        //Video 1
        if(index == 0){
                        removeFlashVideo();
                    $('.videoOne').fadeOut(function(){
                                    //NEED TO ATTACH VIDEO HERE
                $('.videoTwo').fadeIn();
                })
        }
        //Video 2
        else if (index == 1){
            removeFlashVideo();
            $('.videoTwo').fadeOut(function(){
                                    //NEED TO ATTACH VIDEO HERE
                $('.videoOne').fadeIn();
                })
        }
    });
});
function removeFlashVideo(){
//remove flash video
$('.home-video-fade').fadeOut(function(){
    $('.home-video-fade').html('<div id="homevideo"><p class="noflash">Sorry, you must have JavaScript enabled, and have <a href="http://get.adobe.com/flashplayer/" title="Install Adobe Flash player.">Flash installed</a> in order to view this video.</p></div>');
});

}

0 个答案:

没有答案