jQuery 在没有 youtube 链接的情况下嵌入 youtube 视频

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2001558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 12:33:50  来源:igfitidea点击:

Embed youtube video without youtube link

jqueryajaxvideomootoolsyoutube

提问by air

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.

如您所知,当您在网页中嵌入 youtube 视频时,它工作正常,但是如果您单击屏幕的任何部分,youtube 网站将在新窗口中打开。

is there any way to Embed youtube video in our website, but disable that youtube website opening when click on screen to pause the video?

有什么方法可以在我们的网站中嵌入 youtube 视频,但在点击屏幕暂停视频时禁用该 youtube 网站打开?

or you can play you tube video in other player..?

或者你可以在其他播放器中播放你的管视频..?

i am looking for way around it.

我正在寻找解决方法。

any way possibility in j query, ajax, java script or PHP, mootools etc. Thanks

在 j 查询、ajax、java 脚本或 PHP、mootools 等中的任何可能性。谢谢

回答by Ondrej Galbavy

try this:

尝试这个:

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

它来自 youtube API 示例,所以它应该是官方支持的重要的是&version=3&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>

回答by Sampson

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.

你不应该那样做。如果您需要一个视频主持人来让他们的品牌远离您的屏幕,我建议您访问http://blip.tv。您可以通过 FTP 将您的视频传输到那里(它们可供所有用户使用),甚至可以使用您自己的品牌自定义您自己的播放器。

回答by George Oslobanu

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)

需要 JS 知识: - 使用来自 google 的 JS api 并禁用普通按钮并添加自定义按钮和事件(他们的文档中有很多示例)

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)
  • 使用其他播放器
  • 以及我所做的方式:我在播放器的顶部放置了一个 DIV(搜索/控件所在的部分除外)。这可以防止用户单击嵌入式播放器的所需部分,但允许您仍然使用控件(在 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

上述解决方案的用法: - 如果您想点击播放器并触发操作而不开始播放 Youtube 视频 - 禁用:youtube 点击/在另一个窗口中打开 youtube

HOPE THIS WILL HELP YOU

希望能帮到你

回答by davidcondrey

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.

您可以通过此脚本利用 Youtube API,它还允许您指定特定的时间码并仅显示视频的一部分。

<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
    })
}

回答by Douglas Soldan

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>

回答by axraf

use Jw player and add this code to your page

使用 Jw 播放器并将此代码添加到您的页面

<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>