forked from scrublord69420/theme
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoverlay.js
More file actions
141 lines (132 loc) · 4.62 KB
/
overlay.js
File metadata and controls
141 lines (132 loc) · 4.62 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
$("#videowrap").append("<div id='VideoOverlay' class='fadein'><button class='btn btn-sm btn-default OLB' id='fs-vid-button'>Fullscreen</button></div>");
/*$('#videowrap').hover(function(){
$('#VideoOverlay').css({
'opacity':'1',
'display':'block',
});
},function(){
$('#VideoOverlay').css({
'opacity':'0',
'display':'none',
});
});
*/
$("#VideoOverlay").hide();
var i = null;
$("#videowrap").mousemove(function() {
clearTimeout(i);
$("#VideoOverlay").show();
i = setTimeout('$("#VideoOverlay").hide();', 5000);
}).mouseleave(function() {
clearTimeout(i);
$("#VideoOverlay").hide();
});
$("#VideoOverlay").append($("#voteskip"));
$("#VideoOverlay").append($("#mediarefresh"));
$("#VideoOverlay").append("<button id='hidechat' title='Hide Chat' class='btn btn-sm btn-default OLB'>Theater Mode</button>");
$("#VideoOverlay").append("<button id='showchat' title='show Chat' class='btn btn-sm btn-default OLB'>Regular Mode</button>");
$("#VideoOverlay").append("<button id='pipButton' title='Picture In Picture' class='btn btn-sm btn-default OLB'>PIP</button>");
$(document).ready(function(){
$('#hidechat').on('click', function(){nochat();});
$('#showchat').on('click', function(){maxchat();});
});
function nochat(){
$('#chatwrap').addClass('hidden');
$('#pollwrap').addClass('hidden');
$('#maincontain').addClass('fullvideo');
$('#hidechat,#scroll-feature,#motdrow,#videoinfo,#queuecontainer,#footer,.navbar,#bg-wrapper,#rightpane').addClass('hidden');
$('#showchat').addClass('showchat');
$('#mainpage').css({
'padding-top':'0px',
});
$('#videowrap').css({
'position':'fixed',
'height':'100%!important',
});
$('.embed-responsive').css({
'position':'static',
});
}
function maxchat(){
$('#chatwrap').removeClass('hidden');
$('#pollwrap').removeClass('hidden');
$('#maincontain').removeClass('fullvideo');
$('#hidechat,#scroll-feature,#motdrow,#videoinfo,#queuecontainer,#footer,.navbar,#bg-wrapper,#rightpane').removeClass('hidden');
$('#showchat').removeClass('showchat');
$('#mainpage').css({
'padding-top':'50px',
});
$('#videowrap').css({
'position':'inherit',
'height':'inherit',
});
$('.embed-responsive').css({
'position':'relative',
});
}
var requestFullscreen = function (ele) {
if (ele.requestFullscreen) {
ele.requestFullscreen();
} else if (ele.webkitRequestFullscreen) {
ele.webkitRequestFullscreen();
} else if (ele.mozRequestFullScreen) {
ele.mozRequestFullScreen();
} else if (ele.msRequestFullscreen) {
ele.msRequestFullscreen();
} else {
console.log('Fullscreen API is not supported.');
}
};
var exitFullscreen = function () {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else {
console.log('Fullscreen API is not supported.');
}
};
var fsVidButton = document.getElementById('fs-vid-button');
var video = document.getElementById('videowrap');
fsVidButton.addEventListener('click', function(e) {
e.preventDefault();
requestFullscreen(videowrap);
});
// Hide button if Picture-in-Picture is not supported or disabled.
pipButton.hidden = !document.pictureInPictureEnabled || ytapiplayer_html5_api.disablePictureInPicture;
pipButton.addEventListener('click', function() {
// If there is no element in Picture-in-Picture yet, let's request
// Picture-in-Picture for the video, otherwise leave it.
if (!document.pictureInPictureElement) {
ytapiplayer_html5_api.requestPictureInPicture()
.then(pipWindow => {
updateVideoSize(pipWindow.width, pipWindow.height);
pipWindow.addEventListener('resize', function(event) {
updateVideoSize(pipWindow.width, pipWindow.height);
});
})
.catch(error => {
console.log(error)
// Video failed to enter Picture-in-Picture mode.
});
} else {
document.exitPictureInPicture()
.catch(error => {
console.error(error)
// Video failed to leave Picture-in-Picture mode.
});
}
});
function updateVideoSize(width, height) {
// TODO: Update video size based on pip window width and height.
}
ytapiplayer_html5_api.addEventListener('enterpictureinpicture', function() {
// Video element entered Picture-In-Picture mode.
});
ytapiplayer_html5_api.addEventListener('leavepictureinpicture', function() {
// Video element left Picture-In-Picture mode.
});