按下按钮时会显示视频播放器吗?

时间:2015-02-18 14:22:41

标签: javascript php html

我想制作一个视频博客并使用多个视频播放器,youtube和jwplayer。我如何制作它以便youtube播放器默认显示,并且在它下方有一个按钮,当按下按钮时,jwplayer出现并替换youtube。

如果有人能告诉我使用的代码,那就太棒了,感谢大家提前帮忙!

2 个答案:

答案 0 :(得分:0)

你是说这样的意思吗?警告没有自己测试代码但应该工作。

    <form method="post">
    <input name="button" type="submit" />
    </form>


    <?php

    if (!empty('$_POST')){
        //jwplayer video
    }
    else{
        //youtubevideo
    }

    ?>

答案 1 :(得分:0)

敲了一个简单的例子:

http://jsfiddle.net/xxktz511/4/

它使用这一点javascript和jQuery框架来更改父博客项的子元素。根据您的说法,您将在页面上显示许多博客条目。

// Use the jQuery plugin to find all DOM element that have a class of 'switch player'
// You can read up on jquery here: http://jquery.com/
$('.switch_player').click(
    function(e) {
        // Make a jQuery instance based on the 'currentTarget' or 'click' element
        // Find that element parent that is the actual blog entry
        var $blogEntry = $(e.currentTarget).parent();        
        // Then find all children that have either a youtube_video class or
        // jqPlayer class and toggle their display status
        $blogEntry.children('.youtube_video').toggle();
        $blogEntry.children('.jwplayer_video').toggle();
    }  
);

如果视频时间相同,则jwplayer可以从给定点开始流。它在文档中。但是我不知道你是如何从youtube获得当前时间的。

如果您对设计有任何疑问,请与我们联系。