質問編集履歴

1

コードを追加しました

2019/05/19 12:11

投稿

17dez
17dez

スコア12

test CHANGED
File without changes
test CHANGED
@@ -19,3 +19,141 @@
19
19
 
20
20
 
21
21
  ![イメージ説明](15222e008d1a87d3c1222af51b1018d5.jpeg)
22
+
23
+
24
+
25
+ ※上記画像は、「← ← ← コレ」で表示したものになります。
26
+
27
+
28
+
29
+ ```Javascript
30
+
31
+ jQuery.fancybox.open({
32
+
33
+ type: "iframe",
34
+
35
+ opts: {
36
+
37
+ smallBtn: false,
38
+
39
+ animationEffect: false,
40
+
41
+ width: '100%',
42
+
43
+ height: '100%',
44
+
45
+ baseTpl:
46
+
47
+ '<div class="fancybox-container" role="dialog" tabindex="-1">' +
48
+
49
+ '<div class="fancybox-bg" style="opacity:1;background-color:rgba(0,0,0,.97);"></div>' +
50
+
51
+ '<div class="fancybox-inner">' +
52
+
53
+ '<div class="fancybox-toolbar">{{buttons}}</div>' +
54
+
55
+ '<div class="fancybox-stage"></div>' +
56
+
57
+ "</div>" +
58
+
59
+ "</div>",
60
+
61
+ touch: {
62
+
63
+ vertical: false,
64
+
65
+ momentum: false
66
+
67
+ },
68
+
69
+ beforeLoad: function(instance,current){
70
+
71
+ console.info( current ) //← ← ← コレ
72
+
73
+ var tag = document.createElement('script');
74
+
75
+
76
+
77
+ tag.src = "https://www.youtube.com/iframe_api";
78
+
79
+ var firstScriptTag = document.getElementsByTagName('script')[0];
80
+
81
+ firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
82
+
83
+
84
+
85
+ // 3. This function creates an <iframe> (and YouTube player)
86
+
87
+ // after the API code downloads.
88
+
89
+ var player;
90
+
91
+ function onYouTubeIframeAPIReady() {
92
+
93
+ player = new YT.Player(id_name, {
94
+
95
+ height: '360',
96
+
97
+ width: '640',
98
+
99
+ videoId: 'XXXXXXXXX',
100
+
101
+ events: {
102
+
103
+ 'onReady': onPlayerReady,
104
+
105
+ 'onStateChange': onPlayerStateChange
106
+
107
+ }
108
+
109
+ });
110
+
111
+ }
112
+
113
+
114
+
115
+ // 4. The API will call this function when the video player is ready.
116
+
117
+ function onPlayerReady(event) {
118
+
119
+ event.target.playVideo();
120
+
121
+ }
122
+
123
+
124
+
125
+ // 5. The API calls this function when the player's state changes.
126
+
127
+ // The function indicates that when playing a video (state=1),
128
+
129
+ // the player should play for six seconds and then stop.
130
+
131
+ var done = false;
132
+
133
+ function onPlayerStateChange(event) {
134
+
135
+ if (event.data == YT.PlayerState.PLAYING && !done) {
136
+
137
+ setTimeout(stopVideo, 6000);
138
+
139
+ done = true;
140
+
141
+ }
142
+
143
+ }
144
+
145
+ function stopVideo() {
146
+
147
+ player.stopVideo();
148
+
149
+ }
150
+
151
+ }
152
+
153
+ },
154
+
155
+ });
156
+
157
+
158
+
159
+ ```