Spaces:
Paused
Paused
Commit
·
5e22091
1
Parent(s):
6c29d73
fix
Browse files- templates/film_player.html +30 -15
templates/film_player.html
CHANGED
@@ -49,26 +49,41 @@
|
|
49 |
<script>
|
50 |
document.addEventListener("DOMContentLoaded", function() {
|
51 |
const queryParams = new URLSearchParams(window.location.search);
|
52 |
-
const
|
53 |
|
54 |
-
if (!
|
55 |
-
document.getElementById('error').innerText = 'No
|
56 |
return;
|
57 |
}
|
58 |
|
59 |
-
//
|
60 |
-
|
61 |
-
// .then(response => response.json())
|
62 |
-
// .then(data => {
|
63 |
-
// if (data.title) {
|
64 |
-
// document.getElementById('filmTitle').innerText = data.title;
|
65 |
-
// }
|
66 |
-
// });
|
67 |
|
68 |
-
//
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
});
|
73 |
</script>
|
74 |
</body>
|
|
|
49 |
<script>
|
50 |
document.addEventListener("DOMContentLoaded", function() {
|
51 |
const queryParams = new URLSearchParams(window.location.search);
|
52 |
+
const filmTitle = queryParams.get('title');
|
53 |
|
54 |
+
if (!filmTitle) {
|
55 |
+
document.getElementById('error').innerText = 'No film title provided.';
|
56 |
return;
|
57 |
}
|
58 |
|
59 |
+
// Display the film title
|
60 |
+
document.getElementById('filmTitle').innerText = decodeURIComponent(filmTitle);
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
+
// Fetch film metadata and stream URL
|
63 |
+
fetch(`/api/film/${encodeURIComponent(filmTitle)}`)
|
64 |
+
.then(response => response.json())
|
65 |
+
.then(data => {
|
66 |
+
if (data.file_path) {
|
67 |
+
return fetch(`/api/stream?path=${encodeURIComponent(data.file_path)}`);
|
68 |
+
} else {
|
69 |
+
throw new Error('File path not found.');
|
70 |
+
}
|
71 |
+
})
|
72 |
+
.then(response => response.json())
|
73 |
+
.then(data => {
|
74 |
+
if (data.stream_id) {
|
75 |
+
// Update video source with the stream URL
|
76 |
+
const videoSource = document.getElementById('videoSource');
|
77 |
+
videoSource.src = `/stream/${data.stream_id}`;
|
78 |
+
console.log("streamID : "+data.stream_id)
|
79 |
+
document.getElementById('videoPlayer').load();
|
80 |
+
} else {
|
81 |
+
throw new Error('Stream ID not found.');
|
82 |
+
}
|
83 |
+
})
|
84 |
+
.catch(error => {
|
85 |
+
document.getElementById('error').innerText = `Error: ${error.message}`;
|
86 |
+
});
|
87 |
});
|
88 |
</script>
|
89 |
</body>
|