jquery视频弹出覆盖不在IE中关闭视频

时间:2011-06-26 19:58:11

标签: jquery asp.net overlay swfobject

使用此处的代码:

How to popup a jquery window to play youtube video?

我创建了以下内容:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>
<script src="js/swfobject.js"></script>
</head>
<body>
<script language="javascript" type="text/javascript">

    $(function () {
        var videoModal = $('#video-modal').overlay({
            expose: {
                color: 'black',
                loadSpeed: 200,
                opacity: 0.85
            },
            closeOnClick: true,
            api: true
        });

        $('.video-link').click(function () {
            videoModal.load();

            var videoUrl = $(this).attr('href');
            var flashvars = {};
            var params = {
                allowFullScreen: "true",
                allowscriptaccess: "always"
            };
            var attributes = {};

            swfobject.embedSWF(videoUrl, 'video-container', '425', '344', '9.0.0', '', flashvars, params, attributes);

            return false;
        });
    });

</script>
    <form id="form1" runat="server">
   <a href="http://www.youtube.com/v/2cxqZiWyW3g&hl=en_US&fs=1&autoplay=1"
    class="video-link">Video 1</a>
<a href="http://www.youtube.com/v/607RMNoJfl4&hl=en_US&fs=1&autoplay=1"
    class="video-link">Video 2</a>

<div class="modal" id="video-modal">
    <div id="video-container" style="width: 425px; height: 344px;"></div>
</div>



    </form>
</body>
</html>

它在firefox中按预期工作(点击视频容器外的任何地方,弹出窗口关闭,视频停止播放)。在IE中 - 视频继续播放。关于如何阻止视频在IE中播放的任何想法?

当我使用swfobject.removeSWF时,我无法再点击任何链接并让我的电影再次“打开”。这是我到目前为止的地方:

<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        var videoModal = $('#video-modal').overlay({
            expose: {
                color: 'black',
                loadSpeed: 200,
                opacity: 0.85
            },
            closeOnClick: true,
            api: true,
            onClose: function () {
                swfobject.removeSWF('video-container');
            }
        });

        $('.video-link').click(function () {
            videoModal.load();

            var videoUrl = $(this).attr('href');
            var flashvars = {};
            var params = {
                allowFullScreen: "true",
                allowscriptaccess: "always"
            };
            var attributes = {};
            swfobject.createSWF({ data: this.href, width: "425", height: "344" }, params, 'video-container');


            return false;
        });


    });


</script>

1 个答案:

答案 0 :(得分:1)

要在关闭Flash视频时将其停止或隐藏,请拨打swfobject.removeSWF('video-container')

在您使用的重叠文档http://flowplayer.org/tools/overlay/index.html中,我们看到有close()和onlose,您可以在关闭对话框时调用上述函数来停止视频。

我必须告诉你,如果你不打电话给removeSWF,视频不会在任何浏览器上停止。只是mozilla停在他身边,或隐藏它而你看不到它,我不知道,但是你需要调用这个命令来阻止它。