fullpage 视频播放暂停_编程笔记

fullpage 视频播放暂停

2023-12-05 21:05:51  浏览:718  作者:保利尼奥
<div class="banner_swiper" {{ app(&#39;visual&#39;).url(&#39;section&#39;, 16079) }}> <div class="swiper-wrapper"> {% ...
<div class="banner_swiper" {{ app('visual').url('section', 16079) }}>
    <div class="swiper-wrapper">
        {% for value in app('section').id(16079) %}
        <div class="swiper-slide">
            <a href="{{ value.url }}">
                {% if value.video !='' %}
                <video class="myVideo" src="{{ value.video | videos_url }}" width="100%" height="100%" controls autoplay loop muted></video>
                {% else %}
                <img src="{{ value.img | img_format }}" alt="{{ value.name }}" />
                {% endif %}
            </a>
        </div>
        {% endfor %}
    </div>
    <div class="swiper-pagination"></div>
</div>
// fullpage
        $('#fullpage').fullpage({
            anchors: ['Page1', 'Page2', 'Page3', 'Page4', 'Page5', 'Page6', 'Page7', 'Page8'],
            css3: true,
            scrollingSpeed: 1000,
            responsiveWidth: 1025,
            keyboardScrolling: true,
            navigation: true,
            afterLoad: function(anchorLink, index) {
                if (index.index == 3) {
                    $('.counter').countUp();
                }else if (index.index == 4){
                    $('.counter').countUp();
                }
            },

            onLeave: function(anchorLink, index, direction){
                if (index.index == 1) {
                    var videos = document.getElementsByClassName('myVideo');
                    for (var i = 0; i < videos.length; i++) {
                        videos[i].pause(); // 在离开第一屏时暂停所有视频播放
                    }
                } else {
                    var videos = document.getElementsByClassName('myVideo');
                    for (var i = 0; i < videos.length; i++) {
                        videos[i].play(); // 在回到第一屏时播放所有视频
                    }
                }
            }

        });


上一篇:圆圈发散 css

下一篇:CSS 进度条

评论区

共 0 条评论
  • 这篇文章还没有收到评论,赶紧来抢沙发吧~

【随机内容】

返回顶部