How to change video playback in the built-in player of Youtube?

I would like to create a playlist where clicking on each <li>will change the link to the video just below. The list will look like this:

  • video1

    <li><a href="MzfAvHlIVjE&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999">">video1</a></li>
    
  • BBBBB

  • Cpc

video player here


So clicking on aaaaa will play aaaaa, clicking on bbbbb will play bbbbb etc.

I would like to do this ajax, without redrawing, just click and play.

Here is a youtube object to edit

<object width="320" height="265">
  <param name="movie" value="http://www.youtube.com/v/MzfAvHlIVjE&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999"></param>
  <param name="allowFullScreen" value="true"></param>
  <param name="allowscriptaccess" value="always"></param>
  <embed src="http://www.youtube.com/v/MzfAvHlIVjE&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="320" height="265"></embed>
</object>

How to change video playback in the built-in player of Youtube?

+3
source share
7 answers

If you dun like a popup, just get rid of it:

function play(id)
    {
       var html  = '';

       html += '<object >';
       html += '<param name="movie" value="http://www.youtube.com/v/'+id+'"></param>';
       html += '<param name="autoplay" value="1">';
       html += '<param name="wmode" value="transparent"></param>';
       html += '<embed src="http://www.youtube.com/v/'+id+'&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" ></embed>';
       html += '</object>';

       return html;
    };

<div id="button1" />
<div id="playvideo" />

$("#button1").click(function() { $("#playvideo").html(play("YOURVIDEOID")); });

Hope this helps

+3
source

check out jQuery TubePlayer plugin -

, . jQuery("#player").tubeplayer("play", "[videoId]") li..

+5

-, :

:

    <script type="text/javascript" src="../../../Assets/js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript"> 
        $(document).ready(function(){
            $(".button").click(function() {
            $("#playvideo").html(play(  $(this).find("a").attr("linkattr")));           
            return false; 
            });
        });
    function play(id)   {
           var html  = '';     
           html += '<iframe width="671" height="495" src="'+id+'" frameborder="0" allowfullscreen></iframe>';
           return html;
        };  
    </script>

:

    <h2 class="button"><a linkattr="https://www.youtube.com/embed/uopXg6NxboQ?rel=0&amp;showinfo=0" href="#"> video 1 </a></h2>
    <h2 class="button"><a linkattr="https://www.youtube.com/embed/h-v1c2kNw70?rel=0&amp;showinfo=0" href="#"> video 2 </a></h2>

    <div id="playvideo">
          <iframe width="671" height="495" src="https://www.youtube.com/embed/uopXg6NxboQ?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
    </div>

: https://cllccavo.asc.ohio-state.edu/Public/Modules/help/howto.php

+4

:

http://www.studioteknik.com/youtube/index2.html

:

<script type="text/javascript"> 
    $(document).ready( function(){
        $(".button").click(function() {
        console.log($(this).find("a").attr("href"));
        $("#playvideo").html(play($(this).find("a").attr("href"))); 
        return false; 
        });
    });
</script>

</head>

<body>

<div>
  <ul>
    <li class="button"><a href="MzfAvHlIVjE&hl=en&fs=1">Video 1</a></li>
    <li class="button"><a href="uN2OGjsLuY8&hl=en&fs=1">Video 2</a></li>
    <li class="button"><a href="EZOTMcqaH98&hl=en&fs=1">Video 3</a></li>
    <li class="button"><a href="PSTDZEZV72Q&hl=en&fs=1">Video 4</a></li>
    <li class="button"><a href="QYlOaoqgMdw&hl=en&fs=1">Video 5</a></li>
    <li class="button"><a href="GEcBhbXEFz8&hl=en&fs=1">Video 6</a></li>
    <li class="button"><a href="cU6sJ0CQWAc&hl=en&fs=1">Video 7</a></li>
    </ul>
</div>
+2
$('#video-player object embed').attr('src', 'http://www.youtube.com/v/' + id + '&hl=en&fs=1&&autoplay=1');

this seems to work too, although it still causes the flash player to be redrawn, doh

0
source

Marc-Andre Menard - can you change the script so that one of the videos automatically loads on page load?

0
source

Source: https://habr.com/ru/post/1705459/


All Articles