小编Ser*_*der的帖子

如何动态更改Youtube Player videoID

我想使用YT.Player代码,以便我可以检测事件.我有一个带有Youtube视频ID的CSV文件和一个将ID放在一个数组中并希望能够在用户点击图像时动态更改ID的功能.基本上是这样的:

HTML

<!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
<div id="player"></div>
Run Code Online (Sandbox Code Playgroud)

JavaScript的

// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "//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.
// NOTE: videoId is taken out and instead is placed as the generated IFRAME src from the postSelection function

var player;
function …
Run Code Online (Sandbox Code Playgroud)

javascript iframe jquery youtube-api

27
推荐指数
1
解决办法
4万
查看次数

标签 统计

iframe ×1

javascript ×1

jquery ×1

youtube-api ×1