質問編集履歴
1
コードを追加しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,4 +8,73 @@
|
|
8
8
|
中身をconsoleに表示してみましたが、この中の、「id」を取得するには、どうしたら良いのでしょうか。
|
9
9
|
かなり初歩的なことだと思うのですが。。。。
|
10
10
|
|
11
|
-

|
11
|
+

|
12
|
+
|
13
|
+
※上記画像は、「← ← ← コレ」で表示したものになります。
|
14
|
+
|
15
|
+
```Javascript
|
16
|
+
jQuery.fancybox.open({
|
17
|
+
type: "iframe",
|
18
|
+
opts: {
|
19
|
+
smallBtn: false,
|
20
|
+
animationEffect: false,
|
21
|
+
width: '100%',
|
22
|
+
height: '100%',
|
23
|
+
baseTpl:
|
24
|
+
'<div class="fancybox-container" role="dialog" tabindex="-1">' +
|
25
|
+
'<div class="fancybox-bg" style="opacity:1;background-color:rgba(0,0,0,.97);"></div>' +
|
26
|
+
'<div class="fancybox-inner">' +
|
27
|
+
'<div class="fancybox-toolbar">{{buttons}}</div>' +
|
28
|
+
'<div class="fancybox-stage"></div>' +
|
29
|
+
"</div>" +
|
30
|
+
"</div>",
|
31
|
+
touch: {
|
32
|
+
vertical: false,
|
33
|
+
momentum: false
|
34
|
+
},
|
35
|
+
beforeLoad: function(instance,current){
|
36
|
+
console.info( current ) //← ← ← コレ
|
37
|
+
var tag = document.createElement('script');
|
38
|
+
|
39
|
+
tag.src = "https://www.youtube.com/iframe_api";
|
40
|
+
var firstScriptTag = document.getElementsByTagName('script')[0];
|
41
|
+
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
42
|
+
|
43
|
+
// 3. This function creates an <iframe> (and YouTube player)
|
44
|
+
// after the API code downloads.
|
45
|
+
var player;
|
46
|
+
function onYouTubeIframeAPIReady() {
|
47
|
+
player = new YT.Player(id_name, {
|
48
|
+
height: '360',
|
49
|
+
width: '640',
|
50
|
+
videoId: 'XXXXXXXXX',
|
51
|
+
events: {
|
52
|
+
'onReady': onPlayerReady,
|
53
|
+
'onStateChange': onPlayerStateChange
|
54
|
+
}
|
55
|
+
});
|
56
|
+
}
|
57
|
+
|
58
|
+
// 4. The API will call this function when the video player is ready.
|
59
|
+
function onPlayerReady(event) {
|
60
|
+
event.target.playVideo();
|
61
|
+
}
|
62
|
+
|
63
|
+
// 5. The API calls this function when the player's state changes.
|
64
|
+
// The function indicates that when playing a video (state=1),
|
65
|
+
// the player should play for six seconds and then stop.
|
66
|
+
var done = false;
|
67
|
+
function onPlayerStateChange(event) {
|
68
|
+
if (event.data == YT.PlayerState.PLAYING && !done) {
|
69
|
+
setTimeout(stopVideo, 6000);
|
70
|
+
done = true;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
function stopVideo() {
|
74
|
+
player.stopVideo();
|
75
|
+
}
|
76
|
+
}
|
77
|
+
},
|
78
|
+
});
|
79
|
+
|
80
|
+
```
|