@geekapps/silo-elements-nextjs 0.3.19 → 0.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,6 +55,68 @@ function deviceSupportsAudioCodec(codec) {
55
55
  return true;
56
56
  }
57
57
  }
58
+ var LANG_NAMES = {
59
+ pt: "Portugu\xEAs",
60
+ "pt-br": "Portugu\xEAs (Brasil)",
61
+ "pt-pt": "Portugu\xEAs (Portugal)",
62
+ en: "English",
63
+ "en-us": "English (US)",
64
+ "en-gb": "English (UK)",
65
+ es: "Espa\xF1ol",
66
+ "es-419": "Espa\xF1ol (Latino)",
67
+ fr: "Fran\xE7ais",
68
+ de: "Deutsch",
69
+ it: "Italiano",
70
+ ja: "\u65E5\u672C\u8A9E",
71
+ ko: "\uD55C\uAD6D\uC5B4",
72
+ zh: "\u4E2D\u6587",
73
+ "zh-cn": "\u666E\u901A\u8BDD",
74
+ "zh-tw": "\u7E41\u9AD4\u4E2D\u6587",
75
+ ru: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
76
+ ar: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629",
77
+ hi: "\u0939\u093F\u0928\u094D\u0926\u0940",
78
+ nl: "Nederlands",
79
+ pl: "Polski",
80
+ sv: "Svenska",
81
+ tr: "T\xFCrk\xE7e",
82
+ und: "Original"
83
+ };
84
+ var CODEC_LABELS = {
85
+ "truehd": "Dolby TrueHD",
86
+ "atmos": "Dolby Atmos",
87
+ "eac3": "Dolby Digital Plus",
88
+ "ec-3": "Dolby Digital Plus",
89
+ "e-ac-3": "Dolby Digital Plus",
90
+ "ac3": "Dolby Digital",
91
+ "ac-3": "Dolby Digital",
92
+ "dts-hd": "DTS-HD",
93
+ "dts-hd ma": "DTS-HD MA",
94
+ "dtshd": "DTS-HD MA",
95
+ "dts": "DTS",
96
+ "aac": "AAC",
97
+ "opus": "Opus",
98
+ "mp3": "MP3",
99
+ "flac": "FLAC",
100
+ "alac": "ALAC"
101
+ };
102
+ var CHANNEL_LABELS = {
103
+ 1: "Mono",
104
+ 2: "Est\xE9reo",
105
+ 6: "5.1",
106
+ 7: "6.1",
107
+ 8: "7.1"
108
+ };
109
+ function friendlyAudioLabel(rawName, lang, codec, channels) {
110
+ const langKey = (lang ?? "").toLowerCase();
111
+ const langLabel = LANG_NAMES[langKey] ?? (lang ? lang.toUpperCase() : null);
112
+ const codecKey = Object.keys(CODEC_LABELS).find((k) => codec.toLowerCase().includes(k));
113
+ const codecLabel = codecKey ? CODEC_LABELS[codecKey] : null;
114
+ const chLabel = channels ? CHANNEL_LABELS[channels] ?? `${channels}ch` : null;
115
+ const looksHuman = rawName && !/^(und|dts|ac3|eac3|aac|opus|truehd|atmos|\w{2,3}-\d+ch|\w{2})/i.test(rawName) && rawName.length > 1;
116
+ const baseName = looksHuman ? rawName : langLabel ?? "\xC1udio";
117
+ const suffix = [codecLabel, chLabel].filter(Boolean).join(" ");
118
+ return suffix ? `${baseName} \u2014 ${suffix}` : baseName;
119
+ }
58
120
  function isHdrLevel(level) {
59
121
  const range = level?.videoRange ?? level?.video_range ?? "";
60
122
  return range === "PQ" || range === "HLG" || range === "HDR10" || typeof level?.name === "string" && /hdr/i.test(level.name);
@@ -862,7 +924,8 @@ function Video({
862
924
  tracks.map((t, i) => {
863
925
  const codec = (t.attrs?.CODECS ?? t.codecSet ?? "").split(",")[0]?.trim() ?? "";
864
926
  const supported = deviceSupportsAudioCodec(codec);
865
- return { id: i, label: t.name ?? t.lang ?? `Track ${i + 1}`, supported };
927
+ const label = friendlyAudioLabel(t.name, t.lang, codec, t.channels ?? t.attrs?.CHANNELS);
928
+ return { id: i, label, supported };
866
929
  })
867
930
  );
868
931
  if (pinnedAudio === -1) setSelectedAudio(hls.audioTrack ?? 0);
@@ -879,7 +942,8 @@ function Video({
879
942
  tracks.map((t, i) => {
880
943
  const codec = (t.attrs?.CODECS ?? t.codecSet ?? "").split(",")[0]?.trim() ?? "";
881
944
  const supported = deviceSupportsAudioCodec(codec);
882
- return { id: i, label: t.name ?? t.lang ?? `Track ${i + 1}`, supported };
945
+ const label = friendlyAudioLabel(t.name, t.lang, codec, t.channels ?? t.attrs?.CHANNELS);
946
+ return { id: i, label, supported };
883
947
  })
884
948
  );
885
949
  }