【问题标题】:jQuery UI Dialog with an embedded video problem in IE带有 IE 中嵌入视频问题的 jQuery UI 对话框
【发布时间】:2011-08-17 01:43:09
【问题描述】:

我有一个链接,点击它会打开一个 jQuery UI 对话框,数据通过 ajax 加载到对话框中,ajax 是一个嵌入式 Flash 视频(使用 flowplayer)。 IE中的问题是,当我单击链接时,对话框打开并且视频开始播放,而当我关闭对话框时,视频仍然继续播放。如果我再次单击该链接,则会打开对话框并播放视频,但不是从头开始。

主html文件有以下代码

<script type="text/javascript">
    $(document).ready(function(){
        var $dialog = $('<div> </div>');
        var dialogOpts = {
            title: "My Videos",
            modal: true,
            autoOpen: false,
            height: 500,
            width: 800
            };
        $('.videobox').one('click', function(){
            $dialog.load('data.html').dialog(dialogOpts);

        });             

        $('.videobox').click(function(event){       
            event.preventDefault();
            var url = event.target;     

            $dialog.dialog('open'); 
            return false;
            });
    })

</script>

点我!

远程文件有如下代码

<div id="player" style="width:640px;height:360px;"></div>
<script>
$f("player", "flowplayer-3.2.2.swf", "004.flv");
     </script>

在 FF、Safari 和 chrome 中一切正常,但在 ie 中,即使对话框关闭,视频也不会停止并继续播放。我花了很多时间进行调试,但似乎没有任何效果。请大家帮忙!!

【问题讨论】:

    标签: javascript jquery-ui


    【解决方案1】:

    用这个替换代码...

    <script type="text/javascript">
        $(document).ready(function(){
            var $dialog = $('<div> </div>');
            var dialogOpts = {
                title: "My Videos",
                modal: true,
                autoOpen: false,
                close: function() {
            $(this).dialog('destroy').empty();
        },
                height: 500,
                width: 800
                };
            $('.videobox').one('click', function(){
                $dialog.load('data.html').dialog(dialogOpts);
    
            });             
    
            $('.videobox').click(function(event){       
                event.preventDefault();
                var url = event.target;     
    
                $dialog.dialog('open'); 
                return false;
                });
        })
    
    </script>
    

    【讨论】:

      【解决方案2】:

      在对话框关闭时,您需要调用暂停,然后调用播放器的卸载方法。

      类似

      $f().pause().unload();
      

      【讨论】:

      • 我试过这个,但它不起作用。我如何解决这个问题是通过在关闭事件中销毁 dailog,然后将其完全从 dom 中删除。 flowplayer 的卸载对我不起作用。!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多