- Integrated HLS.js version 1.6.15 into the project for improved video streaming capabilities. - Updated the ContentsController to check for HLS manifest availability and fall back to presigned URLs for original files if not found. - Enhanced the VideoPlayer component to handle loading and error states more effectively, improving user experience during streaming. - Refactored content service methods to return detailed streaming information, including HLS and DASH manifest URLs.
117 lines
3.0 KiB
TypeScript
117 lines
3.0 KiB
TypeScript
import { apiService } from './api.service'
|
|
import type { ApiProject, ApiContent } from '../types/api'
|
|
|
|
/**
|
|
* Content Service
|
|
* Handles projects and content data
|
|
*/
|
|
class ContentService {
|
|
/**
|
|
* Get all published projects with optional filters
|
|
*/
|
|
async getProjects(filters?: {
|
|
type?: 'film' | 'episodic' | 'music-video'
|
|
status?: string
|
|
genre?: string
|
|
limit?: number
|
|
page?: number
|
|
}): Promise<ApiProject[]> {
|
|
const params = new URLSearchParams()
|
|
|
|
if (filters?.type) params.append('type', filters.type)
|
|
if (filters?.status) params.append('status', filters.status)
|
|
if (filters?.genre) params.append('genre', filters.genre)
|
|
if (filters?.limit) params.append('limit', filters.limit.toString())
|
|
if (filters?.page) params.append('page', filters.page.toString())
|
|
|
|
const url = `/projects${params.toString() ? `?${params.toString()}` : ''}`
|
|
return apiService.get<ApiProject[]>(url)
|
|
}
|
|
|
|
/**
|
|
* Get project by ID
|
|
*/
|
|
async getProjectById(id: string): Promise<ApiProject> {
|
|
return apiService.get<ApiProject>(`/projects/${id}`)
|
|
}
|
|
|
|
/**
|
|
* Get project by slug
|
|
*/
|
|
async getProjectBySlug(slug: string): Promise<ApiProject> {
|
|
return apiService.get<ApiProject>(`/projects/slug/${slug}`)
|
|
}
|
|
|
|
/**
|
|
* Get content by ID
|
|
*/
|
|
async getContentById(id: string): Promise<ApiContent> {
|
|
return apiService.get<ApiContent>(`/contents/${id}`)
|
|
}
|
|
|
|
/**
|
|
* Get all contents for a project
|
|
*/
|
|
async getContentsByProject(projectId: string): Promise<ApiContent[]> {
|
|
return apiService.get<ApiContent[]>(`/contents/project/${projectId}`)
|
|
}
|
|
|
|
/**
|
|
* Get streaming URLs for content (requires subscription or rental).
|
|
* Returns the HLS / DASH / FairPlay manifest URLs from the backend.
|
|
*/
|
|
async getStreamInfo(contentId: string): Promise<{
|
|
file: string
|
|
widevine: string
|
|
fairplay: string
|
|
}> {
|
|
return apiService.get(`/contents/${contentId}/stream`)
|
|
}
|
|
|
|
/**
|
|
* Search projects
|
|
*/
|
|
async searchProjects(query: string, filters?: {
|
|
type?: string
|
|
genre?: string
|
|
}): Promise<ApiProject[]> {
|
|
const params = new URLSearchParams()
|
|
params.append('q', query)
|
|
|
|
if (filters?.type) params.append('type', filters.type)
|
|
if (filters?.genre) params.append('genre', filters.genre)
|
|
|
|
return apiService.get<ApiProject[]>(`/projects/search?${params.toString()}`)
|
|
}
|
|
|
|
/**
|
|
* Get featured content (top-rated, recent releases)
|
|
*/
|
|
async getFeaturedContent(): Promise<ApiProject[]> {
|
|
return apiService.get<ApiProject[]>('/projects?status=published&featured=true')
|
|
}
|
|
|
|
/**
|
|
* Get genres
|
|
*/
|
|
async getGenres(): Promise<Array<{ id: string; name: string; slug: string }>> {
|
|
return apiService.get('/genres')
|
|
}
|
|
|
|
/**
|
|
* Get festivals
|
|
*/
|
|
async getFestivals(): Promise<Array<{ id: string; name: string; slug: string }>> {
|
|
return apiService.get('/festivals')
|
|
}
|
|
|
|
/**
|
|
* Get awards
|
|
*/
|
|
async getAwards(): Promise<Array<{ id: string; name: string; slug: string }>> {
|
|
return apiService.get('/awards')
|
|
}
|
|
}
|
|
|
|
export const contentService = new ContentService()
|