Skip to content

Commit

Permalink
Added HQ support for HLS & Improve codec handling
Browse files Browse the repository at this point in the history
  • Loading branch information
n-ce committed Jul 13, 2024
1 parent 4724d54 commit e7b4622
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ export default function Settings() {
quickSwitch();

}}
onMount={(target) => {
onMount={async (target) => {
const codecSaved = getSaved('codec');
target.selectedIndex = codecSaved ?
parseInt(codecSaved) :
(store.player.supportsOpus ? 0 : 1)
((await store.player.supportsOpus) ? 0 : 1)

store.player.codec = target.value as 'any';
}}
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/superModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ atpSelector.addEventListener('change', () => {
});


downloadBtn.addEventListener('click', () => {
downloadBtn.addEventListener('click', async () => {
superModal.click();
const provider = 'https://api.cobalt.tools/api/json';
const streamUrl = 'https://youtu.be/' + superModal.dataset.id;
Expand All @@ -65,7 +65,7 @@ downloadBtn.addEventListener('click', () => {
body: JSON.stringify({
url: streamUrl,
isAudioOnly: true,
aFormat: store.player.supportsOpus ? 'opus' : 'mp3',
aFormat: (await store.player.supportsOpus) ? 'opus' : 'mp3',
filenamePattern: 'basic'
})
})
Expand Down
4 changes: 2 additions & 2 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const store: {
HLS: boolean,
hq: boolean,
codec: 'opus' | 'aac' | 'any'
supportsOpus: boolean
supportsOpus: Promise<boolean>
},
stream: Record<'id' | 'title' | 'author' | 'duration' | 'channelUrl', string>,
theme: {
Expand All @@ -30,7 +30,7 @@ export const store: {
HLS: Boolean(getSaved('HLS')),
hq: Boolean(getSaved('hq')),
codec: 'opus',
supportsOpus: await navigator.mediaCapabilities.decodingInfo({
supportsOpus: navigator.mediaCapabilities.decodingInfo({
type: 'file',
audio: {
contentType: 'audio/ogg;codecs=opus'
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"compilerOptions": {
"target": "ES2022",
"target": "ES2020",
"useDefineForClassFields": false,
"module": "ESNext",
"lib": [
"ES2022",
"ES2021",
"DOM",
"DOM.Iterable"
],
Expand Down

0 comments on commit e7b4622

Please sign in to comment.