j1-template 2024.3.15 → 2024.3.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/data/amplitude.html +7 -7
- data/assets/data/panel.html +4 -3
- data/assets/theme/j1/adapter/js/amplitude.js +100 -81
- data/assets/theme/j1/adapter/js/masonry.js +2 -2
- data/assets/theme/j1/adapter/js/videojs.js +212 -0
- data/assets/theme/j1/core/css/themes/unolight/bootstrap.css +7 -4
- data/assets/theme/j1/core/css/themes/unolight/bootstrap.css.map +1 -1
- data/assets/theme/j1/core/css/themes/unolight/bootstrap.min.css +1 -1
- data/assets/theme/j1/core/css/themes/unolight/bootstrap.min.css.map +1 -1
- data/assets/theme/j1/core/js/template.js +4 -0
- data/assets/theme/j1/core/js/template.min.js +2 -2
- data/assets/theme/j1/core/js/template.min.js.map +1 -1
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/amplitude.css +81 -1
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/amplitude.min.css +1 -1
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/compact.css +3 -2
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/compact.min.css +1 -1
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/large.css +19 -4
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/large.min.css +1 -1
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/artist.svg +78 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/mute.svg +52 -20
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/next.svg +20 -39
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/now-playing.svg +24 -38
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/playlist-hide.svg +85 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/playlist-music.svg +85 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/playlist-show.svg +85 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/playlist.svg +85 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/previous.svg +18 -37
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/skip-backward.svg +33 -30
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/skip-forward.svg +33 -29
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/small/next.svg +55 -14
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/small/previous.svg +56 -14
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/volume.svg +38 -21
- data/assets/theme/j1/modules/amplitudejs/js/amplitude.map +20 -20
- data/assets/theme/j1/modules/amplitudejs/js/tech/youtube_example.js +211 -0
- data/assets/theme/j1/modules/lightGallery/js/plugins/lg-video.js +206 -122
- data/assets/theme/j1/modules/videojs/assets/icons/custom-icons/next.svg +82 -0
- data/assets/theme/j1/modules/videojs/css/font/README.md +151 -0
- data/assets/theme/j1/modules/videojs/css/font/VideoJS.svg +150 -0
- data/assets/theme/j1/modules/videojs/css/font/video-js-cdn.css +2012 -0
- data/assets/theme/j1/modules/videojs/css/plugins/controls/skipbuttons.0.css +32 -0
- data/assets/theme/j1/modules/videojs/css/plugins/controls/skipbuttons.1.css +31 -0
- data/assets/theme/j1/modules/videojs/css/plugins/controls/skipbuttons.css +31 -0
- data/assets/theme/j1/modules/videojs/css/plugins/controls/skipbuttons.min.css +21 -0
- data/assets/theme/j1/modules/videojs/css/themes/uno.css +14 -3
- data/assets/theme/j1/modules/videojs/css/themes/uno.min.css +1 -1
- data/assets/theme/j1/modules/videojs/css/videojs.css +1 -0
- data/assets/theme/j1/modules/videojs/js/plugins/controls/autocaption/LICENSE +13 -0
- data/assets/theme/j1/modules/videojs/js/plugins/controls/autocaption/README.md +75 -0
- data/assets/theme/j1/modules/videojs/js/plugins/controls/autocaption/autocaption.js +149 -0
- data/assets/theme/j1/modules/videojs/js/plugins/controls/autocaption/autocaption.min.js +21 -0
- data/assets/theme/j1/modules/videojs/js/plugins/controls/hotkeys/README.md +76 -30
- data/assets/theme/j1/modules/videojs/js/plugins/controls/hotkeys/hotkeys.js +64 -53
- data/assets/theme/j1/modules/videojs/js/plugins/controls/hotkeys/hotkeys.min.js +1 -1
- data/assets/theme/j1/modules/videojs/js/plugins/controls/skipbuttons/README.md +133 -0
- data/assets/theme/j1/modules/videojs/js/plugins/controls/skipbuttons/skipbuttons.js +137 -0
- data/assets/theme/j1/modules/videojs/js/plugins/controls/skipbuttons/skipbuttons.min.js +21 -0
- data/assets/theme/j1/modules/videojs/js/plugins/controls/zoom/zoom.js +15 -12
- data/assets/theme/j1/modules/videojs/js/plugins/players/yt/youtube.js +43 -16
- data/lib/j1/patches/rubygems/eventmachine-1.2.7-x64-mingw32/lib/3.3/fastfilereaderext.so +0 -0
- data/lib/j1/patches/rubygems/eventmachine-1.2.7-x64-mingw32/lib/3.3/rubyeventmachine.so +0 -0
- data/lib/j1/patches/rubygems/eventmachine-1.2.7-x64-mingw32/lib/3.4/fastfilereaderext.so +0 -0
- data/lib/j1/patches/rubygems/eventmachine-1.2.7-x64-mingw32/lib/3.4/rubyeventmachine.so +0 -0
- data/lib/j1/version.rb +1 -1
- data/lib/j1_app/j1_auth_manager/config.rb +0 -4
- data/lib/starter_web/Gemfile +45 -22
- data/lib/starter_web/README.md +5 -5
- data/lib/starter_web/_config.yml +4 -6
- data/lib/starter_web/_data/modules/amplitude.yml +9 -399
- data/lib/starter_web/_data/modules/defaults/gallery.yml +42 -0
- data/lib/starter_web/_data/modules/defaults/videojs.yml +107 -0
- data/lib/starter_web/_data/modules/gallery.yml +30 -14
- data/lib/starter_web/_data/modules/masonry.yml +15 -0
- data/lib/starter_web/_data/modules/videojs.yml +57 -0
- data/lib/starter_web/_data/resources.yml +9 -27
- data/lib/starter_web/_data/templates/feed.xml +1 -1
- data/lib/starter_web/_includes/tables/jekyll_variables.asciidoc +1 -0
- data/lib/starter_web/_plugins/asciidoctor/dailymotion-block.rb +4 -1
- data/lib/starter_web/_plugins/asciidoctor/videojs-block.rb +145 -24
- data/lib/starter_web/_plugins/asciidoctor/vimeo-block.rb +4 -1
- data/lib/starter_web/_plugins/asciidoctor/wistia-block.rb +313 -0
- data/lib/starter_web/_plugins/asciidoctor/youtube-block.rb +192 -17
- data/lib/starter_web/_plugins/index/lunr.rb +1 -1
- data/lib/starter_web/package.json +1 -1
- data/lib/starter_web/pages/public/amplitude_yt_tester.adoc +20 -7
- data/lib/starter_web/pages/public/manuals/integrations/amplitudejs/amplitudejs-api.adoc +1 -1
- data/lib/starter_web/pages/public/manuals/integrations/videojs/youtube-api.adoc +1638 -0
- data/lib/starter_web/pages/public/tools/previewer/preview_bootstrap_theme.adoc +5 -6
- data/lib/starter_web/pages/public/tools/previewer/preview_videojs.adoc +203 -0
- data/lib/starter_web/pages/{tour → public/tour}/play_audio.adoc +3 -10
- data/lib/starter_web/pages/{tour → public/tour}/play_video.adoc +49 -40
- metadata +61 -41
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/_pause.svg +0 -19
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/_play.svg +0 -18
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/show-playlist.svg +0 -15
- data/assets/theme/j1/modules/jqueryScrollbar/LICENSE +0 -20
- data/assets/theme/j1/modules/jqueryScrollbar/README.md +0 -28
- data/assets/theme/j1/modules/jqueryScrollbar/css/scrollbar.css +0 -939
- data/assets/theme/j1/modules/jqueryScrollbar/css/scrollbar.min.css +0 -20
- data/assets/theme/j1/modules/jqueryScrollbar/js/scrollbar.js +0 -851
- data/assets/theme/j1/modules/jqueryScrollbar/js/scrollbar.min.js +0 -36
- data/assets/theme/j1/modules/jqueryScrollbar/sass/scrollbar.scss +0 -806
- data/assets/theme/j1/modules/lightGallery/js/plugins/lg-video.0.js +0 -794
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/attributes.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/100_gistblock.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/410_bottom_info.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/410_bottom_left_warning.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/410_bottom_right_danger.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/410_central_success.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/410_full_height_left_info.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/410_full_height_right_success.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/410_table_bs_modal_examples.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/410_top_info.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/410_top_left_info.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/410_top_right_success.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/419_advanced_modals_demo.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/tables/bs_modal_examples.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/themes_bootstrap.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/_includes/documents/themes_rouge.asciidoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/asciidoc_extensions.adoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/bootstrap_themes.adoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/highlghter_rouge.adoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/icon_fonts.adoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/modal_extentions.adoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/present_images.adoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/quicksearch.adoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/responsive_tables.adoc +0 -0
- /data/lib/starter_web/pages/{tour → public/tour}/typography.adoc +0 -0
@@ -0,0 +1,1638 @@
|
|
1
|
+
---
|
2
|
+
title: YouTube IFrame API
|
3
|
+
title_extention: Player Settings
|
4
|
+
tagline: Player Settings
|
5
|
+
|
6
|
+
date: 2020-11-04
|
7
|
+
#last_modified: 2023-01-01
|
8
|
+
|
9
|
+
description: >
|
10
|
+
The Youtube Embedded Player API explains how to embed
|
11
|
+
a YouTube player in your application and also defines
|
12
|
+
the parameters that are available in the YouTube embedded
|
13
|
+
player
|
14
|
+
keywords: >
|
15
|
+
open source, free, template, jekyll, jekyllone, web,
|
16
|
+
sites, static, jamstack, bootstrap,
|
17
|
+
html, html5, video, support,
|
18
|
+
youtube
|
19
|
+
|
20
|
+
categories: [ Manuals ]
|
21
|
+
tags: [ Module, YouTube ]
|
22
|
+
|
23
|
+
image:
|
24
|
+
path: /assets/image/icons/videojs/videojs-poster.png
|
25
|
+
width: 1920
|
26
|
+
height: 1280
|
27
|
+
|
28
|
+
regenerate: false
|
29
|
+
personalization: true
|
30
|
+
permalink: /pages/public/manuals/videojs/youtube_api/
|
31
|
+
|
32
|
+
resources: [ clipboard, rouge ]
|
33
|
+
resource_options:
|
34
|
+
- toccer:
|
35
|
+
collapseDepth: 2
|
36
|
+
- attic:
|
37
|
+
slides:
|
38
|
+
- url: /assets/image/icons/videojs/videojs-poster.png
|
39
|
+
alt: VideoJS Poster
|
40
|
+
---
|
41
|
+
|
42
|
+
// Page Initializer
|
43
|
+
// =============================================================================
|
44
|
+
// Enable the Liquid Preprocessor
|
45
|
+
:page-liquid:
|
46
|
+
|
47
|
+
// Set (local) page attributes here
|
48
|
+
// -----------------------------------------------------------------------------
|
49
|
+
// :page--attr: <attr-value>
|
50
|
+
:images-dir: {imagesdir}/pages/roundtrip/100_present_images
|
51
|
+
|
52
|
+
// Load Liquid procedures
|
53
|
+
// -----------------------------------------------------------------------------
|
54
|
+
{% capture load_attributes %}themes/{{site.template.name}}/procedures/global/attributes_loader.proc{%endcapture%}
|
55
|
+
|
56
|
+
// Load page attributes
|
57
|
+
// -----------------------------------------------------------------------------
|
58
|
+
{% include {{load_attributes}} scope="global" %}
|
59
|
+
// https://developers.google.com/youtube/iframe_api_reference?hl=en
|
60
|
+
// https://developers.google.com/youtube/player_parameters?hl=en
|
61
|
+
|
62
|
+
// Page content
|
63
|
+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
64
|
+
[role="dropcap"]
|
65
|
+
The YouTube Embedded Player API explains how to embed a *YouTube player* in
|
66
|
+
your application and also defines the parameters that are available in the
|
67
|
+
YouTube embedded player.
|
68
|
+
|
69
|
+
mdi:clock-time-five-outline[24px, md-gray mt-4 mb-5 mr-2]
|
70
|
+
*30-60 Minutes* to read
|
71
|
+
|
72
|
+
// Include sub-documents (if any)
|
73
|
+
// -----------------------------------------------------------------------------
|
74
|
+
[role="mt-5"]
|
75
|
+
== Overview
|
76
|
+
|
77
|
+
By appending parameters to the IFrame URL, you can customize the
|
78
|
+
playback experience in your application. For example, you can
|
79
|
+
automatically play videos using the `autoplay` parameter or cause a
|
80
|
+
video to play repeatedly using the `loop` parameter. You can also use
|
81
|
+
the `enablejsapi` parameter to enable the player to be controlled via
|
82
|
+
the link:https://developers.google.com/youtube/iframe_api_reference[IFrame Player API, {browser-window--new}].
|
83
|
+
|
84
|
+
This page currently defines all parameters supported in any YouTube
|
85
|
+
*embedded* player. Each parameter definition identifies the players that
|
86
|
+
support the corresponding parameter.
|
87
|
+
|
88
|
+
[NOTE]
|
89
|
+
====
|
90
|
+
Embedded players must have a viewport that is at least 200px by
|
91
|
+
200px. If the player displays controls, it must be large enough to fully
|
92
|
+
display the controls without shrinking the viewport below the minimum
|
93
|
+
size. We recommend 16:9 players be at least 480 pixels wide and 270
|
94
|
+
pixels tall.
|
95
|
+
====
|
96
|
+
|
97
|
+
|
98
|
+
[role="mt-5"]
|
99
|
+
== Embed a Player
|
100
|
+
|
101
|
+
Define an `<iframe>` tag in your application in which the `src` URL
|
102
|
+
specifies the content that the player will load as well as any other
|
103
|
+
player parameters you want to set. The `<iframe>` tag's `height` and
|
104
|
+
`width` parameters specify the dimensions of the player.
|
105
|
+
|
106
|
+
If you create the `<iframe>` element yourself (rather than using the
|
107
|
+
IFrame Player API to create it), you can append player parameters
|
108
|
+
directly to the end of the URL. The URL has the following format:
|
109
|
+
|
110
|
+
....
|
111
|
+
https://www.youtube.com/embed/<VIDEO_ID>
|
112
|
+
....
|
113
|
+
|
114
|
+
The `<iframe>` tag below would load a *640x360px* player that would play
|
115
|
+
the YouTube video *M7lc1UVf-VE*. Since the URL sets the `autoplay`
|
116
|
+
parameter to `1`, the video would play automatically once the player has
|
117
|
+
loaded.
|
118
|
+
|
119
|
+
[source, html]
|
120
|
+
----
|
121
|
+
<iframe
|
122
|
+
id="ytplayer"
|
123
|
+
type="text/html"
|
124
|
+
width="640" height="360"
|
125
|
+
src="https://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1&origin=http://example.com"
|
126
|
+
frameborder="0">
|
127
|
+
</iframe>
|
128
|
+
----
|
129
|
+
|
130
|
+
Follow the
|
131
|
+
link:https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player[IFrame Player API instructions, {browser-window--new}]
|
132
|
+
to insert a video player in your web page or
|
133
|
+
application after the Player API's Javascript code has loaded. The
|
134
|
+
second parameter in the constructor for the video player is an object
|
135
|
+
that specifies player options. Within that object, the `playerVars`
|
136
|
+
property identifies player parameters.
|
137
|
+
|
138
|
+
The HTML and Javascript code below shows a simple example that inserts a
|
139
|
+
*YouTube player* into the page element that has an `id` value of
|
140
|
+
`ytplayer`. The `onYouTubePlayerAPIReady()` method specified here is
|
141
|
+
called automatically when the IFrame Player API code has loaded. This
|
142
|
+
code does not define any player parameters and also does not define
|
143
|
+
other event handlers.
|
144
|
+
|
145
|
+
[source, html]
|
146
|
+
----
|
147
|
+
<div id="ytplayer"></div>
|
148
|
+
|
149
|
+
<script>
|
150
|
+
// Load the IFrame Player API code asynchronously.
|
151
|
+
var tag = document.createElement('script');
|
152
|
+
tag.src = "https://www.youtube.com/player_api";
|
153
|
+
var firstScriptTag = document.getElementsByTagName('script')[0];
|
154
|
+
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
155
|
+
|
156
|
+
// Replace the 'ytplayer' element with an <iframe> and
|
157
|
+
// YouTube player after the API code downloads.
|
158
|
+
var player;
|
159
|
+
function onYouTubePlayerAPIReady() {
|
160
|
+
player = new YT.Player('ytplayer', {
|
161
|
+
height: '360',
|
162
|
+
width: '640',
|
163
|
+
videoId: 'M7lc1UVf-VE'
|
164
|
+
});
|
165
|
+
}
|
166
|
+
</script>
|
167
|
+
----
|
168
|
+
|
169
|
+
|
170
|
+
[role="mt-5"]
|
171
|
+
== Select content to play
|
172
|
+
|
173
|
+
You can configure your embedded player to load a video, a playlist, or a
|
174
|
+
user's uploaded videos.
|
175
|
+
|
176
|
+
The following list explains these options for loading a video. For an IFrame
|
177
|
+
embed, the YouTube video ID for the video that you want to load is specified
|
178
|
+
in the IFrame's `src` URL.
|
179
|
+
|
180
|
+
....
|
181
|
+
https://www.youtube.com/embed/<VIDEO_ID>
|
182
|
+
....
|
183
|
+
|
184
|
+
If you are using the YouTube Data API (v3), you can programmatically construct
|
185
|
+
these URLs by retrieving video IDs from
|
186
|
+
link:https://developers.google.com/youtube/v3/docs/search#resource[search results, {browser-window--new}],
|
187
|
+
link:https://developers.google.com/youtube/v3/docs/playlistItems#resource[playlist item resources, {browser-window--new}],
|
188
|
+
link:https://developers.google.com/youtube/v3/docs/videos#resource[video resources, {browser-window--new}],
|
189
|
+
or other resources. After obtaining a video ID, replace the `VIDEO_ID` text in
|
190
|
+
the URLs above with that value to create the player URL.
|
191
|
+
|
192
|
+
For loading a playlist, set the `listType` player parameter to `playlist`.
|
193
|
+
In addition, set the `list` player parameter to the YouTube playlist ID that
|
194
|
+
you want to load.
|
195
|
+
|
196
|
+
....
|
197
|
+
https://www.youtube.com/embed?listType=playlist&list=PLAYLIST_ID
|
198
|
+
....
|
199
|
+
|
200
|
+
Note that you need to prepend the playlist ID with the letters `PL` as
|
201
|
+
shown in the following example:
|
202
|
+
|
203
|
+
....
|
204
|
+
https://www.youtube.com/embed?listType=playlist&list=PLC77007E23FF423C6
|
205
|
+
....
|
206
|
+
|
207
|
+
If you are using the YouTube Data API (v3), you can programmatically
|
208
|
+
construct these URLs by retrieving playlist IDs from
|
209
|
+
link:https://developers.google.com/youtube/v3/docs/search#resource[search results, {browser-window--new}],
|
210
|
+
link:https://developers.google.com/youtube/v3/docs/channels#contentDetails.relatedPlaylists[channel resources, {browser-window--new}],
|
211
|
+
or link:https://developers.google.com/youtube/v3/docs/activities#resource[activity resources, {browser-window--new}].
|
212
|
+
After obtaining a playlist ID, replace the `PLAYLIST_ID` text in the URL above
|
213
|
+
with that value.
|
214
|
+
|
215
|
+
For Loading a user's uploaded videos, set the `listType` player parameter
|
216
|
+
to `user_uploads`. In addition, set the `list` player parameter to the
|
217
|
+
YouTube username whose uploaded videos you want to load.
|
218
|
+
|
219
|
+
....
|
220
|
+
https://www.youtube.com/embed?listType=user_uploads&list=USERNAME
|
221
|
+
....
|
222
|
+
|
223
|
+
[role="mt-5"]
|
224
|
+
== Supported players parameters
|
225
|
+
|
226
|
+
All of the following parameters are optional.
|
227
|
+
|
228
|
+
[role="mt-4"]
|
229
|
+
=== `autoplay`
|
230
|
+
|
231
|
+
This parameter specifies whether the initial video will automatically
|
232
|
+
start to play when the player loads. Supported values are `0` or `1`.
|
233
|
+
The default value is `0`.
|
234
|
+
|
235
|
+
If you enable Autoplay, playback will occur without any user interaction
|
236
|
+
with the player; playback data collection and sharing will therefore
|
237
|
+
occur upon page load.
|
238
|
+
|
239
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
240
|
+
|===
|
241
|
+
|Type |Default
|
242
|
+
|
243
|
+
|`0`\|`1`
|
244
|
+
|`0`
|
245
|
+
|
246
|
+
|===
|
247
|
+
|
248
|
+
[role="mt-4"]
|
249
|
+
=== `cc_lang_pref`
|
250
|
+
|
251
|
+
This parameter specifies the default language that the player will use
|
252
|
+
to display captions. Set the parameter's value to an
|
253
|
+
link:https://www.loc.gov/standards/iso639-2/php/code_list.php[ISO 639-1 two-letter language code, {browser-window--new}].
|
254
|
+
|
255
|
+
If you use this parameter and also set the `cc_load_policy` parameter to
|
256
|
+
`1`, then the player will show captions in the specified language when
|
257
|
+
the player loads. If you do not also set the `cc_load_policy` parameter,
|
258
|
+
then captions will not display by default, but will display in the
|
259
|
+
specified language if the user opts to turn captions on.
|
260
|
+
|
261
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
262
|
+
|===
|
263
|
+
|Type |Default
|
264
|
+
|
265
|
+
|`string`
|
266
|
+
|no defaults
|
267
|
+
|
268
|
+
|===
|
269
|
+
|
270
|
+
[role="mt-4"]
|
271
|
+
=== `cc_load_policy`
|
272
|
+
|
273
|
+
Setting the parameter's value to `1` causes closed captions to be shown
|
274
|
+
by default, even if the user has turned captions off. The default
|
275
|
+
behavior is based on user preference.
|
276
|
+
|
277
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
278
|
+
|===
|
279
|
+
|Type |Default
|
280
|
+
|
281
|
+
|`0`\|`1`
|
282
|
+
|no defaults
|
283
|
+
|
284
|
+
|===
|
285
|
+
|
286
|
+
[role="mt-4"]
|
287
|
+
=== `color`
|
288
|
+
|
289
|
+
This parameter specifies the color that will be used in the player's
|
290
|
+
video progress bar to highlight the amount of the video that the viewer
|
291
|
+
has already seen. Valid parameter values are `red` and `white`, and, by
|
292
|
+
default, the player uses the color red in the video progress bar.
|
293
|
+
|
294
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
295
|
+
|===
|
296
|
+
|Type |Default
|
297
|
+
|
298
|
+
|`red`\|`white`
|
299
|
+
|`red`
|
300
|
+
|
301
|
+
|===
|
302
|
+
|
303
|
+
[role="mt-4"]
|
304
|
+
=== `controls`
|
305
|
+
|
306
|
+
This parameter indicates whether the video player controls are
|
307
|
+
displayed:
|
308
|
+
|
309
|
+
* `controls=0`, Player controls do not display in the player.
|
310
|
+
* `controls=1`, Player controls display in the player (default).
|
311
|
+
|
312
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
313
|
+
|===
|
314
|
+
|Type |Default
|
315
|
+
|
316
|
+
|`0`\|`1`
|
317
|
+
|`1`
|
318
|
+
|
319
|
+
|===
|
320
|
+
|
321
|
+
[role="mt-4"]
|
322
|
+
=== `disablekb`
|
323
|
+
|
324
|
+
Setting the parameter's value to `1` causes the player to not respond to
|
325
|
+
keyboard controls. The default value is `0`, which means that keyboard
|
326
|
+
controls are enabled. Currently supported keyboard controls are:
|
327
|
+
|
328
|
+
* Spacebar or [k]: Play / Pause
|
329
|
+
* Arrow Left: Jump back 5 seconds in the current video
|
330
|
+
* Arrow Right: Jump ahead 5 seconds in the current video
|
331
|
+
* Arrow Up: Volume up
|
332
|
+
* Arrow Down: Volume Down
|
333
|
+
* [f]: Toggle full-screen display
|
334
|
+
* [j]: Jump back 10 seconds in the current video
|
335
|
+
* [l]: Jump ahead 10 seconds in the current video
|
336
|
+
* [m]: Mute or unmute the video
|
337
|
+
* [0-9]: Jump to a point in the video. `0` jumps to the beginning of the
|
338
|
+
video, `1` jumps to the point 10% into the video, `2` jumps to the point
|
339
|
+
20% into the video, and so forth.
|
340
|
+
|
341
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
342
|
+
|===
|
343
|
+
|Type |Default
|
344
|
+
|
345
|
+
|`0`\|`1`
|
346
|
+
|`0`
|
347
|
+
|
348
|
+
|===
|
349
|
+
|
350
|
+
[role="mt-4"]
|
351
|
+
=== `enablejsapi`
|
352
|
+
|
353
|
+
Setting the parameter's value to `1` enables the player to be controlled
|
354
|
+
via IFrame Player API calls. The default value is `0`, which means that the
|
355
|
+
player cannot be controlled using that API.
|
356
|
+
|
357
|
+
For more information on the IFrame API and how to use it, see the
|
358
|
+
link:https://developers.google.com/youtube/iframe_api_reference[IFrame API documentation, {browser-window--new}].
|
359
|
+
|
360
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
361
|
+
|===
|
362
|
+
|Type |Default
|
363
|
+
|
364
|
+
|`0`\|`1`
|
365
|
+
|`0`
|
366
|
+
|
367
|
+
|===
|
368
|
+
|
369
|
+
[role="mt-4"]
|
370
|
+
=== `end`
|
371
|
+
|
372
|
+
This parameter specifies the time, measured in seconds from the start of
|
373
|
+
the video, when the player should stop playing the video. The parameter
|
374
|
+
value is a positive integer.
|
375
|
+
|
376
|
+
Note that the time is measured from the beginning of the video and not
|
377
|
+
from either the value of the `start` player parameter or the
|
378
|
+
`startSeconds` parameter, which is used in YouTube Player API methods
|
379
|
+
for loading or queueing a video.
|
380
|
+
|
381
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
382
|
+
|===
|
383
|
+
|Type |Default
|
384
|
+
|
385
|
+
|`integer`
|
386
|
+
|no defaults
|
387
|
+
|
388
|
+
|===
|
389
|
+
|
390
|
+
[role="mt-4"]
|
391
|
+
=== `fs`
|
392
|
+
|
393
|
+
Setting this parameter to `0` prevents the fullscreen button from
|
394
|
+
displaying in the player. The default value is `1`, which causes the
|
395
|
+
fullscreen button to display.
|
396
|
+
|
397
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
398
|
+
|===
|
399
|
+
|Type |Default
|
400
|
+
|
401
|
+
|`0`\|`1`
|
402
|
+
|`1`
|
403
|
+
|
404
|
+
|===
|
405
|
+
|
406
|
+
[role="mt-4"]
|
407
|
+
=== `hl`
|
408
|
+
|
409
|
+
Sets the player's interface language. The parameter value is an
|
410
|
+
link:https://www.loc.gov/standards/iso639-2/php/code_list.php[ISO 639-1 two-letter language code, {browser-window--new}]
|
411
|
+
or a fully specified locale. For example, `fr` and `fr-ca` are both valid
|
412
|
+
values. Other language input codes, such as IETF language tags (BCP 47) might
|
413
|
+
also be handled properly.
|
414
|
+
|
415
|
+
The interface language is used for tooltips in the player and also
|
416
|
+
affects the default caption track. Note that _YouTube_ might select a
|
417
|
+
different caption track language for a particular user based on the
|
418
|
+
user's individual language preferences and the availability of caption
|
419
|
+
tracks.
|
420
|
+
|
421
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
422
|
+
|===
|
423
|
+
|Type |Default
|
424
|
+
|
425
|
+
|`string`
|
426
|
+
|no defaults
|
427
|
+
|
428
|
+
|===
|
429
|
+
|
430
|
+
[role="mt-4"]
|
431
|
+
=== `iv_load_policy`
|
432
|
+
|
433
|
+
Setting the parameter's value to `1` causes video annotations to be
|
434
|
+
shown by default, whereas setting to `3` causes video annotations to not
|
435
|
+
be shown by default. The default value is `1`.
|
436
|
+
|
437
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
438
|
+
|===
|
439
|
+
|Type |Default
|
440
|
+
|
441
|
+
|`1`\|`3`
|
442
|
+
|`1`
|
443
|
+
|
444
|
+
|===
|
445
|
+
|
446
|
+
[role="mt-4"]
|
447
|
+
=== `list`
|
448
|
+
|
449
|
+
The `list` parameter, in conjunction with the `listType` parameter,
|
450
|
+
identifies the content that will load in the player.
|
451
|
+
|
452
|
+
* If the `listType` parameter value is `user_uploads`, then the `list`
|
453
|
+
parameter value identifies the _YouTube_ channel whose uploaded videos
|
454
|
+
will be loaded.
|
455
|
+
* If the `listType` parameter value is `playlist`, then the `list`
|
456
|
+
parameter value specifies a YouTube playlist ID. In the parameter value,
|
457
|
+
you need to prepend the playlist ID with the letters `PL` as shown in
|
458
|
+
the example below.
|
459
|
+
|
460
|
+
....
|
461
|
+
https://www.youtube.com/embed?listType=playlist &list=PLC77007E23FF423C6
|
462
|
+
....
|
463
|
+
|
464
|
+
* If the `listType` parameter value is `search`, then the `list`
|
465
|
+
parameter value specifies the search query.
|
466
|
+
|
467
|
+
[NOTE]
|
468
|
+
====
|
469
|
+
This functionality is
|
470
|
+
link:https://developers.google.com/youtube/player_parameters#release_notes_10_13_2020[deprecated, {browser-window--new}]
|
471
|
+
and will no longer be supported as of 15 November 2020.
|
472
|
+
|
473
|
+
If you specify values for the `list` and `listType` parameters,
|
474
|
+
the IFrame embed URL does not need to specify a video ID.
|
475
|
+
====
|
476
|
+
|
477
|
+
[role="mt-4"]
|
478
|
+
=== `listType`
|
479
|
+
|
480
|
+
The `listType` parameter, in conjunction with the `list` parameter,
|
481
|
+
identifies the content that will load in the player. Valid parameter
|
482
|
+
values are `playlist` and `user_uploads`.
|
483
|
+
|
484
|
+
If you specify values for the `list` and `listType` parameters, the
|
485
|
+
IFrame embed URL does not need to specify a video ID.
|
486
|
+
|
487
|
+
[NOTE]
|
488
|
+
====
|
489
|
+
A third value, `search`, has been
|
490
|
+
link:https://developers.google.com/youtube/player_parameters#release_notes_10_13_2020[deprecated, {browser-window--new}]
|
491
|
+
and will no longer be supported as of 15 November 2020.
|
492
|
+
====
|
493
|
+
|
494
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
495
|
+
|===
|
496
|
+
|Type |Default
|
497
|
+
|
498
|
+
|`user_uploads`\|`playlist`
|
499
|
+
|no defaults
|
500
|
+
|
501
|
+
|===
|
502
|
+
|
503
|
+
[role="mt-4"]
|
504
|
+
=== `loop`
|
505
|
+
|
506
|
+
In the case of a single video player, a setting of `1` causes the player
|
507
|
+
to play the initial video again and again. In the case of a playlist
|
508
|
+
player (or custom player), the player plays the entire playlist and then
|
509
|
+
starts again at the first video.
|
510
|
+
|
511
|
+
Supported values are `0` and `1`, and the default value is `0`.
|
512
|
+
|
513
|
+
[NOTE]
|
514
|
+
====
|
515
|
+
This parameter has limited support in IFrame embeds. To loop a
|
516
|
+
single video, set the `loop` parameter value to `1` and set the
|
517
|
+
`playlist` parameter value to the same video ID already specified in the
|
518
|
+
Player API URL:
|
519
|
+
====
|
520
|
+
|
521
|
+
[source, notranslate]
|
522
|
+
----
|
523
|
+
https://www.youtube.com/embed/VIDEO_ID?playlist=VIDEO_ID&loop=1
|
524
|
+
----
|
525
|
+
|
526
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
527
|
+
|===
|
528
|
+
|Type |Default
|
529
|
+
|
530
|
+
|`0`\|`1`
|
531
|
+
|`0`
|
532
|
+
|
533
|
+
|===
|
534
|
+
|
535
|
+
[role="mt-4"]
|
536
|
+
=== `modestbranding`
|
537
|
+
|
538
|
+
[WARNING]
|
539
|
+
====
|
540
|
+
*This parameter is deprecated* and has no effect. See the
|
541
|
+
link:https://developers.google.com/youtube/player_parameters#release_notes_08_15_2023[deprecation announcement, {browser-window--new}]
|
542
|
+
for more information.
|
543
|
+
====
|
544
|
+
|
545
|
+
[role="mt-4"]
|
546
|
+
=== `origin`
|
547
|
+
|
548
|
+
This parameter provides an extra security measure for the IFrame API and
|
549
|
+
is only supported for IFrame embeds. If you are using the IFrame API,
|
550
|
+
which means you are setting the `enablejsapi` parameter value to `1`,
|
551
|
+
you should always specify your domain as the `origin` parameter value.
|
552
|
+
|
553
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
554
|
+
|===
|
555
|
+
|Type |Default
|
556
|
+
|
557
|
+
|`string`
|
558
|
+
|no defaults
|
559
|
+
|
560
|
+
|===
|
561
|
+
|
562
|
+
[role="mt-4"]
|
563
|
+
=== `playlist`
|
564
|
+
|
565
|
+
This parameter specifies a comma-separated list of video IDs to play. If
|
566
|
+
you specify a value, the first video that plays will be the `VIDEO_ID`
|
567
|
+
specified in the URL path, and the videos specified in the `playlist`
|
568
|
+
parameter will play thereafter.
|
569
|
+
|
570
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
571
|
+
|===
|
572
|
+
|Type |Default
|
573
|
+
|
574
|
+
|`array`
|
575
|
+
|no defaults
|
576
|
+
|
577
|
+
|===
|
578
|
+
|
579
|
+
[role="mt-4"]
|
580
|
+
=== `playsinline`
|
581
|
+
|
582
|
+
This parameter controls whether videos play inline or fullscreen on iOS.
|
583
|
+
Valid values are:
|
584
|
+
|
585
|
+
* `0`, Results in fullscreen playback. This is currently the default
|
586
|
+
value, though the default is subject to change.
|
587
|
+
* `1`, Results in inline playback for mobile browsers and for `WebViews`
|
588
|
+
created with the `allowsInlineMediaPlayback` property set to `YES`.
|
589
|
+
|
590
|
+
|
591
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
592
|
+
|===
|
593
|
+
|Type |Default
|
594
|
+
|
595
|
+
|`0`\|`1`
|
596
|
+
|`0`
|
597
|
+
|
598
|
+
|===
|
599
|
+
|
600
|
+
[role="mt-4"]
|
601
|
+
=== `rel`
|
602
|
+
|
603
|
+
Prior to the change, this parameter indicates whether the player should
|
604
|
+
show related videos when playback of the initial video ends.
|
605
|
+
|
606
|
+
* If the parameter's value is set to `1`, which is the default value,
|
607
|
+
then the player does show related videos.
|
608
|
+
* If the parameter's value is set to `0`, then the player does not show
|
609
|
+
related videos.
|
610
|
+
|
611
|
+
After the change, you will not be able to disable related videos.
|
612
|
+
Instead, if the `rel` parameter is set to `0`, related videos will come
|
613
|
+
from the same channel as the video that was just played.
|
614
|
+
|
615
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
616
|
+
|===
|
617
|
+
|Type |Default
|
618
|
+
|
619
|
+
|`0`\|`1`
|
620
|
+
|`1`
|
621
|
+
|
622
|
+
|===
|
623
|
+
|
624
|
+
[role="mt-4"]
|
625
|
+
=== `start`
|
626
|
+
|
627
|
+
This parameter causes the player to begin playing the video at the given
|
628
|
+
number of seconds from the start of the video. The parameter value is a
|
629
|
+
positive integer. Note that similar to the `seekTo` method, the player
|
630
|
+
will look for the closest keyframe to the time you specify. This means
|
631
|
+
that sometimes the play head may seek to just before the requested time,
|
632
|
+
usually no more than around two seconds.
|
633
|
+
|
634
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
635
|
+
|===
|
636
|
+
|Type |Default
|
637
|
+
|
638
|
+
|`integer`
|
639
|
+
|no defaults
|
640
|
+
|
641
|
+
|===
|
642
|
+
|
643
|
+
[role="mt-4"]
|
644
|
+
=== `widget_referrer`
|
645
|
+
|
646
|
+
This parameter identifies the URL where the player is embedded. This
|
647
|
+
value is used in YouTube Analytics reporting when the YouTube player is
|
648
|
+
embedded in a widget, and that widget is then embedded in a web page or
|
649
|
+
application. In that scenario, the `origin` parameter identifies the
|
650
|
+
widget provider's domain, but YouTube Analytics should not identify the
|
651
|
+
widget provider as the actual traffic source. Instead, YouTube Analytics
|
652
|
+
uses the `widget_referrer` parameter value to identify the domain
|
653
|
+
associated with the traffic source.
|
654
|
+
|
655
|
+
[cols="3a,9a", width="100%", options="header", role="rtable mt-5 mb-5"]
|
656
|
+
|===
|
657
|
+
|Type |Default
|
658
|
+
|
659
|
+
|`string`
|
660
|
+
|no defaults
|
661
|
+
|
662
|
+
|===
|
663
|
+
|
664
|
+
|
665
|
+
[role="mt-5"]
|
666
|
+
== Methods
|
667
|
+
|
668
|
+
lorem:sentences[5]
|
669
|
+
|
670
|
+
[role="mt-4"]
|
671
|
+
=== player.playVideo
|
672
|
+
|
673
|
+
Plays the currently cued/loaded video. The final player state after
|
674
|
+
this method executes will be `playing` (1). +
|
675
|
+
|
676
|
+
[NOTE]
|
677
|
+
====
|
678
|
+
A playback only counts toward a video's official view count if
|
679
|
+
it is initiated via a native play button in the player.
|
680
|
+
====
|
681
|
+
|
682
|
+
[role="mt-4"]
|
683
|
+
=== player.pauseVideo
|
684
|
+
|
685
|
+
Pauses the currently playing video. The final player state after this
|
686
|
+
method executes will be `paused` (`2`) unless the player is in
|
687
|
+
the `ended` (`0`) state when the method is called, in which case
|
688
|
+
the player state will not change.
|
689
|
+
|
690
|
+
[role="mt-4"]
|
691
|
+
=== player.stopVideo
|
692
|
+
|
693
|
+
Stops and cancels loading of the current video. This method should
|
694
|
+
be reserved for rare situations when you know that the user will not
|
695
|
+
be watching additional video in the player. If your intent is to pause
|
696
|
+
the video, you should just call the link:#pauseVideo[`pauseVideo`]
|
697
|
+
method. If you want to change the video that the player is playing,
|
698
|
+
you can call one of the queueing methods without calling
|
699
|
+
`+stopVideo+` first.
|
700
|
+
|
701
|
+
[WARNING]
|
702
|
+
====
|
703
|
+
Unlike the link:#pauseVideo[`pauseVideo`] method,
|
704
|
+
which leaves the player in the `+paused+` (`2`) state, the
|
705
|
+
`stopVideo` method could put the player into any not-playing
|
706
|
+
state, including `ended` (`0`), `paused` (`2`), `video cued`
|
707
|
+
(`5`) or `not started` (`-1`).
|
708
|
+
====
|
709
|
+
|
710
|
+
[role="mt-4"]
|
711
|
+
=== player.seekTo(seconds:Number, allowSeekAhead:Boolean)
|
712
|
+
|
713
|
+
Seeks to a specified time in the video. If the player is paused when
|
714
|
+
the method is called, it will remain paused. If the method is
|
715
|
+
called from another state (`+playing+`, `+video cued+`, etc.), the
|
716
|
+
player will play the video.
|
717
|
+
|
718
|
+
* The `seconds` parameter identifies the time to which the player
|
719
|
+
should advance.
|
720
|
+
|
721
|
+
The player will advance to the closest keyframe before that time
|
722
|
+
unless the player has already downloaded the portion of the video to
|
723
|
+
which the user is seeking.
|
724
|
+
* The `allowSeekAhead` parameter determines whether the player will
|
725
|
+
make a new request to the server if the `seconds` parameter
|
726
|
+
specifies a time outside of the currently buffered video data.
|
727
|
+
|
728
|
+
It is recommendend that you set this parameter to `false` while the user
|
729
|
+
drags the mouse along a video progress bar and then set it to `true`
|
730
|
+
when the user releases the mouse. This approach lets a user scroll to
|
731
|
+
different points of a video without requesting new video streams by
|
732
|
+
scrolling past unbuffered points in the video. When the user releases
|
733
|
+
the mouse button, the player advances to the desired point in the
|
734
|
+
video and requests a new video stream if necessary.
|
735
|
+
|
736
|
+
////
|
737
|
+
[[Spherical_Video_Controls]]
|
738
|
+
=== Controlling playback of 360° videos
|
739
|
+
|
740
|
+
*Note:* The 360° video playback experience has limited support on mobile
|
741
|
+
devices. On unsupported devices, 360° videos appear distorted and there
|
742
|
+
is no supported way to change the viewing perspective at all, including
|
743
|
+
through the API, using orientation sensors, or responding to touch/drag
|
744
|
+
actions on the device's screen.
|
745
|
+
|
746
|
+
`+player.+``+getSphericalProperties+``+():Object+`::
|
747
|
+
Retrieves properties that describe the viewer's current perspective,
|
748
|
+
or view, for a video playback. In addition:
|
749
|
+
+
|
750
|
+
* This object is only populated for 360° videos, which are also called
|
751
|
+
spherical videos.
|
752
|
+
* If the current video is not a 360° video or if the function is
|
753
|
+
called from a non-supported device, then the function returns an empty
|
754
|
+
object.
|
755
|
+
* On supported mobile devices, if the
|
756
|
+
link:#enableOrientationSensor[`+enableOrientationSensor+`] property is
|
757
|
+
set to `true`, then this function returns an object in which the
|
758
|
+
`+fov+` property contains the correct value and the other properties
|
759
|
+
are set to `+0+`.
|
760
|
+
+
|
761
|
+
The object contains the following properties:
|
762
|
+
+
|
763
|
+
[width="100%",cols="50%,50%",options="header",]
|
764
|
+
|===
|
765
|
+
|Properties |
|
766
|
+
|`+yaw+` |A number in the range [0, 360) that represents the
|
767
|
+
horizontal angle of the view in degrees, which reflects the extent to
|
768
|
+
which the user turns the view to face further left or right. The
|
769
|
+
neutral position, facing the center of the video in its
|
770
|
+
equirectangular projection, represents 0°, and this value increases as
|
771
|
+
the viewer turns left.
|
772
|
+
|
773
|
+
|`+pitch+` |A number in the range [-90, 90] that represents the
|
774
|
+
vertical angle of the view in degrees, which reflects the extent to
|
775
|
+
which the user adjusts the view to look up or down. The neutral
|
776
|
+
position, facing the center of the video in its equirectangular
|
777
|
+
projection, represents 0°, and this value increases as the viewer
|
778
|
+
looks up.
|
779
|
+
|
780
|
+
|`+roll+` a|
|
781
|
+
A number in the range [-180, 180] that represents the clockwise or
|
782
|
+
counterclockwise rotational angle of the view in degrees. The neutral
|
783
|
+
position, with the horizontal axis in the equirectangular projection
|
784
|
+
being parallel to the horizontal axis of the view, represents 0°. The
|
785
|
+
value increases as the view rotates clockwise and decreases as the
|
786
|
+
view rotates counterclockwise. +
|
787
|
+
+
|
788
|
+
Note that the embedded player does not present a user interface for
|
789
|
+
adjusting the roll of the view. The roll can be adjusted in either of
|
790
|
+
these mutually exclusive ways:
|
791
|
+
|
792
|
+
. Use the orientation sensor in a mobile browser to provide roll for
|
793
|
+
the view. If the link:#enableOrientationSensor[orientation sensor] is
|
794
|
+
enabled, then the `+getSphericalProperties+` function always returns
|
795
|
+
`+0+` as the value of the `+roll+` property.
|
796
|
+
. If the orientation sensor is disabled, set the roll to a nonzero
|
797
|
+
value using this API.
|
798
|
+
|
799
|
+
|`+fov+` |A number in the range [30, 120] that represents the
|
800
|
+
field-of-view of the view in degrees as measured along the longer edge
|
801
|
+
of the viewport. The shorter edge is automatically adjusted to be
|
802
|
+
proportional to the aspect ratio of the view. +
|
803
|
+
+
|
804
|
+
The default value is 100 degrees. Decreasing the value is like zooming
|
805
|
+
in on the video content, and increasing the value is like zooming out.
|
806
|
+
This value can be adjusted either by using the API or by using the
|
807
|
+
mousewheel when the video is in fullscreen mode.
|
808
|
+
|===
|
809
|
+
|
810
|
+
`+player.+``+setSphericalProperties+``+(properties:Object):Void+`::
|
811
|
+
Sets the video orientation for playback of a 360° video. (If the
|
812
|
+
current video is not spherical, the method is a no-op regardless of
|
813
|
+
the input.) +
|
814
|
+
+
|
815
|
+
The player view responds to calls to this method by updating to
|
816
|
+
reflect the values of any known properties in the `+properties+`
|
817
|
+
object. The view persists values for any other known properties not
|
818
|
+
included in that object. +
|
819
|
+
+
|
820
|
+
In addition:
|
821
|
+
+
|
822
|
+
* If the object contains unknown and/or unexpected properties, the
|
823
|
+
player ignores them.
|
824
|
+
* As noted at the beginning of this section, the 360° video playback
|
825
|
+
experience is not supported on all mobile devices.
|
826
|
+
* By default, on supported mobile devices, this function sets only
|
827
|
+
sets the `+fov+` property and does not affect the `+yaw+`, `+pitch+`,
|
828
|
+
and `+roll+` properties for 360° video playbacks. See the
|
829
|
+
`+enableOrientationSensor+` property below for more detail.
|
830
|
+
+
|
831
|
+
The `+properties+` object passed to the function contains the
|
832
|
+
following properties:
|
833
|
+
+
|
834
|
+
[width="100%",cols="50%,50%",options="header",]
|
835
|
+
|===
|
836
|
+
|Properties |
|
837
|
+
|`+yaw+` |See link:#spherical-property-yaw[definition] above.
|
838
|
+
|
839
|
+
|`+pitch+` |See link:#spherical-property-pitch[definition] above.
|
840
|
+
|
841
|
+
|`+roll+` |See link:#spherical-property-roll[definition] above.
|
842
|
+
|
843
|
+
|`+fov+` |See link:#spherical-property-fov[definition] above.
|
844
|
+
|
845
|
+
|`+enableOrientationSensor+` a|
|
846
|
+
[.note]##*Note:* This property affects the 360° viewing experience on
|
847
|
+
supported devices only.##A boolean value that indicates whether the
|
848
|
+
IFrame embed should respond to events that signal changes in a
|
849
|
+
supported device's orientation, such as a mobile browser's
|
850
|
+
`+DeviceOrientationEvent+`. The default parameter value is `true`. +
|
851
|
+
+
|
852
|
+
*Supported mobile devices*
|
853
|
+
|
854
|
+
* When the value is `true`, an embedded player relies _only_ on the
|
855
|
+
device's movement to adjust the `+yaw+`, `+pitch+`, and `+roll+`
|
856
|
+
properties for 360° video playbacks. However, the `+fov+` property can
|
857
|
+
still be changed via the API, and the API is, in fact, the only way to
|
858
|
+
change the `+fov+` property on a mobile device. This is the default
|
859
|
+
behavior.
|
860
|
+
* When the value is `false`, then the device's movement does not
|
861
|
+
affect the 360° viewing experience, and the `+yaw+`, `+pitch+`,
|
862
|
+
`+roll+`, and `+fov+` properties must all be set via the API.
|
863
|
+
|
864
|
+
+
|
865
|
+
*Unsupported mobile devices* +
|
866
|
+
The `+enableOrientationSensor+` property value does not have any
|
867
|
+
effect on the playback experience.
|
868
|
+
|
869
|
+
|===
|
870
|
+
|
871
|
+
== Playing a video in a playlist
|
872
|
+
|
873
|
+
`+player.+``+nextVideo+``+():Void+`::
|
874
|
+
This function loads and plays the next video in the playlist.
|
875
|
+
+
|
876
|
+
* If `+player.nextVideo()+` is called while the last video in the
|
877
|
+
playlist is being watched, and the playlist is set to play
|
878
|
+
continuously (link:#setLoop[`+loop+`]), then the player will load and
|
879
|
+
play the first video in the list.
|
880
|
+
* If `+player.nextVideo()+` is called while the last video in the
|
881
|
+
playlist is being watched, and the playlist is not set to play
|
882
|
+
continuously, then playback will end.
|
883
|
+
|
884
|
+
`+player.+``+previousVideo+``+():Void+`::
|
885
|
+
This function loads and plays the previous video in the playlist.
|
886
|
+
+
|
887
|
+
* If `+player.previousVideo()+` is called while the first video in the
|
888
|
+
playlist is being watched, and the playlist is set to play
|
889
|
+
continuously (link:#setLoop[`+loop+`]), then the player will load and
|
890
|
+
play the last video in the list.
|
891
|
+
* If `+player.previousVideo()+` is called while the first video in the
|
892
|
+
playlist is being watched, and the playlist is not set to play
|
893
|
+
continuously, then the player will restart the first playlist video
|
894
|
+
from the beginning.
|
895
|
+
|
896
|
+
`+player.+``+playVideoAt+``+(index:Number):Void+`::
|
897
|
+
This function loads and plays the specified video in the playlist.
|
898
|
+
+
|
899
|
+
* The required `+index+` parameter specifies the index of the video
|
900
|
+
that you want to play in the playlist. The parameter uses a zero-based
|
901
|
+
index, so a value of `+0+` identifies the first video in the list. If
|
902
|
+
you have link:#setShuffle[shuffled] the playlist, this function will
|
903
|
+
play the video at the specified position in the shuffled playlist.
|
904
|
+
////
|
905
|
+
|
906
|
+
[role="mt-4"]
|
907
|
+
=== Changing the player volume
|
908
|
+
|
909
|
+
lorem:sentences[5]
|
910
|
+
|
911
|
+
[role="mt-4"]
|
912
|
+
==== player.mute()
|
913
|
+
|
914
|
+
Mutes the player.
|
915
|
+
|
916
|
+
[role="mt-4"]
|
917
|
+
==== player.unMute()
|
918
|
+
|
919
|
+
Unmutes the player.
|
920
|
+
|
921
|
+
[role="mt-4"]
|
922
|
+
==== player.isMuted()
|
923
|
+
|
924
|
+
Returns `true` if the player is muted, `false` if not.
|
925
|
+
|
926
|
+
[role="mt-4"]
|
927
|
+
==== player.setVolume(volume:Number)
|
928
|
+
|
929
|
+
Sets the volume. Accepts an integer between `0` and `100`.
|
930
|
+
|
931
|
+
[role="mt-4"]
|
932
|
+
==== player.getVolume(volume:Number)
|
933
|
+
|
934
|
+
Returns the player's current volume, an integer between `0` and `100`.
|
935
|
+
|
936
|
+
[NOTE]
|
937
|
+
====
|
938
|
+
The method `getVolume()` will return the volume even if the player
|
939
|
+
is muted.
|
940
|
+
====
|
941
|
+
|
942
|
+
[role="mt-4"]
|
943
|
+
=== Setting the player size
|
944
|
+
|
945
|
+
lorem:sentences[5]
|
946
|
+
|
947
|
+
==== player.setSize(width:Number, height:Number)
|
948
|
+
|
949
|
+
Sets the size in pixels of the `<iframe>` that contains the player.
|
950
|
+
|
951
|
+
|
952
|
+
=== Setting the playback rate
|
953
|
+
|
954
|
+
lorem:sentences[5]
|
955
|
+
|
956
|
+
[role="mt-4"]
|
957
|
+
==== player.getPlaybackRate()
|
958
|
+
|
959
|
+
This method retrieves the playback rate of the currently playing
|
960
|
+
video. The default playback rate is `1`, which indicates that the
|
961
|
+
video is playing at normal speed. Playback rates may include values
|
962
|
+
like `0.25`, `0.5`, `1`, `1.5`, and `2`.
|
963
|
+
|
964
|
+
[role="mt-4"]
|
965
|
+
==== player.setPlaybackRate+(suggestedRate:Number)
|
966
|
+
|
967
|
+
This method sets the suggested playback rate for the current video.
|
968
|
+
If the playback rate changes, it will only change for the video that
|
969
|
+
is already cued or being played. If you set the playback rate for a
|
970
|
+
cued video, that rate will still be in effect when the `playVideo`
|
971
|
+
method is called or the user initiates playback directly through the
|
972
|
+
player controls. In addition, calling methods to cue or load videos
|
973
|
+
or playlists (`cueVideoById`, `loadVideoById`, etc.) will reset
|
974
|
+
the playback rate to `1`.
|
975
|
+
|
976
|
+
Calling this method does *not guarantee* that the playback rate will
|
977
|
+
actually change. However, if the playback rate does change, the
|
978
|
+
link:#onPlaybackRateChange[`onPlaybackRateChange`] event will fire,
|
979
|
+
and your code should respond to the event rather than the fact that it
|
980
|
+
called the `setPlaybackRate` method.
|
981
|
+
|
982
|
+
The link:#getAvailablePlaybackRates[`getAvailablePlaybackRates`]
|
983
|
+
method will return the possible playback rates for the currently
|
984
|
+
playing video. However, if you set the `suggestedRate` parameter to
|
985
|
+
a non-supported integer or float value, the player will round that
|
986
|
+
value down to the nearest supported value in the direction of `1`.
|
987
|
+
|
988
|
+
[role="mt-4"]
|
989
|
+
==== player.getAvailablePlaybackRates()
|
990
|
+
|
991
|
+
This method returns the set of playback rates (as an array) in which
|
992
|
+
the current video is available. The default value is `1`, which indicates
|
993
|
+
that the video is playing at normal speed.
|
994
|
+
|
995
|
+
The method returns an array of numbers ordered from slowest to
|
996
|
+
fastest playback speed. Even if the player does not support variable
|
997
|
+
playback speeds, the array should always contain at least one value
|
998
|
+
(`1`).
|
999
|
+
|
1000
|
+
[role="mt-4"]
|
1001
|
+
=== Setting playback behavior for playlists
|
1002
|
+
|
1003
|
+
lorem:sentences[5]
|
1004
|
+
|
1005
|
+
[role="mt-4"]
|
1006
|
+
==== player.setLoop+(loopPlaylists:Boolean)
|
1007
|
+
|
1008
|
+
This method indicates whether the video player should continuously
|
1009
|
+
play a playlist or if it should stop playing after the last video in
|
1010
|
+
the playlist ends. The default behavior is that playlists do not loop.
|
1011
|
+
|
1012
|
+
This setting will persist even if you load or cue a different playlist,
|
1013
|
+
which means that if you load a playlist, call the `setLoop` method with
|
1014
|
+
a value of `true`, and then load a second playlist, the second playlist
|
1015
|
+
will also loop.
|
1016
|
+
|
1017
|
+
The required `loopPlaylists` parameter identifies the looping *behavior*.
|
1018
|
+
|
1019
|
+
* If the parameter value is `true`, then the video player will
|
1020
|
+
continuously play playlists. After playing the last video in a
|
1021
|
+
playlist, the video player will go back to the beginning of the
|
1022
|
+
playlist and play it again.
|
1023
|
+
* If the parameter value is `false`, then playbacks will end after
|
1024
|
+
the video player plays the last video in a playlist.
|
1025
|
+
|
1026
|
+
[role="mt-4"]
|
1027
|
+
==== player.setShuffle(shufflePlaylist:Boolean)
|
1028
|
+
|
1029
|
+
This method indicates whether a playlist's videos should be shuffled
|
1030
|
+
so that they play back in an order different from the one that the
|
1031
|
+
playlist creator designated. If you shuffle a playlist after it has
|
1032
|
+
already started playing, the list will be reordered while the video
|
1033
|
+
that is playing continues to play. The next video that plays will then
|
1034
|
+
be selected based on the reordered list.
|
1035
|
+
|
1036
|
+
This setting will not persist if you load or cue a different playlist,
|
1037
|
+
which means that if you load a playlist, call the `setShuffle`
|
1038
|
+
method, and then load a second playlist, the second playlist will
|
1039
|
+
not be shuffled.
|
1040
|
+
|
1041
|
+
The required `shufflePlaylist` parameter indicates whether YouTube
|
1042
|
+
should shuffle the playlist.
|
1043
|
+
|
1044
|
+
* If the parameter value is `true`, then YouTube will shuffle the
|
1045
|
+
playlist order. If you instruct the method to shuffle a playlist
|
1046
|
+
that has already been shuffled, YouTube will shuffle the order again.
|
1047
|
+
* If the parameter value is `false`, then YouTube will change the
|
1048
|
+
playlist order back to its original order.
|
1049
|
+
|
1050
|
+
[role="mt-4"]
|
1051
|
+
=== Playback status
|
1052
|
+
|
1053
|
+
lorem:sentences[5]
|
1054
|
+
|
1055
|
+
[role="mt-4"]
|
1056
|
+
==== player.getVideoLoadedFraction
|
1057
|
+
|
1058
|
+
Returns a (float) number between `0` and `1` that specifies the *percentage*
|
1059
|
+
of the video that the player shows as buffered. This method returns a
|
1060
|
+
more reliable number than the now-deprecated
|
1061
|
+
link:#getVideoBytesLoaded[`getVideoBytesLoaded`] and
|
1062
|
+
link:#getVideoBytesTotal[`getVideoBytesTotal`] methods.
|
1063
|
+
|
1064
|
+
[role="mt-4"]
|
1065
|
+
==== player.etPlayerState()
|
1066
|
+
|
1067
|
+
Returns the state of the player. Possible values are:
|
1068
|
+
|
1069
|
+
* `-1`, not started
|
1070
|
+
* `0`, ended
|
1071
|
+
* `1`, playing
|
1072
|
+
* `2`, paused
|
1073
|
+
* `3`, buffering
|
1074
|
+
* `5`, video cued
|
1075
|
+
|
1076
|
+
[role="mt-4"]
|
1077
|
+
==== player.getCurrentTime()
|
1078
|
+
|
1079
|
+
Returns the elapsed time in seconds since the video started playing.
|
1080
|
+
|
1081
|
+
[role="mt-4"]
|
1082
|
+
==== player.getVideoStartBytes()
|
1083
|
+
|
1084
|
+
*Deprecated as of October 31, 2012*. Returns the number of bytes the
|
1085
|
+
video file started loading from. (This method now always returns a
|
1086
|
+
value of `0`.) Example scenario: the user seeks ahead to a point
|
1087
|
+
that hasn't loaded yet, and the player makes a new request to play a
|
1088
|
+
segment of the video that hasn't loaded yet.
|
1089
|
+
|
1090
|
+
[role="mt-4"]
|
1091
|
+
==== player.getVideoBytesLoaded()
|
1092
|
+
|
1093
|
+
*Deprecated as of July 18, 2012*. Instead, use the
|
1094
|
+
link:#getVideoLoadedFraction[`getVideoLoadedFraction`] method to
|
1095
|
+
determine the percentage of the video that has buffered.
|
1096
|
+
|
1097
|
+
This method returns a value between `0` and `1000` that
|
1098
|
+
approximates the amount of the video that has been loaded. You could
|
1099
|
+
calculate the fraction of the video that has been loaded by dividing
|
1100
|
+
the `getVideoBytesLoaded` value by the `getVideoBytesTotal` value.
|
1101
|
+
|
1102
|
+
[role="mt-4"]
|
1103
|
+
==== player.getVideoBytesTotal()
|
1104
|
+
|
1105
|
+
*Deprecated as of July 18, 2012*. Instead, use the
|
1106
|
+
link:#getVideoLoadedFraction[`getVideoLoadedFraction`] method to
|
1107
|
+
determine the percentage of the video that has buffered.
|
1108
|
+
|
1109
|
+
Returns the size in bytes of the currently loaded/playing video or an
|
1110
|
+
approximation of the video's size.
|
1111
|
+
|
1112
|
+
This method always returns a value of `1000`. You could calculate
|
1113
|
+
the fraction of the video that has been loaded by dividing the
|
1114
|
+
`getVideoBytesLoaded` value by the `getVideoBytesTotal` value.
|
1115
|
+
|
1116
|
+
[role="mt-4"]
|
1117
|
+
=== Retrieving video information
|
1118
|
+
|
1119
|
+
lorem:sentences[5]
|
1120
|
+
|
1121
|
+
[role="mt-4"]
|
1122
|
+
==== player.getDuration()
|
1123
|
+
|
1124
|
+
Returns the duration in seconds of the currently playing video. Note
|
1125
|
+
that `getDuration()` method will return `0` until the video's metadata is
|
1126
|
+
loaded, which normally happens just after the video starts playing.
|
1127
|
+
|
1128
|
+
If the currently playing video is a
|
1129
|
+
link:/youtube/2.0/developers_guide_protocol_retrieving_live_events[live
|
1130
|
+
event], the `getDuration()` method will return the elapsed time
|
1131
|
+
since the live video stream began. Specifically, this is the amount of
|
1132
|
+
time that the video has streamed without being reset or interrupted.
|
1133
|
+
In addition, this duration is commonly longer than the actual event
|
1134
|
+
time since streaming may begin before the event's start time.
|
1135
|
+
|
1136
|
+
[role="mt-4"]
|
1137
|
+
==== player.getVideoUrl()
|
1138
|
+
|
1139
|
+
Returns the YouTube.com URL for the currently loaded/playing video.
|
1140
|
+
|
1141
|
+
[role="mt-4"]
|
1142
|
+
==== player.getVideoEmbedCode()
|
1143
|
+
|
1144
|
+
Returns the embed code for the currently loaded/playing video.
|
1145
|
+
|
1146
|
+
[role="mt-4"]
|
1147
|
+
=== Retrieving playlist information
|
1148
|
+
|
1149
|
+
lorem:sentences[5]
|
1150
|
+
|
1151
|
+
[role="mt-4"]
|
1152
|
+
==== player.getPlaylist()
|
1153
|
+
|
1154
|
+
This method returns an array of the video IDs in the playlist as
|
1155
|
+
they are currently ordered. By default, this method will return
|
1156
|
+
video IDs in the order designated by the playlist owner. However, if
|
1157
|
+
you have called the link:#setShuffle[`setShuffle`] method to
|
1158
|
+
shuffle the playlist order, then the `getPlaylist()` method's
|
1159
|
+
return value will reflect the shuffled order.
|
1160
|
+
|
1161
|
+
[role="mt-4"]
|
1162
|
+
==== player.getPlaylistIndex()
|
1163
|
+
|
1164
|
+
This method returns the index of the playlist video that is
|
1165
|
+
currently playing.
|
1166
|
+
|
1167
|
+
* If you have not shuffled the playlist, the return value will
|
1168
|
+
identify the position where the playlist creator placed the video.
|
1169
|
+
The return value uses a zero-based index, so a value of `0` identifies
|
1170
|
+
the first video in the playlist.
|
1171
|
+
* If you have shuffled the playlist, the return value will identify
|
1172
|
+
the video's order within the shuffled playlist.
|
1173
|
+
|
1174
|
+
[role="mt-4"]
|
1175
|
+
=== Adding or removing an event listener
|
1176
|
+
|
1177
|
+
lorem:sentences[5]
|
1178
|
+
|
1179
|
+
[role="mt-4"]
|
1180
|
+
==== player.addEventListener(event:String, listener:String)
|
1181
|
+
|
1182
|
+
Adds a listener method for the specified `event`. The
|
1183
|
+
link:#Events[Events] section below identifies the different events
|
1184
|
+
that the player might fire. The listener is a string that specifies
|
1185
|
+
the method that will execute when the specified event fires.
|
1186
|
+
|
1187
|
+
[role="mt-4"]
|
1188
|
+
==== player.removeEventListener+(event:String, listener:String)
|
1189
|
+
|
1190
|
+
Removes a listener method for the specified `event`. The `listener`
|
1191
|
+
is a string that identifies the method that will no longer execute
|
1192
|
+
when the specified event fires.
|
1193
|
+
|
1194
|
+
[role="mt-4"]
|
1195
|
+
=== Accessing and modifying DOM nodes
|
1196
|
+
|
1197
|
+
lorem:sentences[5]
|
1198
|
+
|
1199
|
+
[role="mt-4"]
|
1200
|
+
==== player.getIframe()
|
1201
|
+
|
1202
|
+
This method returns the DOM node for the embedded `<iframe>`.
|
1203
|
+
|
1204
|
+
[role="mt-4"]
|
1205
|
+
==== player.destroy()
|
1206
|
+
|
1207
|
+
Removes the `<iframe>` containing the player.
|
1208
|
+
|
1209
|
+
|
1210
|
+
[role="mt-5"]
|
1211
|
+
== Events
|
1212
|
+
|
1213
|
+
The API fires events to notify your application of changes to the
|
1214
|
+
embedded player. As noted in the previous section, you can subscribe to
|
1215
|
+
events by adding an event listener when
|
1216
|
+
link:#Loading_a_Video_Player[constructing the `+YT.Player+` object], and
|
1217
|
+
you can also use the link:#addEventListener[`+addEventListener+`]
|
1218
|
+
method.
|
1219
|
+
|
1220
|
+
The API will pass an event object as the sole argument to each of those
|
1221
|
+
methods. The event object has the following properties:
|
1222
|
+
|
1223
|
+
* The event's `target` identifies the video player that corresponds to
|
1224
|
+
the event.
|
1225
|
+
* The event's `data` specifies a value relevant to the event. Note
|
1226
|
+
that the `onReady` and `+onAutoplayBlocked+` events do not specify a
|
1227
|
+
`data` property.
|
1228
|
+
|
1229
|
+
[role="mt-4"]
|
1230
|
+
=== onReady
|
1231
|
+
|
1232
|
+
This event fires whenever a player has finished loading and is ready
|
1233
|
+
to begin receiving API calls. Your application should implement this
|
1234
|
+
method if you want to automatically execute certain operations, such
|
1235
|
+
as playing the video or displaying information about the video, as
|
1236
|
+
soon as the player is ready.
|
1237
|
+
|
1238
|
+
The example below shows a sample method for handling this event. The
|
1239
|
+
event object that the API passes to the method has a `target`
|
1240
|
+
property, which identifies the player. The method retrieves the
|
1241
|
+
embed code for the currently loaded video, starts to play the video,
|
1242
|
+
and displays the embed code in the page element that has an `+id+`
|
1243
|
+
value of `embed-code`.
|
1244
|
+
|
1245
|
+
[source, js]
|
1246
|
+
----
|
1247
|
+
function onPlayerReady(event) {
|
1248
|
+
var embedCode = event.target.getVideoEmbedCode();
|
1249
|
+
event.target.playVideo();
|
1250
|
+
if (document.getElementById('embed-code')) {
|
1251
|
+
document.getElementById('embed-code').innerHTML = embedCode;
|
1252
|
+
}
|
1253
|
+
}
|
1254
|
+
----
|
1255
|
+
|
1256
|
+
[role="mt-4"]
|
1257
|
+
=== onStateChange
|
1258
|
+
|
1259
|
+
This event fires whenever the player's state changes. The `data`
|
1260
|
+
property of the event object that the API passes to your event
|
1261
|
+
listener method will specify an integer that corresponds to the new
|
1262
|
+
player state. Possible values are:
|
1263
|
+
|
1264
|
+
* `-1`, not started
|
1265
|
+
* `0`, ended
|
1266
|
+
* `1`, playing
|
1267
|
+
* `2`, paused
|
1268
|
+
* `3`, buffering
|
1269
|
+
* `5`, video cued
|
1270
|
+
|
1271
|
+
When the player first loads a video, it will broadcast an
|
1272
|
+
`+unstarted+` (`+-1+`) event. When a video is cued and ready to play,
|
1273
|
+
the player will broadcast a `+video cued+` (`+5+`) event. In your
|
1274
|
+
code, you can specify the integer values or you can use one of the
|
1275
|
+
following namespaced variables:
|
1276
|
+
|
1277
|
+
* `YT.PlayerState.ENDED`
|
1278
|
+
* `YT.PlayerState.PLAYING`
|
1279
|
+
* `YT.PlayerState.PAUSED`
|
1280
|
+
* `YT.PlayerState.BUFFERING`
|
1281
|
+
* `YT.PlayerState.CUED`
|
1282
|
+
|
1283
|
+
[role="mt-4"]
|
1284
|
+
=== onPlaybackQualityChange
|
1285
|
+
|
1286
|
+
This event fires whenever the video playback quality changes. It might
|
1287
|
+
signal a change in the viewer's playback environment. See the
|
1288
|
+
https://support.google.com/youtube/answer/91449[YouTube Help Center]
|
1289
|
+
for more information about factors that affect playback conditions or
|
1290
|
+
that might cause the event to fire.
|
1291
|
+
|
1292
|
+
The `data` property value of the event object that the API passes to
|
1293
|
+
the event listener method will be a string that identifies the new
|
1294
|
+
playback quality. Possible values are:
|
1295
|
+
|
1296
|
+
* `small`
|
1297
|
+
* `medium`
|
1298
|
+
* `large`
|
1299
|
+
* `hd720`
|
1300
|
+
* `hd1080`
|
1301
|
+
* `highres`
|
1302
|
+
|
1303
|
+
[role="mt-4"]
|
1304
|
+
=== onPlaybackRateChange
|
1305
|
+
|
1306
|
+
This event fires whenever the video playback rate changes. For
|
1307
|
+
example, if you call the
|
1308
|
+
link:#setPlaybackRate[`+setPlaybackRate(suggestedRate)+`] method,
|
1309
|
+
this event will fire if the playback rate actually changes. Your
|
1310
|
+
application should respond to the event and should not assume that the
|
1311
|
+
playback rate will automatically change when the
|
1312
|
+
link:#setPlaybackRate[`+setPlaybackRate(suggestedRate)+`] method is
|
1313
|
+
called. Similarly, your code should not assume that the video playback
|
1314
|
+
rate will only change as a result of an explicit call to `setPlaybackRate`.
|
1315
|
+
|
1316
|
+
The `data` property value of the event object that the API passes to
|
1317
|
+
the event listener method will be a number that identifies the new
|
1318
|
+
playback rate. The
|
1319
|
+
link:#getAvailablePlaybackRates[`+getAvailablePlaybackRates+`] method
|
1320
|
+
returns a list of the valid playback rates for the currently cued or
|
1321
|
+
playing video.
|
1322
|
+
|
1323
|
+
[role="mt-4"]
|
1324
|
+
=== onError
|
1325
|
+
|
1326
|
+
This event fires if an error occurs in the player. The API will pass
|
1327
|
+
an `event` object to the event listener method. That object's
|
1328
|
+
`data` property will specify an integer that identifies the type of
|
1329
|
+
error that occurred.
|
1330
|
+
|
1331
|
+
Possible values are:
|
1332
|
+
|
1333
|
+
* `2`, The request contains an invalid parameter value. For
|
1334
|
+
example, this error occurs if you specify a video ID that does not
|
1335
|
+
have 11 characters, or if the video ID contains invalid characters,
|
1336
|
+
such as exclamation points or asterisks.
|
1337
|
+
* `5`, The requested content cannot be played in an HTML5 player or
|
1338
|
+
another error related to the HTML5 player has occurred.
|
1339
|
+
* `100`, The video requested was not found. This error occurs when
|
1340
|
+
a video has been removed (for any reason) or has been marked as
|
1341
|
+
private.
|
1342
|
+
* `101`, The owner of the requested video does not allow it to be
|
1343
|
+
played in embedded players.
|
1344
|
+
* `150`, This error is the same as `101`. It's just a `101`
|
1345
|
+
error in disguise.
|
1346
|
+
|
1347
|
+
[role="mt-4"]
|
1348
|
+
=== onApiChange
|
1349
|
+
|
1350
|
+
This event is fired to indicate that the player has loaded (or
|
1351
|
+
unloaded) a module with exposed API methods. Your application can
|
1352
|
+
listen for this event and then poll the player to determine which
|
1353
|
+
options are exposed for the recently loaded module. Your application
|
1354
|
+
can then retrieve or update the existing settings for those options.
|
1355
|
+
|
1356
|
+
The following command retrieves an array of module names for which you
|
1357
|
+
can set player options:
|
1358
|
+
|
1359
|
+
[source, js]
|
1360
|
+
----
|
1361
|
+
player.getOptions();
|
1362
|
+
----
|
1363
|
+
|
1364
|
+
Currently, the only module that you can set options for is the
|
1365
|
+
`captions` module, which handles closed captioning in the player.
|
1366
|
+
Upon receiving an `+onApiChange+` event, your application can use the
|
1367
|
+
following command to determine which options can be set for the
|
1368
|
+
`captions` module:
|
1369
|
+
|
1370
|
+
[source, js]
|
1371
|
+
----
|
1372
|
+
player.getOptions('captions');
|
1373
|
+
----
|
1374
|
+
|
1375
|
+
By polling the player with this command, you can confirm that the
|
1376
|
+
options you want to access are, indeed, accessible. The following
|
1377
|
+
commands retrieve and update module options:
|
1378
|
+
|
1379
|
+
[source, js]
|
1380
|
+
----
|
1381
|
+
// Retrieving an option:
|
1382
|
+
player.getOption(module, option);
|
1383
|
+
|
1384
|
+
//Setting an option
|
1385
|
+
player.setOption(module, option, value);
|
1386
|
+
----
|
1387
|
+
|
1388
|
+
The table below lists the options that the API supports:
|
1389
|
+
|
1390
|
+
[width="100%",cols="34%,33%,33%",options="header",]
|
1391
|
+
|===
|
1392
|
+
|Module |Option |Description
|
1393
|
+
|captions
|
1394
|
+
|fontSize
|
1395
|
+
|This option adjusts the font size of the captions displayed in the player. +
|
1396
|
+
|
1397
|
+
Valid values are `-1`, `0`, `1`, `2`, and `3`. The default size is `0`,
|
1398
|
+
and the smallest size is `-1`. Setting this option to an integer below `-1`
|
1399
|
+
will cause the smallest caption size to display, while setting this option
|
1400
|
+
to an integer above `3` will cause the largest caption size to display.
|
1401
|
+
|
1402
|
+
|captions
|
1403
|
+
|reload
|
1404
|
+
|This option reloads the closed caption data for the video that is playing.
|
1405
|
+
The value will be `null` if you retrieve the option's value. Set the value
|
1406
|
+
to `true` to reload the closed caption
|
1407
|
+
data.
|
1408
|
+
|===
|
1409
|
+
|
1410
|
+
[role="mt-4"]
|
1411
|
+
=== onAutoplayBlocked
|
1412
|
+
|
1413
|
+
This event fires any time the browser blocks autoplay or scripted
|
1414
|
+
video playback features, collectively referred to as "autoplay". This
|
1415
|
+
includes playback attempted with any of the following player APIs:
|
1416
|
+
|
1417
|
+
* link:/youtube/player_parameters#autoplay[`autoplay`] parameter
|
1418
|
+
* link:#loadPlaylist[`loadPlaylist`] method
|
1419
|
+
* link:#loadVideoById[`loadVideoById`] method
|
1420
|
+
* link:#loadVideoByUrl[`loadVideoByUrl`] method
|
1421
|
+
* link:#playVideo[`playVideo`] method
|
1422
|
+
|
1423
|
+
Most browsers have policies that can block autoplay in desktop,
|
1424
|
+
mobile, and other environments if certain conditions are true.
|
1425
|
+
Instances where this policy may be triggered include unmuted playback
|
1426
|
+
without user interaction, or when a
|
1427
|
+
https://developer.mozilla.org/en-US/docs/Web/HTTP/Permissions_Policy[Permissions
|
1428
|
+
Policy] to permit autoplay on a cross-origin iframe has not been
|
1429
|
+
set.
|
1430
|
+
|
1431
|
+
For complete details, refer to browser-specific policies
|
1432
|
+
(https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari/#3030251[Apple
|
1433
|
+
Safari / Webkit], https://developer.chrome.com/blog/autoplay/[Google
|
1434
|
+
Chrome], https://support.mozilla.org/en-US/kb/block-autoplay[Mozilla
|
1435
|
+
Firefox]) and Mozilla's
|
1436
|
+
https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide[autoplay
|
1437
|
+
guide].
|
1438
|
+
|
1439
|
+
|
1440
|
+
[role="mt-5"]
|
1441
|
+
== Examples
|
1442
|
+
|
1443
|
+
=== Example 1
|
1444
|
+
|
1445
|
+
Use API with existing <iframe>. In this example, an `<iframe>` element on
|
1446
|
+
the page already defines the player with which the API will be used. Note
|
1447
|
+
that either the player's `src` URL must set the
|
1448
|
+
link:/youtube/player_parameters#enablejsapi[`enablejsapi`] parameter
|
1449
|
+
to `1` or the `<iframe>` element's `enablejsapi` attribute must be
|
1450
|
+
set to `true`.
|
1451
|
+
|
1452
|
+
The `onPlayerReady` method changes the color of the border around
|
1453
|
+
the player to orange when the player is ready. The
|
1454
|
+
`onPlayerStateChange+ method then changes the color of the border
|
1455
|
+
around the player based on the current player status. For example, the
|
1456
|
+
color is green when the player is playing, red when paused, blue when
|
1457
|
+
buffering, and so forth.
|
1458
|
+
|
1459
|
+
This example uses the following code:
|
1460
|
+
|
1461
|
+
[source, html]
|
1462
|
+
----
|
1463
|
+
<iframe id="existing-iframe-example"
|
1464
|
+
width="640" height="360"
|
1465
|
+
src="https://www.youtube.com/embed/M7lc1UVf-VE?enablejsapi=1"
|
1466
|
+
frameborder="0"
|
1467
|
+
style="border: solid 4px #37474F"
|
1468
|
+
></iframe>
|
1469
|
+
|
1470
|
+
<script type="text/javascript">
|
1471
|
+
var tag = document.createElement('script');
|
1472
|
+
tag.id = 'iframe-demo';
|
1473
|
+
tag.src = 'https://www.youtube.com/iframe_api';
|
1474
|
+
var firstScriptTag = document.getElementsByTagName('script')[0];
|
1475
|
+
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
1476
|
+
|
1477
|
+
var player;
|
1478
|
+
function onYouTubeIframeAPIReady() {
|
1479
|
+
player = new YT.Player('existing-iframe-example', {
|
1480
|
+
events: {
|
1481
|
+
'onReady': onPlayerReady,
|
1482
|
+
'onStateChange': onPlayerStateChange
|
1483
|
+
}
|
1484
|
+
});
|
1485
|
+
}
|
1486
|
+
function onPlayerReady(event) {
|
1487
|
+
document.getElementById('existing-iframe-example').style.borderColor = '#FF6D00';
|
1488
|
+
}
|
1489
|
+
function changeBorderColor(playerStatus) {
|
1490
|
+
var color;
|
1491
|
+
if (playerStatus == -1) {
|
1492
|
+
color = "#37474F"; // unstarted = gray
|
1493
|
+
} else if (playerStatus == 0) {
|
1494
|
+
color = "#FFFF00"; // ended = yellow
|
1495
|
+
} else if (playerStatus == 1) {
|
1496
|
+
color = "#33691E"; // playing = green
|
1497
|
+
} else if (playerStatus == 2) {
|
1498
|
+
color = "#DD2C00"; // paused = red
|
1499
|
+
} else if (playerStatus == 3) {
|
1500
|
+
color = "#AA00FF"; // buffering = purple
|
1501
|
+
} else if (playerStatus == 5) {
|
1502
|
+
color = "#FF6DOO"; // video cued = orange
|
1503
|
+
}
|
1504
|
+
if (color) {
|
1505
|
+
document.getElementById('existing-iframe-example').style.borderColor = color;
|
1506
|
+
}
|
1507
|
+
}
|
1508
|
+
function onPlayerStateChange(event) {
|
1509
|
+
changeBorderColor(event.data);
|
1510
|
+
}
|
1511
|
+
</script>
|
1512
|
+
----
|
1513
|
+
|
1514
|
+
[role="mt-4"]
|
1515
|
+
=== Example 2
|
1516
|
+
|
1517
|
+
Loud playback. This example creates a 1280px by 720px video player.
|
1518
|
+
The event listener for the `onReady` event then calls the link:#setVolume[`setVolume`]
|
1519
|
+
method to adjust the volume to the highest setting.
|
1520
|
+
|
1521
|
+
[source, js]
|
1522
|
+
----
|
1523
|
+
function onYouTubeIframeAPIReady() {
|
1524
|
+
var player;
|
1525
|
+
player = new YT.Player('player', {
|
1526
|
+
width: 1280,
|
1527
|
+
height: 720,
|
1528
|
+
videoId: 'M7lc1UVf-VE',
|
1529
|
+
events: {
|
1530
|
+
'onReady': onPlayerReady,
|
1531
|
+
'onStateChange': onPlayerStateChange,
|
1532
|
+
'onError': onPlayerError
|
1533
|
+
}
|
1534
|
+
});
|
1535
|
+
}
|
1536
|
+
|
1537
|
+
function onPlayerReady(event) {
|
1538
|
+
event.target.setVolume(100);
|
1539
|
+
event.target.playVideo();
|
1540
|
+
}
|
1541
|
+
----
|
1542
|
+
|
1543
|
+
[role="mt-4"]
|
1544
|
+
=== Example 3
|
1545
|
+
|
1546
|
+
This example sets player parameters to automatically play
|
1547
|
+
the video when it loads and to hide the video player's controls. It also
|
1548
|
+
adds event listeners for several events that the API broadcasts.
|
1549
|
+
|
1550
|
+
[source, js]
|
1551
|
+
----
|
1552
|
+
function onYouTubeIframeAPIReady() {
|
1553
|
+
var player;
|
1554
|
+
player = new YT.Player('player', {
|
1555
|
+
videoId: 'M7lc1UVf-VE',
|
1556
|
+
playerVars: { 'autoplay': 1, 'controls': 0 },
|
1557
|
+
events: {
|
1558
|
+
'onReady': onPlayerReady,
|
1559
|
+
'onStateChange': onPlayerStateChange,
|
1560
|
+
'onError': onPlayerError
|
1561
|
+
}
|
1562
|
+
});
|
1563
|
+
}
|
1564
|
+
----
|
1565
|
+
|
1566
|
+
////
|
1567
|
+
[[Example_Control_Spherical_Videos]]
|
1568
|
+
==== Controlling 360° videos
|
1569
|
+
|
1570
|
+
[[spherical-video-player]]
|
1571
|
+
|
1572
|
+
[width="100%",cols="20%,20%,20%,20%,20%",]
|
1573
|
+
|===
|
1574
|
+
a|
|
1575
|
+
yaw: +
|
1576
|
+
|
1577
|
+
[[yaw-current-value]]
|
1578
|
+
|
1579
|
+
a|
|
1580
|
+
pitch: +
|
1581
|
+
|
1582
|
+
[[pitch-current-value]]
|
1583
|
+
|
1584
|
+
a|
|
1585
|
+
roll: +
|
1586
|
+
|
1587
|
+
[[roll-current-value]]
|
1588
|
+
|
1589
|
+
a|
|
1590
|
+
fov: +
|
1591
|
+
|
1592
|
+
[[fov-current-value]]
|
1593
|
+
|
1594
|
+
|Update properties
|
1595
|
+
|===
|
1596
|
+
|
1597
|
+
This example uses the following code:
|
1598
|
+
|
1599
|
+
[source,devsite-click-to-copy,notranslate]
|
1600
|
+
----
|
1601
|
+
<style>
|
1602
|
+
.current-values {
|
1603
|
+
color: #666;
|
1604
|
+
font-size: 12px;
|
1605
|
+
}
|
1606
|
+
</style>
|
1607
|
+
<!-- The player is inserted in the following div element -->
|
1608
|
+
<div id="spherical-video-player"></div>
|
1609
|
+
|
1610
|
+
<!-- Display spherical property values and enable user to update them. -->
|
1611
|
+
<table style="border: 0; width: 640px;">
|
1612
|
+
<tr style="background: #fff;">
|
1613
|
+
<td>
|
1614
|
+
<label for="yaw-property">yaw: </label>
|
1615
|
+
<input type="text" id="yaw-property" style="width: 80px"><br>
|
1616
|
+
<div id="yaw-current-value" class="current-values"> </div>
|
1617
|
+
</td>
|
1618
|
+
<td>
|
1619
|
+
<label for="pitch-property">pitch: </label>
|
1620
|
+
<input type="text" id="pitch-property" style="width: 80px"><br>
|
1621
|
+
<div id="pitch-current-value" class="current-values"> </div>
|
1622
|
+
</td>
|
1623
|
+
<td>
|
1624
|
+
<label for="roll-property">roll: </label>
|
1625
|
+
<input type="text" id="roll-property" style="width: 80px"><br>
|
1626
|
+
<div id="roll-current-value" class="current-values"> </div>
|
1627
|
+
</td>
|
1628
|
+
<td>
|
1629
|
+
<label for="fov-property">fov: </label>
|
1630
|
+
<input type="text" id="fov-property" style="width: 80px"><br>
|
1631
|
+
<div id="fov-current-value" class="current-values"> </div>
|
1632
|
+
</td>
|
1633
|
+
<td style="vertical-align: bottom;">
|
1634
|
+
<button id="spherical-properties-button">Update properties</button>
|
1635
|
+
</td>
|
1636
|
+
</tr>
|
1637
|
+
</table>
|
1638
|
+
////
|