// types/video.d.ts

/**
 * 视频信息
 */
export interface IVideoInfo {
  id: number
  chapterId: number
  type: 0 | 1 | 2 // 0: MP4, 1: M3U8, 2: 音频
  video: string // 视频ID
  sort: number
  duration: number // 视频时长（秒）
  createTime: string
  delFlag: number
  playAuth?: string // 阿里云播放授权
  videoUrl?: string // 视频URL（兼容字段）
  m3u8Url?: string // M3U8流地址
  mp4Url?: string // MP4视频地址
  mtsHlsUriToken?: string // M3U8 Token
  userCourseVideoPositionEntity?: IVideoPosition
}

/**
 * 视频播放位置
 */
export interface IVideoPosition {
  id: number
  userId: number
  videoId: number
  position: number // 播放位置（秒）
  createTime: string
  updateTime: string
  delFlag: number
}

/**
 * 视频检查接口响应
 */
export interface IVideoCheckResponse {
  msg: string
  code: number
  video: IVideoInfo
}

/**
 * 视频播放器组件 Props
 */
export interface IVideoPlayerProps {
  videoList: Array<IVideoInfo>
  currentIndex: number
  countdownSeconds?: number
  showWatermark?: boolean
  watermarkText?: string
}

/**
 * 视频播放器组件状态
 */
export interface IVideoPlayerState {
  currentVideoData: IVideoInfo | null
  currentTime: number
  firstTime: number
  isSetFirstTime: boolean
  isFullScreen: boolean
  showCountdown: boolean
  countdownRemaining: number
  showError: boolean
  errorMessage: string
  isLoading: boolean
  isChanging: boolean
  playbackRate: number
  volume: number
}

/**
 * 视频错误类型
 */
export enum VideoErrorType {
  NETWORK_ERROR = 'NETWORK_ERROR',
  VIDEO_LOAD_ERROR = 'VIDEO_LOAD_ERROR',
  ENCRYPTION_ERROR = 'ENCRYPTION_ERROR',
  PLATFORM_NOT_SUPPORTED = 'PLATFORM_NOT_SUPPORTED',
  INVALID_PARAMS = 'INVALID_PARAMS',
  API_ERROR = 'API_ERROR'
}
