Vimeo仍然在froogaloop api卸载后玩

时间:2013-04-03 15:01:24

标签: zurb-foundation vimeo reveal.js froogaloop

我在一个画廊中使用基础4框架和Reveal模式作为灯箱效果托管了几个vimeo视频。不幸的是,视频在每个模态关闭后继续播放。

我还是jquery的新手所以我使用了Froogaloop api(https://developer.vimeo.com/player/js-api)来卸载每个vimeo视频,但是我无法让它工作。

这是我的代码:

        //Vimeo Froogaloop API event handler 
        function ready(player_id) {
            var player = $f(player_id),

            play = document.getElementById('play'),
            pause = document.getElementById('pause'),
            unload = document.getElementById('unload');

            play.addEventListener('click', function() {
                player.api('play');
            });

            pause.addEventListener('click', function() {
                player.api('pause');
            });

            unload.addEventListener('click', function() {
                player.api('unload');
                });
            }

            window.addEventListener('load', function() {
            //Attach the ready event to the iframe
            $f(document.getElementById('player')).addEvent('ready', ready);
        });

HTML:

        <!-- //Video Click Event -->
        <div class="row">
            <div class="large-12 columns">
                <div id="myModal3" class="reveal-modal">
                    <iframe id="player1" src="http://player.vimeo.com/video/62831216?api=1" width="720" height="406" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
                    <a class="close-reveal-modal" id="unload" href="#">x</a>
                </div>      
            </div>
        </div>      

        <div class="row">
            <div class="large-12 columns">
                <p><img src="http://placehold.it/250x100" class="logo"></p>
            </div>
        </div>



        <div class="row">
            <div class="large-12 columns">&nbsp;</div> 
        </div>

        <div class="row">
            <div class="large-12 columns">&nbsp;</div> 
        </div>   



        <!-- //Foundation 4 Accordion -->
        <div class="row">
            <div class="large-12 columns">
                <div class="section-container accordion" data-section="accordion">


                    <section class="section"> 
                        <div class="row">
                            <div class="large-5 columns"><p class="title"><a href="#"><img src="http://placehold.it/301x248"></a></p></div>
                                <div class="large-7 columns">
                                    <p class="title"><a href="#">Name</a><br> Title</p>
                                    <p class="quote">"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ac tempus libero."</p>
                                </div> 
                            </div>  

                            <div class="row">
                                <div class="large-12 columns">&nbsp;</div> 
                            </div> 

                            <div class="content">
                                <div class="row">
                                    <div class="large-12 columns">&nbsp;</div> 
                                </div> 

                            <div class="row">
                                <div class="large-12 columns">
                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus malesuada sapien ut nibh porttitor fringilla in sit amet risus. Curabitur euismod viverra elit sed pretium. Suspendisse laoreet tristique convallis. Aliquam erat volutpat. Morbi pharetra lobortis purus non elementum. Pellentesque mattis dignissim lectus in blandit. Duis facilisis vestibulum adipiscing. Suspendisse vulputate viverra consequat. In quis lorem ut tellus fringilla egestas. Etiam semper, dolor ut luctus dapibus, leo nunc scelerisque erat, eget aliquam dolor mauris ut risus. Nam non sem non libero laoreet bibendum quis in mi. Sed non nibh risus. Nunc id nunc felis. Maecenas eu est dui. In tortor justo, facilisis vel pulvinar a, bibendum vel tellus.</p>
                                </div> 
                            </div>

                            <div class="row">
                                <div class="large-12 columns">&nbsp;</div> 
                            </div> 

                            <div class="row">
                                <div class="large-12 columns">&nbsp;</div> 
                                </div>

                            <div class="row">
                                <div class="large-12 columns">
                                    <a href="#" data-reveal-id="myModal3" data-animation="fadeAndPop" data-animationspeed="300" data-closeonbackgroundclick="true" data-dismissmodalclass="close-reveal-modal">
                                        <img src="http://placehold.it/720x406">
                                    </a>

                                    <div class="row">
                                        <div class="large-12 columns">&nbsp;</div> 
                                    </div>     

                                    <div class="row">
                                         <div class="large-12 columns">                          
                                              <p class="subheader"><b>Client</b><br>
                                              <medium>"Title"</medium><br>
                                              <small>Location</small></p>
                                         </div> 
                                    </div> 
                                </div> 
                            </div>  

                            <div class="row">
                                <div class="large-12 columns">&nbsp;</div> 
                            </div>

                            <div class="row">
                                <div class="large-12 columns">&nbsp;</div> 
                            </div>

                        </div>
                    </section>

                </div>
            </div>
        </div>              

1 个答案:

答案 0 :(得分:0)

尝试使用此

 <script type="text/javascript">
 jQuery(document).ready(function($) {
   $('body').live('click',function(){
    if($('div.reveal-modal-bg').is(':visible')){
        var resourceVideo = $('#myModal iframe').attr('src');
        $('#myModal iframe').attr('src','').attr('src',resourceVideo);
        };
    })
});
</script>