WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Video Plugin
how to play youtube videos one after another (4 posts)

  1. radiofranky
    Member
    Posted 3 years ago #

    Hi,
    I was wondering if is possible to auto play youtube videos in sequential?

    for example [youtube xjidjdj, sjdijidjsi, jdij8j33, ue9jdjf]

    It will show there're 4 parts to it, and once the first video finises, the second one starts automatically.

    i got some code but don't know how to integrate into video plugin

    /* Youtube Player */
    var ids = new Array();
    var curId = 0;
    function SetupVideoPlayer() {
    ids = $(".video_ids").text().split(',');
    if (ids.length > 1 && ids[0].length > 4){
    $('.node_body').append("<div class=\"video_wrapper\"></div>");
    $('.video_wrapper').append('<div class="video_note">Subsequent part(s) will play automatically when the current part finishes playing.</div>');
    $('.video_wrapper').append('<div id="ytapiplayer">You need Flash player 8+ and JavaScript enabled to view this video.</div>');
    $('.video_wrapper').append('<div class="video_nav"></div>');

    var params = { play: "false", allowScriptAccess: "always", allowFullScreen: "true", wmode:"transparent" };
    var atts = { id: "myytplayer", play: "false" };
    swfobject.embedSWF("http://www.youtube.com/v/"+ids[0]+"?enablejsapi=1&playerapiid=ytplayer&fs=1&showinfo=0",
    "ytapiplayer", "680", "500", "8", null, null, params, atts);

    if (ids.length > 1){
    for (i=0;i<ids.length;i++)
    {
    $('.video_nav').append('Part ' + (i+1) + ' ');
    }
    }
    if (ids.length == 1)
    $('.video_note').remove();
    $('.video_nav .part_0').addClass("active_part");

    }
    return false;
    }

    var first_time_video_load = true;
    var ytplayer;
    function onYouTubePlayerReady(){
    ytplayer = document.getElementById('myytplayer');
    ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
    if (!first_time_video_load)
    ytplayer.loadVideoById(ids[0]);
    first_time_video_load = false;
    }

    function onytplayerStateChange(newState) {
    if (newState == 0 && curId < ids.length - 1){
    PlayPart(curId + 1);
    }
    }

    function ResetPartLinkWeight(){
    for (i=0;i<ids.length;i++)
    {
    $('.video_nav .part_' + i).removeClass("active_part");
    }
    }
    function PlayPart(n){
    if (n>=0 && n<ids.length){
    if (ytplayer) {
    setTimeout("ytplayer.loadVideoById('"+ids[n]+"')", 1000);
    curId = n;
    ResetPartLinkWeight();
    $('.video_nav .part_' + n).addClass("active_part");
    }
    }
    }

    function FetchSelectedShoutcast() {
    comment_parent_id = $(this).attr("href").split('v=')[1];
    $(".videos").animate({marginRight:310}, "slow");
    $(".right_side_panel").animate({width:310}, "slow");
    $.get("/ajax/comment/", {t:"shoutcast", id:comment_parent_id}, function(response){
    $(".raw_comments").remove();
    $(".comments_wrapper").fadeOut("slow", function(){
    $(".comments_wrapper").children().remove();
    $(".comments_wrapper").append(response);
    ProcessRawComments();
    $(this).fadeIn("slow");
    });

    });
    }

    http://wordpress.org/extend/plugins/wordpress-video-plugin/

  2. daburna
    Member
    Plugin Author

    Posted 3 years ago #

    Hi radiofranky,
    thanks for your code! I will test and think about the integration into my plugin. With this code it is not possible to change the videosize like [youtube id width height] or? So I have to write an admin page and make the size configurable via variables.
    Regards
    Oliver

  3. radiofranky
    Member
    Posted 3 years ago #

    i think you can passing in size variable... it's very similar to your current code.

  4. radiofranky
    Member
    Posted 3 years ago #

    Please keep me posted if you get chance to add this code to your plugin.

    If you need beta tester, I'm in.

    thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic