<script src="https://www.youtube.com/iframe_api"></script>
<!-- Business Web Technology (ISYS3004) -->
<!-- School of Information Systems -->
<!-- Curtin University -->
<!-- See External Resources for you tube api reference -->
<!-- https://www.youtube.com/iframe_api" -->
<h2> Select a video </h2>
<select id="selectVideo" onchnage="playSegment()">
</select>
// When You Tube API is ready, create a new
// You Tube player in the div with id 'player'
function onYouTubeIframeAPIReady() {
resetVideo();
player = new YT.Player('player', {
playerVars: {
autoplay: 0,
start: 10,
rel:0,
theme: "light",
controls: 1,
showinfo: 0,
modestbranding: 1
},
events: {
onReady: onReady,
onStateChange: onStateChange,
onError: onError
}
});
}
// When the player is ready, play the initial segment
function onReady(event) {
console.log("ready");
playSegment();
}
// When the instructional part of the clip has finished
// playing, build the quiz question to test the
// viwers understanding
function onStateChange(event) {
console.log('onStateChange', event);
if (event.data == YT.PlayerState.ENDED) {
console.log("video ended");
}
}
}
// Log any errors
function onError(event) {
console.log('onError', event);
}
// Play the video segment
function playSegment( ) {
// Play the current video
var selected = document.getElementById("selectVideo").value;
player.loadVideoById({
videoId: media[selected].video
});
}
// In a real application, the items below would come from a database
var media = [
{
video: "a1YzCWeoHdc",
title: 'Apple',
description: 'Eating an apple a day keeps the doctor away!'
},
{
video: "EkQooes5R2k",
title: 'Banana',
description: 'A banana is a good source of engery'
},
{
video: 'kgEkCtmkXUI',
title: 'Carrot',
description: "Carrots are good for your eye sight!"
},
{
video: 'MfUcsgtNN24',
title: 'Hat',
description: 'Belongs on your head, not in your kitchen or your tummy!'
}
];
function loadVideoSelectMenu() {
var htmlText = "";
for (var i=0;...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.