Skip to content

Commit

Permalink
feat: partial work
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultNocchi committed Jan 31, 2023
1 parent 3eee286 commit 46bcf8a
Show file tree
Hide file tree
Showing 9 changed files with 483 additions and 105 deletions.
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"destr": "1.1.1",
"dompurify": "2.3.8",
"he": "1.2.0",
"hls.js": "1.3.1",
"langs": "2.0.0",
"lodash-es": "4.17.21",
"screenfull": "6.0.1",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<router-view-transition is-root />
<snackbar />
<player-element />
<video-player />
</v-app>
</template>
125 changes: 47 additions & 78 deletions frontend/src/components/Buttons/SubtitleSelectionButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,95 +2,64 @@
<v-menu
v-model="menu"
:close-on-content-click="false"
:persistent="!true"
:transition="'slide-y-transition'"
transition="slide-y-transition"
location="top"
:nudge-top="nudgeTop"
offset-y
min-width="25em"
max-width="25em"
min-height="25em"
max-height="25em"
:z-index="500"
class="menu"
@input="$emit('input', $event)">
<!-- eslint-disable-next-line vue/no-template-shadow -->
<template #activator="{ on: menu, attrs }">
<v-tooltip location="top">
<template #activator="{ on: tooltip }">
<v-btn
class="align-self-center active-button"
icon
:disabled="
!playbackManager.currentItemParsedSubtitleTracks ||
playbackManager.currentItemParsedSubtitleTracks.length === 0
"
v-bind="attrs"
v-on="{ ...tooltip, ...menu }">
<v-icon>
<i-mdi-closed-caption />
</v-icon>
</v-btn>
</template>
<span>{{ $t('subtitles') }}</span>
</v-tooltip>
<template #activator="{ props }">
<v-btn
class="align-self-center active-button"
icon
:disabled="
!playbackManager.currentItemParsedSubtitleTracks ||
playbackManager.currentItemParsedSubtitleTracks.length === 0
"
v-bind="props">
<v-icon>
<i-mdi-closed-caption />
</v-icon>
</v-btn>
<!-- <span>{{ $t('subtitles') }}</span> -->
</template>
<v-card>
<v-list color="transparent">
<v-list-item
v-for="track of tracks"
:key="track.srcIndex"
@click="playbackManager.currentSubtitleStreamIndex = track.srcIndex">
<v-icon
v-if="
track.srcIndex === playbackManager.currentSubtitleStreamIndex
">
<i-mdi-check />
</v-icon>
{{ track.label }}
</v-list-item>
</v-list>
</v-card>
<!-- Appended or prepended icons cause the menu to be scrollable. This doesn't happen if it's classic text. Vuetify 3.1.2 -->
<v-list>
<v-list-item
v-for="track of tracks"
:key="track.srcIndex"
:append-icon="
track.srcIndex === playbackManager.currentSubtitleStreamIndex
? IMdiCheck
: undefined
"
:title="track.label"
@click="playbackManager.currentSubtitleStreamIndex = track.srcIndex" />
</v-list>
</v-menu>
</template>

<script lang="ts">
<script lang="ts" setup>
import { SubtitleDeliveryMethod } from '@jellyfin/sdk/lib/generated-client';
import { defineComponent } from 'vue';
import { ref, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import IMdiCheck from 'virtual:icons/mdi/check';
import { playbackManagerStore } from '@/store';
import { PlaybackTrack } from '@/store/playbackManager';
export default defineComponent({
props: {
nudgeTop: {
type: [Number, String],
default: 0
}
},
setup() {
const playbackManager = playbackManagerStore();
const { t } = useI18n();
const playbackManager = playbackManagerStore();
return { playbackManager };
},
data() {
return {
menu: false
};
},
computed: {
tracks(): PlaybackTrack[] {
const subs = this.playbackManager
.currentItemParsedSubtitleTracks as PlaybackTrack[];
const menu = ref(false);
return [
{
label: this.$t('disabled'),
srcIndex: -1,
type: SubtitleDeliveryMethod.External
},
...subs
];
}
}
const tracks = computed(() => {
const subs =
playbackManager.currentItemParsedSubtitleTracks as PlaybackTrack[];
return [
{
label: t('disabled'),
srcIndex: -1,
type: SubtitleDeliveryMethod.External
},
...subs
];
});
</script>
Loading

0 comments on commit 46bcf8a

Please sign in to comment.