- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我制作了一个弹出窗口并在其中放置了一个 youtube 视频。我将视频设置为自动播放。但问题是当我打开页面时视频播放。它在全局范围内自动播放,我希望它在弹出窗口显示时自动播放。我没有找到任何解决方案。
目前,它播放时就像背景幽灵在说话一样。谁能帮忙?
视频HTML
<iframe width="800" height="315" src="http://www.youtube.com/embed/?wmode=opaque&autoplay=1&rel=0&color=white" frameborder="0"></iframe><a href="http://www.youtube.com" target="_blank"><img alt="" class="watermark" src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQHcbyVSjHQlwCy3tYqOyLwSWDO4tblhxTVVjKV5R0PtFsPy9TwfA" /></a></div>
</div>
调用弹窗
<a href="#" data-reveal-id="video_pop"><img src="kaow.png"/></a>
</div>
弹出内容
<div id="video_pop" class="reveal-modal medium">
<a class="close-reveal-modal"></a>
<div>
<iframe width="800" height="315" src="http://www.youtube.com/embed/?wmode=opaque&autoplay=1&rel=0&color=white" frameborder="0"></iframe><a href="http://www.youtube.com" target="_blank"><img alt="" class="watermark" src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQHcbyVSjHQlwCy3tYqOyLwSWDO4tblhxTVVjKV5R0PtFsPy9TwfA" /></a></div>
</div>
JS
Foundation.libs.reveal = {
name: "reveal",
version: "4.2.2",
locked: !1,
settings: {
animation: "fadeAndPop",
animationSpeed: 250,
closeOnBackgroundClick: !0,
closeOnEsc: !0,
dismissModalClass: "close-reveal-modal",
bgClass: "reveal-modal-bg",
open: function() {},
opened: function() {},
close: function() {},
closed: function() {},
bg: a(".reveal-modal-bg"),
css: {
open: {
opacity: 0,
visibility: "visible",
display: "block"
},
close: {
opacity: 1,
visibility: "hidden",
display: "none"
}
}
},
init: function(b, c, d) {
return Foundation.inherit(this, "data_options delay"), "object" == typeof c ? a.extend(!0, this.settings, c) : "undefined" != typeof d && a.extend(!0, this.settings, d),
"string" != typeof c ? (this.events(), this.settings.init) : this[c].call(this, d);
},
events: function() {
var b = this;
return a(this.scope).off(".fndtn.reveal").on("click.fndtn.reveal", "[data-reveal-id]", function(c) {
c.preventDefault();
if (!b.locked) {
var d = a(this), e = d.data("reveal-ajax");
b.locked = !0;
if ("undefined" == typeof e) b.open.call(b, d); else {
var f = e === !0 ? d.attr("href") : e;
b.open.call(b, d, {
url: f
});
}
}
}).on("click.fndtn.reveal", this.close_targets(), function(c) {
c.preventDefault();
if (!b.locked) {
var d = a.extend({}, b.settings, b.data_options(a(".reveal-modal.open")));
if (a(c.target)[0] === a("." + d.bgClass)[0] && !d.closeOnBackgroundClick) return;
b.locked = !0, b.close.call(b, a(this).closest(".reveal-modal"));
}
}).on("open.fndtn.reveal", ".reveal-modal", this.settings.open).on("opened.fndtn.reveal", ".reveal-modal", this.settings.opened).on("opened.fndtn.reveal", ".reveal-modal", this.open_video).on("close.fndtn.reveal", ".reveal-modal", this.settings.close).on("closed.fndtn.reveal", ".reveal-modal", this.settings.closed).on("closed.fndtn.reveal", ".reveal-modal", this.close_video),
a("body").bind("keyup.reveal", function(c) {
var d = a(".reveal-modal.open"), e = a.extend({}, b.settings, b.data_options(d));
27 === c.which && e.closeOnEsc && d.foundation("reveal", "close");
}), !0;
},
open: function(b, c) {
if (b) if ("undefined" != typeof b.selector) var d = a("#" + b.data("reveal-id")); else {
var d = a(this.scope);
c = b;
} else var d = a(this.scope);
if (!d.hasClass("open")) {
var e = a(".reveal-modal.open");
"undefined" == typeof d.data("css-top") && d.data("css-top", parseInt(d.css("top"), 10)).data("offset", this.cache_offset(d)),
d.trigger("open"), e.length < 1 && this.toggle_bg(d);
if ("undefined" == typeof c || !c.url) this.hide(e, this.settings.css.close), this.show(d, this.settings.css.open); else {
var f = this, g = "undefined" != typeof c.success ? c.success : null;
a.extend(c, {
success: function(b, c, h) {
a.isFunction(g) && g(b, c, h), d.html(b), a(d).foundation("section", "reflow"),
f.hide(e, f.settings.css.close), f.show(d, f.settings.css.open);
}
}), a.ajax(c);
}
}
},
close: function(b) {
var b = b && b.length ? b : a(this.scope), c = a(".reveal-modal.open");
c.length > 0 && (this.locked = !0, b.trigger("close"), this.toggle_bg(b), this.hide(c, this.settings.css.close));
},
close_targets: function() {
var a = "." + this.settings.dismissModalClass;
return this.settings.closeOnBackgroundClick ? a + ", ." + this.settings.bgClass : a;
},
toggle_bg: function(b) {
0 === a(".reveal-modal-bg").length && (this.settings.bg = a("<div />", {
"class": this.settings.bgClass
}).appendTo("body")), this.settings.bg.filter(":visible").length > 0 ? this.hide(this.settings.bg) : this.show(this.settings.bg);
},
已编辑:
我正在为弹出窗口使用 Foundation 5 Reveal Model:http://foundation.zurb.com/docs/components/reveal.html
最佳答案
我想你想要这样的东西:
基本上,我使用 API Javascript 向视频添加操作 play
和 pause
。
我使用 Foundation 的默认功能来向播放器添加事件。
HTML
<a href="#" data-reveal-id="myModal">Click Me For A Modal</a>
<div id="myModal" class="reveal-modal" data-reveal>
<h2>Awesome</h2>
<div id="player"></div>
<a class="close-reveal-modal">×</a>
</div>
JS
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '315',
width: '560',
videoId: 'l-gQLqv9f4o',
events: {
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING) {
//player is playing
} else {
//player is paused
}
}
function stopVideo() {
player.stopVideo();
}
function playVideo() {
player.playVideo();
}
function pauseVideo() {
player.pauseVideo();
}
$(document).on('opened.fndtn.reveal', '[data-reveal]', function () {
playVideo();
});
$(document).on('closed.fndtn.reveal', '[data-reveal]', function () {
pauseVideo();
});
关于javascript - Youtube 视频在弹出窗口中自动播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25175166/
是否有任何解决方案来禁用右键单击选项并从 Youtube 视频中删除右下角水印 Logo ?我在搜索 GOOGLE 后尝试过。谁能告诉我? 谢谢你。 最佳答案 试试 modestbranding范围:
我想使用 YouTube API (v3) 来启用仅音乐轨道的搜索(没有猫或藤蔓或任何其他非音乐视频)。我查看了 API Explorer 和文档以获取有关该问题的任何指示,但找不到任何有用的信息。
我需要为网站使用YouTube视频缩略图的maxresdefault版本,但是在开发实现此目的的代码后,我发现并非所有视频都具有这些缩略图,尽管这些视频均为1080p。 有没有一种方法可以自动为我的所
我想通过“iframe”嵌入youtube视频,但YouTube在我国禁止使用,建议我如何在我的网站上嵌入视频! [1]:以下图片显示了在我的国家/地区无法访问youtube 最佳答案 该视频将被嵌入
我正在为myBB使用一个名为Profile Music Plugin的插件,可以在此处找到http://community.mybb.com/mods.php?action=view&pid=75 我
Youtube IFRAME API中是否有可以执行命令的功能,例如在播放的视频结尾处打开网站? (我相信有一个功能可以在旧的Java API下执行此操作,但该功能已于去年弃用。) 最佳答案 您可以引
我试图在Videos.insert和Videos.update查询中设置3d尺寸标志。但是标志不会改变。 更新查询示例: 请求: PUT https://www.googleapis.com/yout
使用此获取评论 评论主题:列表 GET https://www.googleapis.com/youtube/v3/commentThreads?part=snippet { "error": {
最近,我尝试使用OEmbed服务通过播放列表查询参数获取视频网址的iframe代码,但是OEmbed为我们提供了与我要求的视频不同的iframe代码。 这是带有播放列表查询参数的视频网址: https
我正在使用此代码: https://www.googleapis.com/youtube/v3/search?q=global+warming&part=id&maxResults=50&key=MY
我有一个LiveBroadcast,并且将来会添加一个scheduledStartTime。据我所知,这次测试不会对LiveBroadcast的整体状态产生影响,即广播是否具有准备就绪/测试的life
YouTube API是否支持在特定时间后关闭浏览器的参数? 这需要使用链接在不同位置共享来推广促销视频。视频播放结束后关闭浏览器。 最佳答案 您可以使用Youtube API监控视频是否播放完毕,然
如果没有表单上的透明面板,YouTube Player将可以正常播放视频,或者可以全屏播放视频,透明面板中有一些图像没有什么特别的。如果我取出透明面板,则YouTube播放器会按需工作,并嵌入到应用程
我正在通过Google进行身份验证,以尝试获取YouTube分析数据,但我的问题是我不知道在查询YouTube时如何向您填充参数 在这里,我正在提供一项新服务:然后尝试查询它 我不确定要在“ids”参
我想添加youtube视频列表,但不添加视频播放器。所以我需要的是 视频标题 视频缩略图 视频时长 我以某种方式设法通过使用此http://img.youtube.com/vi/4wew2uWoARw
我正在使用youtube api和python库gdata 我遵循了文档,但似乎没有出路。 问题是 - How do i get the size of the youtube video fil
使用Youtube API,我如何获得评论或顶过youtube视频的用户ID /处理列表? 提前致谢 最佳答案 在这里,您可以了解如何使用YouTube API v2(v3尚不支持此注释)获取评论:h
我正在为所有相关数据构建一个仪表板(以php为单位),我还想在YouTube“稍后观看”播放列表中显示我的商品数量。 我知道无法使用YouTube API来解决这个问题,但是也许有人想出一种解决方法?
我尝试使用YouTube API,但存在引号问题。 SearchResource.ListRequest searchListRequest = yt.Search.List("sni
我想为我的Android应用程序的用户构建视频推荐器。我有Google OAuth可以登录我的应用程序。我可以获取有关我的应用程序用户在YouTube上观看的视频的数据吗? 最佳答案 v3 API分为
我是一名优秀的程序员,十分优秀!