Skip to content

Commit

Permalink
refactor: update playback rate handling in ft-shaka-video-player and …
Browse files Browse the repository at this point in the history
…Watch components

- Changed default playback rate from 1.0 to 1 in ft-shaka-video-player.js
- Renamed event from 'current-playback-rate-update' to 'playback-rate-updated' in ft-shaka-video-player.js and Watch.vue
- Updated Watch.js to initialize currentPlaybackRate to null and set it based on store value in mounted lifecycle hook
  • Loading branch information
ikizey committed Dec 26, 2024
1 parent 8ecdf29 commit 4c8c245
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default defineComponent({
},
currentPlaybackRate: {
type: Number,
default: () => 1.0
default: () => 1
},
},
emits: [
Expand All @@ -134,7 +134,7 @@ export default defineComponent({
'ended',
'timeupdate',
'toggle-theatre-mode',
'current-playback-rate-update'
'playback-rate-updated'
],
setup: function (props, { emit, expose }) {
const { locale, t } = useI18n()
Expand Down Expand Up @@ -2415,7 +2415,7 @@ export default defineComponent({
await performFirstLoad()

player.addEventListener('ratechange', () => {
emit('current-playback-rate-update', video.value.playbackRate)
emit('playback-rate-updated', player.getPlaybackRate())
})
})

Expand Down
3 changes: 2 additions & 1 deletion src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default defineComponent({
videoGenreIsMusic: false,
/** @type {Date|null} */
streamingDataExpiryDate: null,
currentPlaybackRate: parseFloat(this.$store.getters.getDefaultPlayback)
currentPlaybackRate: null,
}
},
computed: {
Expand Down Expand Up @@ -305,6 +305,7 @@ export default defineComponent({
this.activeFormat = this.defaultVideoFormat

this.checkIfTimestamp()
this.currentPlaybackRate = parseFloat(this.$store.getters.getDefaultPlayback)
},
mounted: function () {
this.onMountedDependOnLocalStateLoading()
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/views/Watch/Watch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@timeupdate="updateCurrentChapter"
@ended="handleVideoEnded"
@toggle-theatre-mode="useTheatreMode = !useTheatreMode"
@current-playback-rate-update="updatePlaybackRate"
@playback-rate-updated="updatePlaybackRate"
/>
<div
v-if="!isLoading && (isUpcoming || errorMessage)"
Expand Down

0 comments on commit 4c8c245

Please sign in to comment.