mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-06 07:28:53 -05:00
wtv
This commit is contained in:
parent
32f61cf566
commit
e34bd55e7a
@ -256,7 +256,7 @@ def video_chapters(request, friendly_token):
|
|||||||
return HttpResponseRedirect("/")
|
return HttpResponseRedirect("/")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = json.loads(request.body)["chapters"]
|
data = json.loads(request.body)["segments"]
|
||||||
chapters = []
|
chapters = []
|
||||||
for _, chapter_data in enumerate(data):
|
for _, chapter_data in enumerate(data):
|
||||||
start_time = chapter_data.get('startTime')
|
start_time = chapter_data.get('startTime')
|
||||||
|
|||||||
@ -968,7 +968,7 @@ const TimelineControls = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadSavedSegments = () => {
|
const loadSavedSegments = () => {
|
||||||
// Get savedSegments directly from window.MEDIA_DATA
|
// Get savedSegments directly from window.MEDIA_DATA
|
||||||
let savedData = (typeof window !== 'undefined' && (window as any).MEDIA_DATA?.savedSegments) || null;
|
let savedData = (typeof window !== 'undefined' && (window as any).MEDIA_DATA?.chapters) || null;
|
||||||
|
|
||||||
// If no saved segments, use default segments
|
// If no saved segments, use default segments
|
||||||
if (!savedData) {
|
if (!savedData) {
|
||||||
|
|||||||
@ -94,33 +94,7 @@ const useVideoChapters = () => {
|
|||||||
// Check if we have existing chapters from the backend
|
// Check if we have existing chapters from the backend
|
||||||
const existingChapters =
|
const existingChapters =
|
||||||
(typeof window !== 'undefined' && (window as any).MEDIA_DATA?.chapters) ||
|
(typeof window !== 'undefined' && (window as any).MEDIA_DATA?.chapters) ||
|
||||||
[
|
[];
|
||||||
/* {
|
|
||||||
name: 'Chapter 1',
|
|
||||||
from: '00:00:00',
|
|
||||||
to: '00:00:03',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Chapter 2',
|
|
||||||
from: '00:00:03',
|
|
||||||
to: '00:00:06',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Chapter 3',
|
|
||||||
from: '00:00:09',
|
|
||||||
to: '00:00:12',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Chapter 4',
|
|
||||||
from: '00:00:15',
|
|
||||||
to: '00:00:18',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Chapter 5',
|
|
||||||
from: '00:00:21',
|
|
||||||
to: '00:00:24',
|
|
||||||
}, */
|
|
||||||
];
|
|
||||||
|
|
||||||
if (existingChapters.length > 0) {
|
if (existingChapters.length > 0) {
|
||||||
// Create segments from existing chapters
|
// Create segments from existing chapters
|
||||||
@ -128,8 +102,8 @@ const useVideoChapters = () => {
|
|||||||
const chapter = existingChapters[i];
|
const chapter = existingChapters[i];
|
||||||
|
|
||||||
// Parse time strings to seconds
|
// Parse time strings to seconds
|
||||||
const startTime = parseTimeToSeconds(chapter.from);
|
const startTime = parseTimeToSeconds(chapter.startTime);
|
||||||
const endTime = parseTimeToSeconds(chapter.to);
|
const endTime = parseTimeToSeconds(chapter.endTime);
|
||||||
|
|
||||||
// Generate thumbnail for this segment
|
// Generate thumbnail for this segment
|
||||||
const segmentThumbnail = await generateThumbnail(video, (startTime + endTime) / 2);
|
const segmentThumbnail = await generateThumbnail(video, (startTime + endTime) / 2);
|
||||||
@ -140,7 +114,7 @@ const useVideoChapters = () => {
|
|||||||
startTime: startTime,
|
startTime: startTime,
|
||||||
endTime: endTime,
|
endTime: endTime,
|
||||||
thumbnail: segmentThumbnail,
|
thumbnail: segmentThumbnail,
|
||||||
chapterTitle: chapter.name, // Set the chapter title from backend data
|
chapterTitle: chapter.text,
|
||||||
};
|
};
|
||||||
|
|
||||||
initialSegments.push(segment);
|
initialSegments.push(segment);
|
||||||
@ -768,7 +742,7 @@ const useVideoChapters = () => {
|
|||||||
|
|
||||||
// Convert chapters to backend expected format
|
// Convert chapters to backend expected format
|
||||||
const backendChapters = chapters.map((chapter) => ({
|
const backendChapters = chapters.map((chapter) => ({
|
||||||
startTime: chapter.from,
|
startTime: chapter.from,
|
||||||
endTime: chapter.to,
|
endTime: chapter.to,
|
||||||
text: chapter.name,
|
text: chapter.name,
|
||||||
}));
|
}));
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -16,8 +16,10 @@
|
|||||||
mediaId: "{{ media_object.friendly_token }}",
|
mediaId: "{{ media_object.friendly_token }}",
|
||||||
redirectURL: "{{ media_object.get_absolute_url }}",
|
redirectURL: "{{ media_object.get_absolute_url }}",
|
||||||
redirectUserMediaURL: "{{ media_object.user.get_absolute_url }}",
|
redirectUserMediaURL: "{{ media_object.user.get_absolute_url }}",
|
||||||
chapters: "{{ chapters }}",
|
chapters: {{ chapters|safe }},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log(window.MEDIA_DATA.chapters)
|
||||||
</script>
|
</script>
|
||||||
{%endblock topimports %}
|
{%endblock topimports %}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user