@zezosoft/zezo-ott-react-native-video-player
Version:
React Native OTT Video Player for Android & iOS. Supports playlists, seasons, auto-next playback, subtitles, theming, analytics, fullscreen mode, and custom controls. 🚀 Powered by ZezoSoft.
24 lines (19 loc) • 681 B
text/typescript
import type { MediaTrack } from '../store/videoPlayer.type';
import type { ReactVideoSource } from 'react-native-video';
interface UrlHandlerProps {
playList: MediaTrack[];
currentTrackIndex: number;
}
export const getVideoSource = ({
playList,
currentTrackIndex,
}: UrlHandlerProps): ReactVideoSource => {
const track = playList?.[currentTrackIndex];
if (!track) return { uri: '' };
const uri = track.isTrailer ? track.trailerSource : track.sourceLink;
return { uri: encodeURI(uri?.trim() || '') ?? '' };
};
export const getEpisodeIndex = (
playList: MediaTrack[],
episodeId: string
): number => playList.findIndex((item) => item.episodeId === episodeId);