【问题标题】:how to determine if a slide has been triggered in a jquery slider如何确定是否在 jquery 滑块中触发了幻灯片
【发布时间】:2013-02-14 16:21:33
【问题描述】:

http://basic-slider.com/

我想知道如何确定一个对象是否在基本滑块中有滑动?如果出现滑块,我想暂停视频,但不知道如何确定是否出现滑块?

更新:

下面的代码显示了我如何在 Galleria 滑块中显示 jwplayer。但问题是它只显示一个黑色方块。没有出现滑块或视频播放器,我确实想为此使用 jwplayer:

<?php
                        //start:procedure video

     if(count($arrVideoFile[$key]) > 1){
    ?>

    <style>
        #galleriavideo_<?php echo $key; ?>{ width: 500px; height: 300px; background: #000 }
    </style>

     <div id="galleriavideo_<?php echo $key; ?>">
    <?php
    foreach ($arrVideoFile[$key] as $v) { ?>
    <div id="myElement-<?php echo $key.'-'.$i; ?>">Loading the player...

    <script type="text/javascript">


    jwplayer("myElement-<?php echo $key.'-'.$i; ?>").setup({
        file: "<?php echo 'VideoFiles/'.$v; ?>",
        width: 480,
        height: 270
    });

    <?php $i++; ?>
    </script>

    </div>
    <?php } ?>
    </div>

             <script type="text/javascript">

                Galleria.loadTheme('jquery/classic/galleria.classic.min.js');
                Galleria.run('#galleriavideo_<?php echo $key; ?>');

              </script>

    <?php

            }

【问题讨论】:

    标签: jquery jquery-slider


    【解决方案1】:

    您选择的滑块似乎无法处理事件。也许你应该选择另一个插件?例如Galleria 就有这种可能性。检查Documentation =&gt; Events,尤其是image

    如果您想保留基本滑块,您可以更改代码以在显示幻灯片时添加您想要的内容。更多信息在这里:jQuery event to trigger action when a div is made visible

    另一种解决方案是使用jQuery Watch plugin 并检测display 属性何时发生变化。

    就个人而言,我认为第一个解决方案是最简单的:)

    【讨论】:

    • 我会选择第一个解决方案,但你能帮我看看我在尝试实现 Galleria 滑块时做错了什么吗?它一直说 init failed: Galleria counld not find element 72 元素 72 是 $[key] in div。
    • 您在运行 Galleria 时忘记添加 #:该行应该是 Galleria.run('#galleriaimage_&lt;?php echo $key; ?&gt;');
    • 好的,在我给你投票和最佳答案之前,我的更新中还有一个问题。它正在处理尝试在 Galleria 滑块中显示 jwplayer
    • 您应该使用您的 jwplayer 创建另一个页面并在 iframe 中使用它。请参阅此处的显示 iframegalleria.io/docs/references/data
    • 如果你不介意你能展示一个关于如何为更新示例创建 ifrmae 的示例代码,我一直在尝试,但我认为我执行不正确。我已经标记了你的答案并投了赞成票,但请你给我看一个代码 sn-p,说明它应该如何实现以适合我的代码?
    猜你喜欢
    • 2013-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多