File size: 2,744 Bytes
ac7030c
 
 
 
f42b4a1
ac7030c
f42b4a1
ac7030c
 
 
 
3d4392e
ac7030c
 
 
 
 
 
 
 
 
 
 
 
3d4392e
f42b4a1
ac7030c
 
3d4392e
 
 
ac7030c
 
 
 
 
 
 
3d4392e
 
 
 
 
 
 
 
 
 
 
ac7030c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"use client"

import AutoSizer from "react-virtualized-auto-sizer"

import { cn } from "@/lib/utils/cn"
import { MediaInfo } from "@/types/general"
import { parseMediaProjectionType } from "@/lib/utils/parseMediaProjectionType"

import { EquirectangularVideoPlayer } from "./equirectangular"
import { CartesianVideoPlayer } from "./cartesian"
import { GaussianSplattingPlayer } from "./gaussian"
import { LatentPlayer } from "./latent"

export function MediaPlayer({
  media,
  enableShortcuts = true,
  className = "",
  // currentTime,
 }: {
  media?: MediaInfo
  enableShortcuts?: boolean
  className?: string
  // currentTime?: number
}) {
  // console.log("MediaPlayer called for \"" + media?.label + "\"")
  
  if (!media || !media?.assetUrl) { return null }

  // uncomment one of those to forcefully test the .clap player!
 media.assetUrlHd = "https://huggingface.co/datasets/jbilcke/ai-tube-cinema/tree/main/404.clap"

  // uncomment one of those to forcefully test the .splatv player!
  // media.assetUrlHd = "https://huggingface.co/datasets/dylanebert/3dgs/resolve/main/4d/flame/flame.splatv"
  // media.assetUrlHd = "https://huggingface.co/datasets/dylanebert/3dgs/resolve/main/4d/sear/sear.splatv"
  // media.assetUrlHd = "https://huggingface.co/datasets/dylanebert/3dgs/resolve/main/4d/birthday/birthday.splatv"

  const projectionType = parseMediaProjectionType(media)
  
  if (projectionType === "latent") {
    // note: for AutoSizer to work properly it needs to be inside a normal div with no display: "flex"
    return (
      <div className={cn(`w-full aspect-video`, className)}>
        <AutoSizer>{({ height, width }) => (
           <LatentPlayer media={media} className={className} width={width} height={height} />
          )}</AutoSizer>
      </div>
    )
  }

  if (projectionType === "gaussian") {
    // note: for AutoSizer to work properly it needs to be inside a normal div with no display: "flex"
    return (
      <div className={cn(`w-full aspect-video`, className)}>
        <AutoSizer>{({ height, width }) => (
           <GaussianSplattingPlayer media={media} className={className} width={width} height={height} />
          )}</AutoSizer>
      </div>
    )
  }

  if (projectionType === "equirectangular") {
    // note: for AutoSizer to work properly it needs to be inside a normal div with no display: "flex"
    return (
      <div className={cn(`w-full aspect-video`, className)}>
        <AutoSizer>{({ height, width }) => (
           <EquirectangularVideoPlayer media={media} className={className} width={width} height={height} />
          )}</AutoSizer>
      </div>
    )
  }

  return (
    <CartesianVideoPlayer media={media} enableShortcuts={enableShortcuts} className={className} />
  )
}