Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7520713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:07:00+00:00 2026-05-30T02:07:00+00:00

I am using Jquery youtube player plugin found here: http://badsyntax.github.com/jquery-youtube-player/ The plugin allows you

  • 0

I am using Jquery youtube player plugin found here: http://badsyntax.github.com/jquery-youtube-player/

The plugin allows you the specify a title for the youtube video you wish to play and the youtube video ID. Here is a snip it of the code:

var config =  {

            repeatPlaylist: 1,
            showTime: 1,
            height: 356,
            toolbar: 'play,prev,next,shuffle,repeat,mute', // comma separated list of toolbar buttons

            // Custom playlist
            playlist: {
                title: 'Random videos',
                videos: [
                    { id: 'youtube video id goes here', title: 'title goes here' },
                ]
            }

        };

I would like to create a button and assign the youtube id and video title. When pressed I would like those values to be used to load the youtube video using the jQuery plugin above without refreshing the page.

I have no clue how to do this. I have spent hours trying to figure it out without any luck. Any help would be greatly. appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:07:01+00:00Added an answer on May 30, 2026 at 2:07 am

    html:

    <div class="youtube-player"></div>         <!-- this element will be replaced -->
    
    <button type="button" id="videoBtn1">video 1</button>
    <button type="button" id="videoBtn2">video 2</button>
    

    js:

    function loadYouTube(id, title) {
        // your config with the parameters id and title
        var config =  {
            repeatPlaylist: 1,
            showTime: 1,
            height: 356,
            toolbar: 'play,prev,next,shuffle,repeat,mute',
            // Custom playlist
            playlist: {
                title: 'Random videos',
                videos: [{ id: id, title: title }]
            }
        };
        // replace the html element with an empty you-tube plugin html code
        $('.youtube-player').replaceWith($('<div class="youtube-player"><div class="youtube-player-video"><div class="youtube-player-object">You need Flash player 8+ and JavaScript enabled to view this video.</div></div></div>'));
        // start youtube-plugin
        $('.youtube-player').player(config);
    }
    
    // click handlers
    $('#videoBtn1').click(function() {
        loadYouTube('3qQWibGlfb0', 'title 1 goes here');
    });
    $('#videoBtn2').click(function() {
        loadYouTube('b8MhLvjoBTs', 'title 2 goes here');
    });
    

    Also see this example.

    === UPDATE ===

    Put the event handler calls into an onclick-attribute of the buttons and remove them in the javascript:

    <button type="button" id="videoBtn1" onclick="loadYouTube('3qQWibGlfb0', 'title 1 goes here');">video 1</button>
    <button type="button" id="videoBtn2" onclick="loadYouTube('b8MhLvjoBTs', 'title 2 goes here');">video 2</button>
    

    Also see the updated example.

    === UPDATE ===

    Maybe this free 😉 example can help you:

    html:

    <div id="youtube-player">
        <div class="youtube-player-video">
            <div class="youtube-player-object">
                You need Flash player 8+ and JavaScript enabled to view this video.
            </div>
        </div>
    </div>
    
    <button type="button" id="videoBtn1" onclick="loadYouTube('3qQWibGlfb0', 'title 1 goes here');">video 1</button>
    <button type="button" id="videoBtn2" onclick="loadYouTube('b8MhLvjoBTs', 'title 2 goes here');">video 2</button>
    

    js:

    var player = null;
    var playlist = {
        title: 'Random videos',
        videos: []
    };
    
    function loadYouTube(id, title) {
        // check if player isn't already loaded
        if (typeof $('#youtube-player').data('jquery-youtube-player') == 'undefined') {
            // add video to playlist
            playlist.videos.push({id: id, title: title});
            // load player
            player = $('#youtube-player')
                .show()
                .player({
                    repeatPlaylist: 1,
                    showTime: 1,
                    height: 356,
                    toolbar: 'play,prev,next,shuffle,repeat,mute',
                    playlist: playlist
                });
        }
        // if player is active
        else {
            var bFound = false;
            // search if video is already in playlist
            for (var i = 0; i < playlist.videos.length; i++) {
                if (playlist.videos[i].id == id) {
                    bFound = true;
                    break;
                }
            }
            if (!bFound) {                       
                // add video to playlist
                playlist.videos.push({id: id, title: title});
                // load updated playlist
                player.player('loadPlaylist', playlist);
            }
            // show current video
            player.player('cueVideo', id);
        }
    }
    

    Also see this updated jsfiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I were to embed a YouTube video for example <iframe width=560 src=http://www.youtube.com/embed/25LBTSUEU0A class=player
Using the code found here: How to popup a jquery window to play youtube
I'm doing a video player using JQuery and the YouTube JS API, i've varios
I'm using the jQuery Youtube plugin to embed a youtube video and use some
Possible Duplicate: jQuery Youtube URL Validation with regex YouTube url id Regex http://www.youtube.com/watch?v=SCS7SIeF30E http://www.youtube.com/watch?v=SCS7SIeF30E&feature=relmfu
I'm using jQuery to try to show a hidden YouTube player, and then start
Why isn't oembed showing the youtube video? I'm using the following code: <html xmlns=http://www.w3.org/1999/xhtml>
Im using this plugin clueTip http://plugins.learningjquery.com/cluetip/demo/ See the first example where you hover your
My problem is best described with this screencast I recorded: http://www.youtube.com/watch?v=aI-p_jqzOdU I'm using the
I'm using jQuery to append a youtube video when a button is clicked. onclick=$('#videogallery').append('<iframe

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.