Skip to content

Commit

Permalink
[MS] FileControlsPlayback component
Browse files Browse the repository at this point in the history
  • Loading branch information
Ironicbay committed Jan 3, 2025
1 parent 2d78b4b commit 68b07d5
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 35 deletions.
34 changes: 34 additions & 0 deletions client/src/components/viewers/controls/FileControlsPlayback.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!-- Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS -->

<template>
<file-controls-group>
<file-controls-button
:class="{ 'flip-horizontal-ion-icon': ended }"
:icon="getPlaybackIcon()"
/>
</file-controls-group>
</template>

<script setup lang="ts">
import { refresh, play, pause } from 'ionicons/icons';
import { FileControlsButton, FileControlsGroup } from '@/components/viewers';

const props = defineProps<{
ended: boolean;
paused: boolean;
}>();

function getPlaybackIcon(): string {
if (props.ended) {
return refresh;
}
switch (props.paused) {
case true:
return play;
case false:
return pause;
}
}
</script>

<style scoped lang="scss"></style>
11 changes: 10 additions & 1 deletion client/src/components/viewers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import FileControlsButton from '@/components/viewers/controls/FileControlsButton
import FileControlsGroup from '@/components/viewers/controls/FileControlsGroup.vue';
import FileControlsInput from '@/components/viewers/controls/FileControlsInput.vue';
import FileControlsPagination from '@/components/viewers/controls/FileControlsPagination.vue';
import FileControlsPlayback from '@/components/viewers/controls/FileControlsPlayback.vue';
import FileControlsZoom from '@/components/viewers/controls/FileControlsZoom.vue';

export { FileControls, FileControlsButton, FileControlsGroup, FileControlsInput, FileControlsPagination, FileControlsZoom };
export {
FileControls,
FileControlsButton,
FileControlsGroup,
FileControlsInput,
FileControlsPagination,
FileControlsPlayback,
FileControlsZoom,
};
22 changes: 5 additions & 17 deletions client/src/views/viewers/AudioViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<!-- Disabled till we add an illustration in the viewer -->
<!-- <template #controls>
<file-controls>
<file-controls-button
:class="{'flip-horizontal-ion-icon': ended}"
:icon="getPlaybackIcon()"
<file-controls-playback
:paused="paused"
:ended="ended"
@click="togglePlayback"
/>
<file-controls-button
Expand All @@ -34,11 +34,11 @@
</template>

<script setup lang="ts">
// import { refresh, play, pause, volumeHigh, volumeLow, volumeMedium, volumeMute } from 'ionicons/icons';
// import { volumeHigh, volumeLow, volumeMedium, volumeMute } from 'ionicons/icons';
// import { FileControls, FileControlsPlayback, FileControlsButton } from '@/components/viewers';
import { onMounted, ref } from 'vue';
import { FileViewerWrapper } from '@/views/viewers';
import { FileContentInfo } from '@/views/viewers/utils';

const props = defineProps<{
contentInfo: FileContentInfo;
}>();
Expand Down Expand Up @@ -83,18 +83,6 @@ function updateMediaData(event: Event): void {
// return volumeMute;
// }
// }

// function getPlaybackIcon(): string {
// if (ended.value) {
// return refresh;
// }
// switch (paused.value) {
// case true:
// return play;
// case false:
// return pause;
// }
// }
</script>

<style scoped lang="scss"></style>
22 changes: 5 additions & 17 deletions client/src/views/viewers/VideoViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
</template>
<template #controls>
<file-controls>
<file-controls-button
:class="{ 'flip-horizontal-ion-icon': ended }"
:icon="getPlaybackIcon()"
<file-controls-playback
:paused="paused"
:ended="ended"
@click="togglePlayback"
/>
<file-controls-button
Expand All @@ -41,10 +41,10 @@
</template>

<script setup lang="ts">
import { refresh, play, pause, volumeHigh, volumeLow, volumeMedium, volumeMute, scan } from 'ionicons/icons';
import { volumeHigh, volumeLow, volumeMedium, volumeMute, scan } from 'ionicons/icons';
import { onMounted, ref } from 'vue';
import { FileContentInfo } from '@/views/viewers/utils';
import { FileControls, FileControlsButton } from '@/components/viewers';
import { FileControls, FileControlsButton, FileControlsPlayback } from '@/components/viewers';
import { FileViewerWrapper } from '@/views/viewers';

const props = defineProps<{
Expand Down Expand Up @@ -95,18 +95,6 @@ function getVolumeIcon(): string {
return volumeMute;
}
}

function getPlaybackIcon(): string {
if (ended.value) {
return refresh;
}
switch (paused.value) {
case true:
return play;
case false:
return pause;
}
}
</script>

<style scoped lang="scss">
Expand Down

0 comments on commit 68b07d5

Please sign in to comment.