All of the changes that have been sitting on tildepi for ages. For posterity.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3530 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2020-09-23 01:58:13 +00:00
parent d6018736d5
commit d293637741
29 changed files with 3380 additions and 8 deletions

View File

@ -0,0 +1,63 @@
terminal.print({iframe: `
<style>
html, body {
padding: 0;
margin: 0;
overflow: hidden;
}
</style>
<!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
<div id="player"></div>
<script>
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://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.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'M7lc1UVf-VE',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// 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's state changes.
// 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) {
parent.postMessage({
state: event.data,
url: event.target.getVideoUrl(),
}, "*");
if (event.data == YT.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 6000);
done = true;
}
}
function stopVideo() {
player.stopVideo();
}
</script>
`, width: 640, height: 390, style: "padding: 0; margin: 0; border: 0"});
terminal.print("hi");
core.register("onWindowMessage", function(event) {
terminal.print("message", JSON.stringify(event.message));
});