Added temporary route and template to demonstrate the display of video streams
This commit is contained in:
@@ -2,6 +2,13 @@ from flask import render_template, Blueprint
|
|||||||
|
|
||||||
main_bp = Blueprint("app", __name__)
|
main_bp = Blueprint("app", __name__)
|
||||||
|
|
||||||
|
## temp, showcasing HLS
|
||||||
|
@main_bp.route('/hls1/<stream_id>')
|
||||||
|
def hls(stream_id):
|
||||||
|
stream_url = f"http://127.0.0.1:8080/hls/{stream_id}/index.m3u8"
|
||||||
|
return render_template("video.html", video_url=stream_url)
|
||||||
|
#--------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@main_bp.route('/get_loggedin_status')
|
@main_bp.route('/get_loggedin_status')
|
||||||
def get_loggedin_status():
|
def get_loggedin_status():
|
||||||
@@ -11,12 +18,24 @@ def get_loggedin_status():
|
|||||||
"""
|
"""
|
||||||
return {"logged_in": logged_in}
|
return {"logged_in": logged_in}
|
||||||
|
|
||||||
|
@main_bp.route('/authenticate_user')
|
||||||
|
def authenticate_user():
|
||||||
|
"""
|
||||||
|
Authenticates the user
|
||||||
|
"""
|
||||||
|
return {"authenticated": True}
|
||||||
|
|
||||||
|
|
||||||
@main_bp.route('/get_streams')
|
@main_bp.route('/get_streams')
|
||||||
def get_sample_streams():
|
def get_sample_streams():
|
||||||
"""
|
"""
|
||||||
Returns a list of (sample) streamers live right now
|
Returns a list of (sample) streamers live right now
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# top 25, if not logged in
|
||||||
|
# if logged in, show streams that match user's tags
|
||||||
|
# user attains tags from the tags of the streamers they follow, and streamers they've watched
|
||||||
|
|
||||||
streamers = [
|
streamers = [
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
|
|||||||
27
web_server/backend/blueprints/templates/video.html
Normal file
27
web_server/backend/blueprints/templates/video.html
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
|
||||||
|
<video id="video" controls></video>
|
||||||
|
<script>
|
||||||
|
if(Hls.isSupported())
|
||||||
|
{
|
||||||
|
var video = document.getElementById('video');
|
||||||
|
var hls = new Hls();
|
||||||
|
hls.loadSource('{{ video_url }}');
|
||||||
|
hls.attachMedia(video);
|
||||||
|
hls.on(Hls.Events.MANIFEST_PARSED,function()
|
||||||
|
{
|
||||||
|
video.play();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (video.canPlayType('application/vnd.apple.mpegurl'))
|
||||||
|
{
|
||||||
|
video.src = ' {{ video_url }}';
|
||||||
|
video.addEventListener('canplay',function()
|
||||||
|
{
|
||||||
|
video.play();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user