Embed youtube video without youtube link

后端 未结 6 799
野趣味
野趣味 2021-02-09 21:08

as you know that when you Embed youtube video in your web page, it works fine , but if you click on any part of screen, youtube website will open in new window.

is there

相关标签:
6条回答
  • 2021-02-09 21:23

    try this:

    it is from youtube API sample, so it should be official supported important is &version=3 or &something=xx;version=3

    <object style="height: 390px; width: 640px">
    <param name="movie" value="http://www.youtube.com/v/u1zgFlCw8Aw?version=3">
    <param name="allowFullScreen" value="true">
    <param name="allowScriptAccess" value="always">
    <embed src="http://www.youtube.com/v/u1zgFlCw8Aw?version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="390"></object>
    
    0 讨论(0)
  • 2021-02-09 21:23

    use Jw player and add this code to your page

    <script type='text/javascript' src='swfobject.js'></script>
    <div id='mediaspace'>This text will be replaced</div>
    
    <script type='text/javascript'>
      var so = new SWFObject('http://astra.pcriot.com/videos/player.swf','ply','400','315','9','#000000');
      so.addParam('allowfullscreen','true');
      so.addParam('allowscriptaccess','always');
      so.addParam('wmode','opaque');
      so.addVariable('file','http://www.youtube.com/watch?v=YQmt8uHgIGY');
      so.write('mediaspace');
    </script>
    
    0 讨论(0)
  • 2021-02-09 21:26

    there are a few ways to do this like (depending on your programmer skills):

    REQUIRE JS knowledge: - use the JS api from google and disable the normal buttons and add customs buttons and events (there are a lot of examples in their documentation)

    NO PROGRAMMER skills:

    • use another player
    • and the way i did: i put a DIV ontop of the player (except the part where the seek/controls are). This prevents the user to click on a desired part of the embedded player but allows you to still use the controls (play/pause/seek/view in youtube)

    USAGE for above solutions: - if you want to click on the player and trigger an action without starting to play the Youtube video - disable: youtube click / open youtube in another window

    HOPE THIS WILL HELP YOU

    0 讨论(0)
  • 2021-02-09 21:34

    You shouldn't do that. If you need a video-host who keeps their branding off of your screen, I suggest http://blip.tv. You can transfer your videos there via a FTP (they make it available to all users), and even customize your own player with your own branding.

    0 讨论(0)
  • 2021-02-09 21:39

    You can leverage the Youtube API with this script which will also allow you to specify specific timecode and display only a portion of the video.

    <div videoID="" startTime="" endTime="" height="" width="" id="youtube"></div>
    
    var n = "youtube";
    var y = document.createElement('script');
    y.type = "text/javascript";
    y.src = "//www.youtube.com/iframe_api";
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(y, s);
    var player;
    var p = document.getElementById(n);
    var st = p.getAttribute("startTime");
    var et = p.getAttribute("endTime");
    var vi = p.getAttribute("videoID");
    var ph = p.getAttribute("height");
    var pw = p.getAttribute("width");
    
    function onYouTubeIframeAPIReady() {
        player = new YT.Player(n, {
            height: ph,width: pw,playerVars: {
                'rel': 0,
                'showinfo': 0,
                'hidecontrols': 1
            },
    
            events: {
                'onReady': lv
            }
        })
    }
    
    function lv(e) {
        e.target.cueVideoById({
            videoId: vi,startSeconds: st,endSeconds: et
        })
    }
    
    0 讨论(0)
  • 2021-02-09 21:39

    Try this

    <iframe width="560" height="315" src="//www.youtube.com/embed/<?=$idtube?>?modestbranding=1&amp;;showinfo=0&amp;;autohide=1&amp;;rel=0&amp;;hd=1" frameborder="0" allowfullscreen></iframe>
    
    0 讨论(0)
提交回复
热议问题