Add YouTube support

This commit is contained in:
Korbs 2024-11-29 17:45:45 -05:00
parent 57eb7f9246
commit c1602e7087
2 changed files with 22 additions and 4 deletions

View file

@ -15,7 +15,7 @@
"live-streaming"
],
"type": "module",
"version": "0.4.63",
"version": "0.4.65",
"exports": {
".": "./index.ts"
},
@ -30,7 +30,7 @@
"astro": "^4.14.2"
},
"scripts": {
"npm:publish": "npm publish --registry https://npm.sudovanilla.org/",
"publish": "npm publish && npm publish --registry https://npm.sudovanilla.org/",
"test": "cd test/ && bun start"
}
}

View file

@ -11,6 +11,11 @@ const {
VideoAttributes,
AudioAttributes,
YouTube = false,
YouTubeQuality = '137',
Invidious,
WatchId,
Milieu,
MilieuMode = "Default",
MilieuSpeed = "2000",
@ -29,14 +34,27 @@ import Controller from './Controls/Controller.astro'
import Seek from './Controls/Seek.astro'
import Sync from './Controls/Sync.astro'
// YouTube
if (YouTube === true) {
// 8K = 272
// 4K = 315
// 1080p = 137
// 720p = 302
// Dash Audio = 251
var YTVideo = 'https://' + Invidious +'/latest_version?id=' + WatchId + '&itag=' + YouTubeQuality
var YTAudio = 'https://' + Invidious +'/latest_version?id=' + WatchId + '&itag=251'
} else if (YouTube === false) {
null
}
// Icons and Styles
import './Styles/Index.scss'
import './Styles/Iconoir.css'
---
<div class="video-container" id={"zorn-player-" + PlayerName}>
<video class="main-video" {VideoAttributes} disableremoteplayback src={Video} poster={Poster} preload="auto"></video>
{Audio ? <audio class="main-audio"><source {AudioAttributes} src={Audio} type="audio/mp3"/></audio> : null }
<video class="main-video" {VideoAttributes} disableremoteplayback src={YouTube ? YTVideo : Video} poster={Poster} preload="auto"></video>
{Audio ? <audio class="main-audio"><source {AudioAttributes} src={YouTube ? YTAudio : Audio} type="audio/mp3"/></audio> : null }
{Audio ? <Sync PlayerName={PlayerName}/> : null }
{Milieu ?
<MilieuEffect