added some simple transitions in audio player

This commit is contained in:
suroh 2023-10-06 17:20:53 +02:00
parent 2b7dcc246d
commit 476139bc3f
7 changed files with 64 additions and 2112 deletions

2079
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -23,3 +23,9 @@ body {
--box-shadow: 0 0 6px 2px #00000010; --box-shadow: 0 0 6px 2px #00000010;
} }
@media screen and (min-width: 1280px) {
body {
font-size: 32px;
}
}

View File

@ -1,6 +1,6 @@
import { LitElement, css, html, unsafeCSS } from 'lit' import { LitElement, css, html, unsafeCSS } from 'lit'
import MainCSS from '../assets/styles/main.scss' import MainCSS from '../assets/styles/main.scss?inline'
import './SvgIcon.js' import './SvgIcon.js'

View File

@ -2,7 +2,6 @@ import { LitElement, html, css,unsafeCSS } from 'lit'
import { Task } from '@lit-labs/task' import { Task } from '@lit-labs/task'
import { formatSeconds } from '../api/utils' import { formatSeconds } from '../api/utils'
import Photo from '/images/Meredith Monk (1974) Photo Lauretta Harris.jpg'
import MainCSS from '../assets/styles/main.scss?inline' import MainCSS from '../assets/styles/main.scss?inline'
import './RangeSlider.js' import './RangeSlider.js'
@ -203,7 +202,7 @@ ${ this.details ?
</ul> </ul>
</div> </div>
</div> </div>
` : html`<img class="bg-img" src=${Photo} />`} ` : html``}
<header> <header>
<h2>${this.details.tracks ? this.details?.tracks[this.track] : this.details.title}</h2> <h2>${this.details.tracks ? this.details?.tracks[this.track] : this.details.title}</h2>
@ -231,7 +230,7 @@ ${ this.details ?
@input=${this.seekTrack} @input=${this.seekTrack}
class="progress" class="progress"
></mm-range> ></mm-range>
<img class="wav-img" src="/media${this.details.media}.png"> <img class="wav-img" loading="eager" src="/media${this.details.media}.png">
</div> </div>
` `
} }
@ -306,18 +305,6 @@ ${ this.details ?
} }
} }
.bg-img {
position: absolute;
inset: 0;
object-fit: cover;
object-position: center 25%;
opacity: 0.2;
mix-blend-mode: overlay;
scale: 1.1;
width: 100%;
height: 100%;
}
header { header {
color: var(--netural-100, white); color: var(--netural-100, white);
font-size: 1.5em; font-size: 1.5em;

View File

@ -46,10 +46,12 @@ class VideoPlayer extends LitElement {
willUpdate(att) { willUpdate(att) {
if (att.has('media')) { if (att.has('media')) {
console.log(this.media)
this.videoEl.src = this.media this.videoEl.src = this.media
if (this.autoplay) { if (this.autoplay) {
this.togglePlay() this.playing = true
this.videoEl.play()
this.interact() this.interact()
} }
} }

View File

@ -1,7 +1,7 @@
import { LitElement, css, html, unsafeCSS } from 'lit' import { LitElement, css, html } from 'lit'
import { Task } from '@lit-labs/task' import { Task } from '@lit-labs/task'
import MainCSS from '../assets/styles/main.scss?inline' import Photo from '/images/Meredith Monk (1974) Photo Lauretta Harris.jpg'
// components // components
import '../components/Header.js' import '../components/Header.js'
@ -26,7 +26,14 @@ class AudioView extends LitElement {
firstUpdated() { firstUpdated() {
this.addEventListener('select-audio', ({ detail }) => { this.addEventListener('select-audio', ({ detail }) => {
this.selected = { ...detail, media: `${Router.route.path}/${detail.media}` } const div = this.shadowRoot.querySelector('mm-audio-player')
div.addEventListener('transitionend', () => {
this.selected = { ...detail, media: `${Router.route.path}/${detail.media}` }
div.classList.remove('unloading')
})
div.classList.add('unloading')
}) })
this.addEventListener('next-track', () => { this.addEventListener('next-track', () => {
@ -53,10 +60,10 @@ class AudioView extends LitElement {
) )
_skipTrack(direction) { _skipTrack(direction) {
const idx = (this.selected.idx + direction) % this.tracks.length const idx = (this.selected.idx + direction) % this.tracks.length
const detail = { ...this.tracks[idx], idx } const detail = { ...this.tracks[idx], idx }
this.selected = { ...detail, media: `${Router.route.path}/${detail.media}` } this.selected = { ...detail, media: `${Router.route.path}/${detail.media}` }
} }
render() { render() {
@ -68,7 +75,13 @@ class AudioView extends LitElement {
<div class="scroll-items"> <div class="scroll-items">
${this._getAudio.render({ ${this._getAudio.render({
pending: () => html`<mm-loading style="--fill-color: grey"></mm-loading>`, pending: () => html`<mm-loading style="--fill-color: grey"></mm-loading>`,
complete: () => html`${this.tracks.map((t, i) => html`<mm-acard idx=${i} icon=${t.album ? 'album' : 'play-circle'} ?selected=${t.title == this.selected.title && t.details == this.selected.details} .details=${t}></mm-acard>`)}`, complete: () => html`${this.tracks.map((t, i) => html`
<mm-acard
idx=${i}
icon=${t.album ? 'album' : 'play-circle'}
?selected=${t.title == this.selected.title && t.details == this.selected.details}
.details=${t}
></mm-acard>`)}`,
error: (err) => html`Error: ${err}` error: (err) => html`Error: ${err}`
})} })}
</div> </div>
@ -76,6 +89,7 @@ class AudioView extends LitElement {
<div class="player"> <div class="player">
<div> <div>
${this.selected.tracks ? '' : html`<img class="bg-img" src=${Photo} />` }
<mm-audio-player .details=${this.selected}></mm-audio-player> <mm-audio-player .details=${this.selected}></mm-audio-player>
</div> </div>
</div> </div>
@ -85,7 +99,7 @@ class AudioView extends LitElement {
` `
} }
static styles = [ css`${unsafeCSS(MainCSS)}`, css` static styles = css`
:host { :host {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -125,20 +139,42 @@ class AudioView extends LitElement {
.player { .player {
position: relative; position: relative;
> div {
position: absolute;
inset: 0;
border-radius: 0.75em 0 0 0.75em;
background: var(--green-gradient-400, lightgrey);
margin-block-end: 1em;
overflow: hidden;
.bg-img {
position: absolute;
inset: 0;
object-fit: cover;
object-position: center 25%;
opacity: 0.2;
scale: 1.1;
width: 100%;
height: 100%;
}
}
} }
.player > div {
position: absolute; mm-audio-player {
inset: 0; transition: opacity 0.125s 0.125s ease-in-out;
border-radius: 0.75em 0 0 0.75em; }
background: var(--green-gradient-400, lightgrey);
margin-block-end: 1em; .unloading {
opacity: 0;
transition: opacity 0.125s ease-in-out;
} }
mm-footer { mm-footer {
z-index: 1; z-index: 1;
} }
` ] `
} }

View File

@ -2,7 +2,7 @@ import { LitElement, css, html, unsafeCSS } from 'lit'
import { Task } from '@lit-labs/task' import { Task } from '@lit-labs/task'
import Router from '../api/Router.js' import Router from '../api/Router.js'
import MainCSS from '../assets/styles/main.scss' import MainCSS from '../assets/styles/main.scss?inline'
import '../components/Header.js' import '../components/Header.js'
import '../components/Footer.js' import '../components/Footer.js'