如何防止嵌入式Vimeo自动播放

时间:2010-12-27 16:40:33

标签: php wordpress slider vimeo

我有人在这个wordpress供电网站的水平滑块上工作:http://lifebridgecypress.org。这是主页自动播放嵌入式Vimeo视频的设置,该视频仅显示为主页上的第一张幻灯片。对于网站上的任何其他页面,视频不会显示,这就是我想要的。但我不知道如何将代码更改为当用户到达主页时视频无法自动播放的位置。 因此,我希望设置视频无法自动播放。

我还想知道是否有更简洁的方法来设置代码以实现相同的结果。这是代码......

<?php 
$options = get_option( 'sample_theme_options' );

$slide_1_title = $options['sometext11'];
$slide_1_image = $options['sometext12'];
$slide_1_url = $options['sometext13'];
$slide_1_text = $options['sometextarea1'];

$slide_2_title = $options['sometext21'];
$slide_2_image = $options['sometext22'];
$slide_2_url = $options['sometext23'];
$slide_2_text = $options['sometextarea2'];

$slide_3_title = $options['sometext31'];
$slide_3_image = $options['sometext32'];
$slide_3_url = $options['sometext33'];
$slide_3_text = $options['sometextarea3'];

$slide_4_title = $options['sometext41'];
$slide_4_image = $options['sometext42'];
$slide_4_url = $options['sometext43'];
$slide_4_text = $options['sometextarea4'];

$slide_5_title = $options['sometext51'];
$slide_5_image = $options['sometext52'];
$slide_5_url = $options['sometext53'];
$slide_5_text = $options['sometextarea5'];

$slide_6_title = $options['sometext61'];
$slide_6_image = $options['sometext62'];
$slide_6_url = $options['sometext63'];
$slide_6_text = $options['sometextarea6'];
?>
    <div id="newsSlider"> 
   <div class="lbutton"> 
    <a href="#" class="previous"></a> 
   </div>

<div class="container"> 
<!--<div class="ltrans"></div> -->
<ul class="slides"> 
<?php if (is_home()) { ?><?php if (!empty($slide_1_image)) { ?>
<li>
<div class="left1slider">
<?php if (preg_match ("/\b(?:vimeo)\.com\b/i", $slide_1_image)) { 
// replace
         $video_vim  = $slide_1_image;
         $vimdomain = array("http://vimeo.com/");
         $blank_text   = array("");
         $vim_id = str_replace($vimdomain, $blank_text, $video_vim);
?>
<object width="648" height="356"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vim_id; ?>&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vim_id; ?>&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="648" height="356"></embed></object>
         <?php } else { ?>
            <a href="<?php echo $slide_1_url; ?>" rel="bookmark">
            <img src="<?php echo $slide_1_image; ?>" width="648" height="356" alt="thumb" />
            </a>
         <?php } ?>
         </div>
         <div class="left2slider">
         <h4><?php echo $slide_1_title; ?></h4>
         <p>
         <?php print nl2br($slide_1_text); ?>
            <br>
            <a href="<?php echo $slide_1_url; ?>" class="readmore">GET DIRECTIONS...</a>
        </p>
         </div>
            </li>
            <?php } // END OF SLIDER ?> <?php } // dont show first slider on site except on homepage ?>

            <?php if (!empty($slide_2_image)) { ?>
            <li>
         <div class="left1slider">
         <?php if (preg_match ("/\b(?:vimeo)\.com\b/i", $slide_2_image)) { 
         // replace
         $video_vim  = $slide_2_image;
         $vimdomain = array("http://vimeo.com/");
         $blank_text   = array("");
         $vim_id = str_replace($vimdomain, $blank_text, $video_vim);
         ?>
         <object width="648" height="356"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vim_id; ?>&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vim_id; ?>&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="648" height="356"></embed></object>
         <?php } else { ?>
            <a href="<?php echo $slide_2_url; ?>" rel="bookmark">
            <img src="<?php echo $slide_2_image; ?>" width="648" height="356" alt="thumb" />
            </a>
         <?php } ?>
         </div>
         <div class="left2slider">
         <h4><?php echo $slide_2_title; ?></h4>
         <p>
         <?php print nl2br($slide_2_text); ?>
            <br>
            <a href="<?php echo $slide_2_url; ?>" class="readmore">Read More...</a>
        </p>
         </div>
            </li>
            <?php } // END OF SLIDER ?>

            <?php if (!empty($slide_3_image)) { ?>
            <li>
         <div class="left1slider">
         <?php if (preg_match ("/\b(?:vimeo)\.com\b/i", $slide_3_image)) { 
         // replace
         $video_vim  = $slide_3_image;
         $vimdomain = array("http://vimeo.com/");
         $blank_text   = array("");
         $vim_id = str_replace($vimdomain, $blank_text, $video_vim);
         ?>
         <object width="648" height="356"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vim_id; ?>&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vim_id; ?>&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="648" height="356"></embed></object>
         <?php } else { ?>
            <a href="<?php echo $slide_3_url; ?>" rel="bookmark">
            <img src="<?php echo $slide_3_image; ?>" width="648" height="356" alt="thumb" />
            </a>
         <?php } ?>
         </div>
         <div class="left2slider">
         <h4><?php echo $slide_3_title; ?></h4>
         <p>
         <?php print nl2br($slide_3_text); ?>
            <br>
            <a href="<?php echo $slide_3_url; ?>" class="readmore">More on 50/50...</a>
        </p>
         </div>
            </li>
            <?php } // END OF SLIDER ?>

            <?php if (!empty($slide_4_image)) { ?>
            <li>
         <div class="left1slider">
         <?php if (preg_match ("/\b(?:vimeo)\.com\b/i", $slide_4_image)) { 
         // replace
         $video_vim  = $slide_4_image;
         $vimdomain = array("http://vimeo.com/");
         $blank_text   = array("");
         $vim_id = str_replace($vimdomain, $blank_text, $video_vim);
         ?>
         <object width="648" height="356"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vim_id; ?>&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vim_id; ?>&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="648" height="356"></embed></object>
         <?php } else { ?>
            <a href="<?php echo $slide_4_url; ?>" rel="bookmark">
            <img src="<?php echo $slide_4_image; ?>" width="648" height="356" alt="thumb" />
            </a>
         <?php } ?>
         </div>
         <div class="left2slider">
         <h4><?php echo $slide_4_title; ?></h4>
         <p>
         <?php print nl2br($slide_4_text); ?>
            <br>
            <a href="<?php echo $slide_4_url; ?>" class="readmore">Read More about 72...</a>
        </p>
         </div>
            </li>
            <?php } // END OF SLIDER ?>

            <?php if (!empty($slide_5_image)) { ?>
            <li>
         <div class="left1slider">
         <?php if (preg_match ("/\b(?:vimeo)\.com\b/i", $slide_5_image)) { 
         // replace
         $video_vim  = $slide_5_image;
         $vimdomain = array("http://vimeo.com/");
         $blank_text   = array("");
         $vim_id = str_replace($vimdomain, $blank_text, $video_vim);
         ?>
         <object width="648" height="356"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vim_id; ?>&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vim_id; ?>&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="648" height="356"></embed></object>
         <?php } else { ?>
            <a href="<?php echo $slide_5_url; ?>" rel="bookmark">
            <img src="<?php echo $slide_5_image; ?>" width="648" height="356" alt="thumb" />
            </a>
         <?php } ?>
         </div>
         <div class="left2slider">
         <h4><?php echo $slide_5_title; ?></h4>
         <p>
         <?php print nl2br($slide_5_text); ?>
            <br>
            <a href="<?php echo $slide_5_url; ?>" class="readmore">Read More Details...</a>
        </p>
         </div>
            </li>
            <?php } // END OF SLIDER ?>

            <?php if (!empty($slide_6_image)) { ?>
            <li>
         <div class="left1slider">
         <?php if (preg_match ("/\b(?:vimeo)\.com\b/i", $slide_6_image)) { 
         // replace
         $video_vim  = $slide_6_image;
         $vimdomain = array("http://vimeo.com/");
         $blank_text   = array("");
         $vim_id = str_replace($vimdomain, $blank_text, $video_vim);
         ?>
         <object width="648" height="356"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vim_id; ?>&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vim_id; ?>&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="648" height="356"></embed></object>
<?php } else { ?>
<a href="<?php echo $slide_6_url; ?>" rel="bookmark"><img src="<?php echo $slide_6_image; ?>" width="648" height="356" alt="thumb" /></a>
<?php } ?></div>
<div class="left2slider">
         <h4><?php echo $slide_6_title; ?></h4>
         <p>
         <?php print nl2br($slide_6_text); ?>
            <br>
            <a href="<?php echo $slide_6_url; ?>" class="readmore">Read More</a>
        </p>
         </div>
            </li>
            <?php } // END OF SLIDER ?>

</ul> 

有谁知道怎么做?感谢您的帮助!哦,顺便说一句,所有这些代码都位于header.php文件中。

1 个答案:

答案 0 :(得分:1)

关闭自动播放机制,我认为将autoplay=1切换为autoplay=0就可以了。

您可以通过收集数组中的所有数据,然后在每个元素上运行foreach循环来更轻松地进行设置。

$slides = array();
// Repeat as many times as needed to add element to slide
$slides[] = array("title" => "sometext",
                  "image" => "some_other_text",
                  "url" => ....,
                  "text" => .....);

然后遍历每个元素

foreach ($slides as $slide)
 {
   echo $slide["title"]; // will contain the title
   echo $slide["image"]; // will contain the image

   etc....

 }