-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
105 lines (87 loc) · 3.67 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/YTiFramePlayerAPI.css" />
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="https://code.jquery.com/jquery-3.2.1.min.js"><\/script>')</script>
</head>
<body>
<!--[if lte IE 9]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience and security.</p>
<![endif]-->
<button class="insertVideo" type="button">Insert Video</button>
<!-- Video Controls START -->
<div class="video-controls">
<button class="playVideo" type="button">Play</button>
<button class="pauseVideo" type="button">Pause</button>
<button class="stopVideo" type="button">Stop</button>
</div>
<!-- Video Controls END -->
<!-- Video STARTS-->
<div class="video-container" data-yt-src="R51LMIAJtsc">
<!-- YouTube Video overwrites this div-->
<div id="video-player">
</div>
</div>
<!-- Video ENDS-->
<script>
// Global variables
var $currentYTVideoSrc = $('.video-container').data('yt-src');
var $insertVideo = $('button.insertVideo');
var $playVideo = $('button.playVideo');
var $pauseVideo = $('button.pauseVideo');
var $stopVideo = $('button.stopVideo');
var $videoControls = $('.video-controls');
var $videoContainer = $('.video-container');
var player = '';
// 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);
// Creates an <iframe> (and YouTube player) after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('video-player', {
height: '390',
width: '640',
videoId: $currentYTVideoSrc,
events: {
'onReady': onPlayerReady
}
});
}
// API calls this function when the video player is ready
function onPlayerReady(event) {
$insertVideo.css('display', 'block');
}
// Play the video function
function playVideo() {
player.playVideo();
}
// Pause the video function
function pauseVideo() {
player.pauseVideo();
}
// Insert video click event
$insertVideo.on('click', function() {
$videoControls.css('display', 'block');
$videoContainer.css('display', 'block');
$(this).hide();
});
// Play video click event
$playVideo.on('click', function() {
playVideo();
});
// Pause video click event
$pauseVideo.on('click', function() {
pauseVideo();
});
</script>
</body>
</html>