-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
854 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,32 @@ | ||
import Reverb from '../models/reverb/reverb.js' | ||
import VideoElement from '../models/video/video.js' | ||
|
||
class SpotifyVideo { | ||
#video | ||
#tries = 0 | ||
#originalCreateElement = document.createElement | ||
|
||
constructor() { | ||
this.#overloadCreateElement() | ||
this._video | ||
this._reverb | ||
this._originalCreateElement = document.createElement | ||
this.#init() | ||
} | ||
|
||
#overloadCreateElement() { | ||
#init() { | ||
const self = this | ||
|
||
document.createElement = function (tagName) { | ||
const element = self.#originalCreateElement.apply(this, arguments) | ||
const element = self._originalCreateElement.apply(this, arguments) | ||
|
||
if (tagName === 'video') { | ||
self.#video = new VideoElement(element) | ||
|
||
document.createElement = self.#originalCreateElement | ||
self._reverb = new Reverb(element) | ||
self._video = new VideoElement({ video: element, reverb: self._reverb }) | ||
document.createElement = self._originalCreateElement | ||
} | ||
return element | ||
} | ||
} | ||
|
||
#init = () => { | ||
try { | ||
this.#tries++ | ||
this.#checkForMainEl() | ||
} catch { | ||
if (this.#tries <= 20) { | ||
setTimeout(this.#init, 500) | ||
return | ||
} | ||
} | ||
} | ||
|
||
#checkForMainEl() { | ||
const mainEl = document.getElementById('main') | ||
get element() { return this._video } | ||
|
||
if (mainEl === null) { | ||
throw new Error('Main container element not found') | ||
} | ||
} | ||
|
||
get element() { | ||
return this.#video | ||
} | ||
get reverb() { return this._reverb } | ||
} | ||
|
||
export const spotifyVideo = new SpotifyVideo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { createTextButton } from '../text-button.js' | ||
|
||
export const createEffectsButtons = () => ` | ||
<div style="display:flex;margin-top:12px;justify-content:space-between;height:1.5rem;"> | ||
${createTextButton({ text: 'reset', id: 'effects-reset' })} | ||
${createTextButton({ text: 'save', id: 'effects-save' })} | ||
</div> | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createEffectsButtons } from './effects-button.js' | ||
import { createEffectsSelector } from './effects-selector.js' | ||
import { convolverPresets, drinkPresets } from '../../lib/reverb/presets.js' | ||
|
||
export const createEffectsControls = () => ` | ||
<div id="chorus-fx-controls" style="display: none"> | ||
<div style="display:flex;flex-direction:column;justify-content:space-evenly;height:6rem;"> | ||
${createEffectsSelector({ name: 'drink-effect', labelName: 'cup-sized reverb', optionNames: drinkPresets })} | ||
${createEffectsSelector({ name: 'convolver-effect', labelName: 'impulse reverb', optionNames: convolverPresets })} | ||
<hr/> | ||
<div style="font-size:1rem;color:#b3b3b3;"> | ||
<p style="display:flex;justify-content:space-between;width:100%;padding-right:.125rem;"> | ||
effect <span id="preset-selection" style="color:#fff"></span> | ||
</p> | ||
</div> | ||
</div> | ||
${createEffectsButtons()} | ||
</div> | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const createOptions = optionNames => ( | ||
optionNames.map(name => `<option name="${name}" value="${name}">${name}</option>`).join('') | ||
) | ||
|
||
export const createEffectsSelector = ({ labelName, name, optionNames }) => ` | ||
<div style="display:flex;justify-content:space-between"> | ||
<label style="color:#b3b3b3;font-size:">${labelName}</label> | ||
<form id="select-container" class="selector"> | ||
<select | ||
class="select" | ||
id="${name}-presets" | ||
name="${name}-presets" | ||
style="color:#fff;font-size:1rem;text-align:end" | ||
> | ||
<option name="none" value="none">-----</option> | ||
${createOptions(optionNames)} | ||
</select> | ||
</form> | ||
</div> | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
export const createTextButton = ({ id, text, style }) => ` | ||
<button | ||
id="chorus-${id}-button" | ||
class="chorus-text-button" | ||
style="padding:0 10px;height:100%;font-size:1rem;${style || ''}" | ||
> | ||
<span>${text}</span> | ||
</button> | ||
` | ||
const classNames = { share: 'share', save: 'success', reset: 'danger', remove: 'danger' } | ||
|
||
export const createTextButton = ({ id, text, style }) => { | ||
const btnTypeClass = classNames[id?.split('-')?.at(-1)] | ||
return ` | ||
<button | ||
id="chorus-${id}-button" | ||
class="chorus-text-button ${btnTypeClass ?? ''}" | ||
style="padding:0 10px;height:100%;font-size:1rem;${style || ''}" | ||
> | ||
<span>${text}</span> | ||
</button> | ||
` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export const createTrackInfo = () => ` | ||
<div style="display:flex;flex-direction:column;margin-top:0.5rem;"> | ||
<p id="track-title" style="color:#fff;font-size:14px;"></p> | ||
<p id="track-artists" style="font-size:11px;color:#b3b3b3;"></p> | ||
<div style="display:flex;flex-direction:column;width:100%;justify-content:space-evenly;margin-top:.5rem"> | ||
<div class="container" style="width:282px"><div class="track-text" id="track-title"></div></div> | ||
<div class="container" style="width:282px"><div class="track-text" id="track-artists"></div></div> | ||
</div> | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.