Skip to content

Commit 3311726

Browse files
joaoantoniocardosorafaellehmkuhl
authored andcommitted
video-player: Add rotation
1 parent c876ab7 commit 3311726

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/components/widgets/VideoPlayer.vue

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,18 @@
5050
:color="widget.options.flipVertically ? 'rgb(0, 20, 80)' : undefined"
5151
hide-details
5252
/>
53+
<div class="d-flex flex-wrap justify-center ga-5">
54+
<v-btn prepend-icon="mdi-file-rotate-left" variant="outlined" @click="rotateVideo(-90)"> Rotate Left</v-btn>
55+
<v-btn prepend-icon="mdi-file-rotate-right" variant="outlined" @click="rotateVideo(+90)"> Rotate Right</v-btn>
56+
</div>
5357
</v-card-text>
5458
</v-card>
5559
</v-dialog>
5660
</template>
5761

5862
<script setup lang="ts">
5963
import { storeToRefs } from 'pinia'
60-
import { computed, onBeforeMount, ref, toRefs, watch } from 'vue'
61-
import { onBeforeUnmount } from 'vue'
64+
import { computed, onBeforeMount, onBeforeUnmount, ref, toRefs, watch } from 'vue'
6265
6366
import { isEqual } from '@/libs/utils'
6467
import { useVideoStore } from '@/stores/video'
@@ -87,6 +90,7 @@ onBeforeMount(() => {
8790
videoFitStyle: 'cover',
8891
flipHorizontally: false,
8992
flipVertically: false,
93+
rotationAngle: 0,
9094
streamName: undefined as string | undefined,
9195
}
9296
}
@@ -125,9 +129,21 @@ watch(mediaStream, () => {
125129
})
126130
})
127131
132+
const rotateVideo = (angle: number): void => {
133+
widget.value.options.rotationAngle += angle
134+
}
135+
128136
const flipStyle = computed(() => {
129137
return `scale(${widget.value.options.flipHorizontally ? -1 : 1}, ${widget.value.options.flipVertically ? -1 : 1})`
130138
})
139+
140+
const rotateStyle = computed(() => {
141+
return `rotate(${widget.value.options.rotationAngle ?? 0}deg)`
142+
})
143+
144+
const transformStyle = computed(() => {
145+
return `${flipStyle.value} ${rotateStyle.value}`
146+
})
131147
</script>
132148

133149
<style scoped>
@@ -146,7 +162,7 @@ video {
146162
top: 0;
147163
left: 0;
148164
object-fit: v-bind('widget.options.videoFitStyle');
149-
transform: v-bind('flipStyle');
165+
transform: v-bind('transformStyle');
150166
}
151167
.no-video-alert {
152168
width: 100%;

0 commit comments

Comments
 (0)