student:demo
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
student:demo [2020/04/13 18:50] – jonathan | student:demo [2020/04/13 19:40] (current) – jonathan | ||
---|---|---|---|
Line 22: | Line 22: | ||
{{: | {{: | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | **What is FizzBuzz**? Write a program that prints the numbers from 1 to 100. But for multiples of three print " | ||
+ | |||
+ | See the post [[https:// | ||
+ | |||
Line 31: | Line 38: | ||
< | < | ||
- | | + | <iframe width="560" |
- | + | src=" | |
- | < | + | frameborder="0" allow=" |
- | // 2. This code loads the IFrame Player API code asynchronously. | + | encrypted-media; gyroscope; picture-in-picture" |
- | var tag = document.createElement(' | + | allowfullscreen> |
- | + | </iframe> | |
- | tag.src = " | + | |
- | var firstScriptTag | + | |
- | firstScriptTag.parentNode.insertBefore(tag, | + | |
- | + | ||
- | // 3. This function creates an < | + | |
- | // after the API code downloads. | + | |
- | var player; | + | |
- | function onYouTubeIframeAPIReady() { | + | |
- | player | + | |
- | height: ' | + | |
- | width: ' | + | |
- | videoId: ' | + | |
- | events: { | + | |
- | ' | + | |
- | ' | + | |
- | } | + | |
- | }); | + | |
- | } | + | |
- | + | ||
- | // 4. The API will call this function when the video player is ready. | + | |
- | function onPlayerReady(event) { | + | |
- | event.target.playVideo(); | + | |
- | } | + | |
- | + | ||
- | // 5. The API calls this function when the player' | + | |
- | // The function indicates that when playing a video (state=1), | + | |
- | // the player should play for six seconds and then stop. | + | |
- | var done = false; | + | |
- | function onPlayerStateChange(event) { | + | |
- | if (event.data == YT.PlayerState.PLAYING && !done) { | + | |
- | setTimeout(stopVideo, | + | |
- | done = true; | + | |
- | } | + | |
- | } | + | |
- | function stopVideo() { | + | |
- | player.stopVideo(); | + | |
- | } | + | |
- | | + | |
</ | </ |
student/demo.1586803801.txt.gz · Last modified: 2020/04/13 18:50 by jonathan