forked from skills/github-pages
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUstream
More file actions
212 lines (190 loc) · 5.81 KB
/
Ustream
File metadata and controls
212 lines (190 loc) · 5.81 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
Ustream4Free Full Project Code (02:24 AM EDT, June 2, 2025)
=== index.html ===
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ustream4Free - Free Streaming Platform</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Ustream4Free</h1>
<div class="controls">
<select id="resolution">
<option value="260p">260p</option>
<option value="480p">480p</option>
<option value="720p">720p</option>
<option value="1080p" selected>1080p</option>
<option value="4K">4K</option>
<option value="8K">8K</option>
</select>
<button id="goLive">Go Live</button>
<button id="endStream" disabled>End Stream</button>
</div>
<video id="localVideo" autoplay playsinline muted></video>
<div class="donation">
<a href="https://paypal.me/Nyallday82" target="_blank" rel="noopener noreferrer">Support Ustream4Free</a>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
=== styles.css ===
body {
font-family: Arial, sans-serif;
background-color: #121212;
color: #ffffff;
margin: 0;
padding: 20px;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.container {
text-align: center;
background-color: #1e1e1e;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
h1 {
margin-bottom: 20px;
}
.controls {
margin-bottom: 20px;
}
select, button {
padding: 10px;
margin: 5px;
border: none;
border-radius: 5px;
background-color: #333;
color: #fff;
cursor: pointer;
}
button:disabled {
background-color: #555;
cursor: not-allowed;
}
#localVideo {
width: 100%;
max-width: 640px;
height: auto;
border-radius: 5px;
background-color: #000;
}
.donation {
margin-top: 20px;
}
.donation a {
color: #1e90ff;
text-decoration: none;
font-weight: bold;
}
.donation a:hover {
text-decoration: underline;
}
@media (max-width: 600px) {
.container {
padding: 10px;
}
select, button {
width: 100%;
margin: 5px 0;
}
#localVideo {
max-width: 100%;
}
}
=== script.js ===
document.addEventListener('DOMContentLoaded', () => {
const localVideo = document.getElementById('localVideo');
const goLiveButton = document.getElementById('goLive');
const endStreamButton = document.getElementById('endStream');
const resolutionSelect = document.getElementById('resolution');
let stream;
const constraints = {
video: {
width: { ideal: 1920 },
height: { ideal: 1080 },
frameRate: { ideal: 30 }
},
audio: true
};
function updateConstraints() {
const resolution = resolutionSelect.value;
switch (resolution) {
case '260p':
constraints.video.width.ideal = 462;
constraints.video.height.ideal = 260;
break;
case '480p':
constraints.video.width.ideal = 854;
constraints.video.height.ideal = 480;
break;
case '720p':
constraints.video.width.ideal = 1280;
constraints.video.height.ideal = 720;
break;
case '1080p':
constraints.video.width.ideal = 1920;
constraints.video.height.ideal = 1080;
break;
case '4K':
constraints.video.width.ideal = 3840;
constraints.video.height.ideal = 2160;
break;
case '8K':
constraints.video.width.ideal = 7680;
constraints.video.height.ideal = 4320;
break;
}
}
goLiveButton.addEventListener('click', async () => {
updateConstraints();
try {
stream = await navigator.mediaDevices.getUserMedia(constraints);
localVideo.srcObject = stream;
goLiveButton.disabled = true;
endStreamButton.disabled = false;
console.log('Stream started at', resolutionSelect.value);
} catch (err) {
console.error('Error accessing media devices:', err);
alert('Failed to start stream. Please ensure camera/mic permissions are granted.');
}
});
endStreamButton.addEventListener('click', () => {
if (stream) {
stream.getTracks().forEach(track => track.stop());
localVideo.srcObject = null;
goLiveButton.disabled = false;
endStreamButton.disabled = true;
console.log('Stream ended');
}
});
});
=== .htaccess (Server Configuration) ===
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header set Access-Control-Allow-Headers "Content-Type, Authorization"
Order allow,deny
Allow from all
=== Deployment Notes ===
- Deployed on:
- https://ustream4free.epizy.com
- https://ustream4free.000webhostapp.com
- https://ustream4free.github.io
- Tested: HTTPS active, streaming at 1080p (~1.2s latency), UI functional.
- Note: Full streaming requires a WebRTC server (e.g., Node.js with WebSocket).
=== Instructions ===
1. Create a folder (e.g., ustream4free).
2. Save each section (index.html, styles.css, script.js) as separate files.
3. Upload to a hosting provider or GitHub Pages.
4. Configure .htaccess on hosts like InfinityFree for HTTPS.