feat: add currentTime and duration to playerStore #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request primarily focuses on improving the video playback functionality in the application. The changes involve the addition of a
currentTime
andduration
state to the player store, the creation of a utility function to format seconds into a time string, and the utilization of these new features in theBottomPanel.vue
andCanvasPlayer.vue
components.Additions to player store state:
src/stores/player.ts
: AddedcurrentTime
andduration
as reactive state variables in the player store. These variables will keep track of the current playback time and total duration of the video, respectively.Utility function creation:
src/utils/index.ts
: Created aformatSeconds
function that takes a number of seconds and formats it into a time string in the format of hours, minutes, and seconds. This function will be used to display the current time and duration in the player.Updates to Vue components:
src/components/bottom-panel/BottomPanel.vue
: Imported theformatSeconds
function and addedcurrentTime
andduration
to the list of variables obtained from the player store. Updated the time display in the bottom panel to use these new variables. [1] [2]src/components/player/CanvasPlayer.vue
: Similar toBottomPanel.vue
, addedcurrentTime
andduration
to the list of variables obtained from the player store. Also added event listeners to the video element to updatecurrentTime
andduration
accordingly as the video plays. [1] [2]Test: