-
Notifications
You must be signed in to change notification settings - Fork 156
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
3 changed files
with
162 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Enhancement: Audio metadata panel | ||
|
||
We've added a right sidebar panel with the name `Audio Info`, which display `audio` metadata if present on the given resource. | ||
It is registered by the files app and becomes visible in the global right sidebar in all file contexts, e.g. file listing | ||
with single select on an audio file with indexed id3 information or when listening to an audio file in the preview app. | ||
|
||
https://github.com/owncloud/web/pull/10956 |
133 changes: 133 additions & 0 deletions
133
packages/web-app-files/src/components/SideBar/Audio/AudioMetaPanel.vue
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,133 @@ | ||
<template> | ||
<div id="files-sidebar-panel-audio"> | ||
<dl class="audio-data-list"> | ||
<template v-if="title"> | ||
<dt v-text="$gettext('Title')" /> | ||
<dd v-text="title" /> | ||
</template> | ||
<template v-if="duration"> | ||
<dt v-text="$gettext('Duration')" /> | ||
<dd v-text="duration" /> | ||
</template> | ||
<template v-if="artist"> | ||
<dt v-text="$gettext('Authors')" /> | ||
<dd v-text="artist" /> | ||
</template> | ||
<template v-if="album"> | ||
<dt v-text="$gettext('Album')" /> | ||
<dd v-text="album" /> | ||
</template> | ||
<template v-if="genre"> | ||
<dt v-text="$gettext('Musical genre')" /> | ||
<dd v-text="genre" /> | ||
</template> | ||
<template v-if="year"> | ||
<dt v-text="$gettext('Year recorded')" /> | ||
<dd v-text="year" /> | ||
</template> | ||
<template v-if="track"> | ||
<dt v-text="$gettext('Track')" /> | ||
<dd v-text="track" /> | ||
</template> | ||
<template v-if="disc"> | ||
<dt v-text="$gettext('Disc')" /> | ||
<dd v-text="disc" /> | ||
</template> | ||
</dl> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { computed, defineComponent, inject, Ref, unref } from 'vue' | ||
import { Resource } from '@ownclouders/web-client' | ||
import { Duration } from 'luxon' | ||
export default defineComponent({ | ||
name: 'AudioMetaPanel', | ||
setup() { | ||
const resource = inject<Ref<Resource>>('resource') | ||
const album = computed(() => { | ||
return unref(resource).audio.album | ||
}) | ||
const artist = computed(() => { | ||
return unref(resource).audio.artist | ||
}) | ||
const albumArtist = computed(() => { | ||
return unref(resource).audio.albumArtist | ||
}) | ||
const genre = computed(() => { | ||
return unref(resource).audio.genre | ||
}) | ||
const title = computed(() => { | ||
return unref(resource).audio.title | ||
}) | ||
const duration = computed(() => { | ||
const milliseconds = unref(resource).audio.duration | ||
if (milliseconds) { | ||
const d = Duration.fromMillis(milliseconds) | ||
if (d.hours > 0) { | ||
return d.toFormat('hh:mm:ss') | ||
} | ||
return d.toFormat('mm:ss') | ||
} | ||
return '' | ||
}) | ||
const track = computed(() => { | ||
const audio = unref(resource).audio | ||
if (audio.track && audio.trackCount) { | ||
return `${audio.track} / ${audio.trackCount}` | ||
} | ||
return audio.track | ||
}) | ||
const disc = computed(() => { | ||
const audio = unref(resource).audio | ||
if (audio.disc && audio.discCount) { | ||
return `${audio.disc} / ${audio.discCount}` | ||
} | ||
return audio.disc | ||
}) | ||
const year = computed(() => { | ||
return unref(resource).audio?.year | ||
}) | ||
return { | ||
album, | ||
artist, | ||
albumArtist, | ||
genre, | ||
title, | ||
duration, | ||
track, | ||
disc, | ||
year | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<style lang="scss"> | ||
.audio-data-list { | ||
display: grid; | ||
grid-template-columns: auto minmax(0, 1fr); | ||
dt, | ||
dd { | ||
margin-bottom: var(--oc-space-small); | ||
} | ||
dt { | ||
font-weight: bold; | ||
white-space: nowrap; | ||
} | ||
dd { | ||
margin-inline-start: var(--oc-space-medium); | ||
} | ||
} | ||
</style> |
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