using Plyr.js for mp4 and Video.js for hls
This commit is contained in:
parent
0c450ff019
commit
0b1f549354
|
@ -24,7 +24,7 @@ export default async function VideoPage({ params }: { params: { platform: Platfo
|
|||
|
||||
const [data, related] = await new VideoAgent(platform).getVideo(decodedId)
|
||||
|
||||
if (!data.lowResUrl && (!data.srcSet || data.srcSet.length == 0)) {
|
||||
if (!data.hlsUrl && (!data.srcSet || data.srcSet.length == 0)) {
|
||||
redirect(`/${locale}/404`)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ const VideoJS: React.FC<Props> = (props) => {
|
|||
|
||||
const { data } = props;
|
||||
|
||||
const videoSrc = data.hlsUrl ?? data.lowResUrl
|
||||
const videoType = data.hlsUrl ? 'application/x-mpegURL' : 'video/mp4'
|
||||
const videoSrc = data.hlsUrl
|
||||
const videoType = 'application/x-mpegURL'
|
||||
|
||||
const playerRef = React.useRef(null);
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import Results from '@/components/Layout/Results';
|
|||
import { GalleryData, VideoData } from '@/meta/data';
|
||||
import { Platforms } from '@/meta/settings';
|
||||
import Disclaimer from '@/components/Layout/Header/Disclaimer';
|
||||
import { platform } from 'os';
|
||||
|
||||
|
||||
interface Props {
|
||||
|
@ -29,7 +28,7 @@ const Video: React.FC<Props> = (props) => {
|
|||
<>
|
||||
<Header />
|
||||
<Disclaimer platform={platform} />
|
||||
{data.srcSet ? <PlyrJS data={data} /> : <VideoJS data={data} />}
|
||||
{data.hlsUrl ? <VideoJS data={data} /> : <PlyrJS data={data} />}
|
||||
<SearchBar />
|
||||
{related && <Results data={related} />}
|
||||
</>
|
||||
|
|
|
@ -19,8 +19,6 @@ export interface VideoSourceItem {
|
|||
}
|
||||
|
||||
export interface VideoData {
|
||||
lowResUrl?: string,
|
||||
hiResUrl?: string,
|
||||
hlsUrl?: string
|
||||
srcSet?: VideoSourceItem[]
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import { getPornHubMediaUrlList, getPornHubRelatedVideoData } from "./url";
|
|||
export const fetchPornHubVideoData = async (videoId: string, params?: FetchParams): Promise<[VideoData, GalleryData[]]> => {
|
||||
|
||||
let data: VideoData = {
|
||||
lowResUrl: '',
|
||||
hlsUrl: '',
|
||||
srcSet: []
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ import { getDataFromRedis, storeDataIntoRedis } from '@/redis/client';
|
|||
export const fetchXNXXVideoData = async (videoId: string, params?: FetchParams): Promise<[VideoData, GalleryData[]]> => {
|
||||
|
||||
let data: VideoData = {
|
||||
lowResUrl: ''
|
||||
hlsUrl: '',
|
||||
srcSet: []
|
||||
}
|
||||
|
||||
let related: GalleryData[] = [];
|
||||
|
@ -50,11 +51,19 @@ export const fetchXNXXVideoData = async (videoId: string, params?: FetchParams):
|
|||
const hlsUrl = findVideoUrlInsideTagStringByFunctionNameAndExtension($(elem).toString(), 'setVideoHLS', '.m3u8')
|
||||
|
||||
if (lowResUrl) {
|
||||
data.lowResUrl = lowResUrl;
|
||||
data.srcSet?.push({
|
||||
src: lowResUrl,
|
||||
type: 'video/mp4',
|
||||
size: "480"
|
||||
})
|
||||
}
|
||||
|
||||
if (hiResUrl) {
|
||||
data.hiResUrl = hiResUrl
|
||||
data.srcSet?.push({
|
||||
src: hiResUrl,
|
||||
type: 'video/mp4',
|
||||
size: "720"
|
||||
})
|
||||
}
|
||||
|
||||
if (hlsUrl) {
|
||||
|
|
|
@ -14,7 +14,8 @@ import { DEFAULT_RELATED_VIDEO_KEY_PATH, DEFAULT_XVIDEOS_CONTENT_EXPIRY } from '
|
|||
export const fetchXvideosVideoData = async (videoId: string, params?: FetchParams): Promise<[VideoData, GalleryData[]]> => {
|
||||
|
||||
let data: VideoData = {
|
||||
lowResUrl: ''
|
||||
hlsUrl: '',
|
||||
srcSet: []
|
||||
}
|
||||
|
||||
let related: GalleryData[] = [];
|
||||
|
@ -50,11 +51,19 @@ export const fetchXvideosVideoData = async (videoId: string, params?: FetchParam
|
|||
const hlsUrl = findVideoUrlInsideTagStringByFunctionNameAndExtension($(elem).toString(), 'setVideoHLS', '.m3u8')
|
||||
|
||||
if (lowResUrl) {
|
||||
data.lowResUrl = lowResUrl;
|
||||
data.srcSet?.push({
|
||||
src: lowResUrl,
|
||||
type: 'video/mp4',
|
||||
size: "480"
|
||||
})
|
||||
}
|
||||
|
||||
if (hiResUrl) {
|
||||
data.hiResUrl = hiResUrl
|
||||
data.srcSet?.push({
|
||||
src: hiResUrl,
|
||||
type: 'video/mp4',
|
||||
size: "720"
|
||||
})
|
||||
}
|
||||
|
||||
if (hlsUrl) {
|
||||
|
|
Loading…
Reference in New Issue