Skip to content

Commit

Permalink
fix: track changes due to skip and snip times (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrani authored Sep 30, 2023
1 parent bab5142 commit 1884ed1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/models/video/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default class VideoElement {
constructor(video) {
this._video = video
this._currentTrackId = null
this.#listenForTrackChange()
this._active = sessionStorage.getItem('enabled') == 'true'

this._videoOverride = new VideoOverride(this)
Expand Down Expand Up @@ -98,18 +97,13 @@ export default class VideoElement {
return
} else if (isSnip || isShared) {
this._video.currentTime = { source: 'chorus', value: startTime }
this._video.play()
} else {
this._video.play()
}
this._currentTrackId = trackId
}

#listenForTrackChange() {
this._video.addEventListener('loadeddata', async () => {
await this.#handleTrackChange()
})
}

get #muteButton() {
return document.querySelector('[data-testid="volume-bar-toggle-mute-button"]')
}
Expand Down
4 changes: 2 additions & 2 deletions src/observers/current-time/song-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class SongTracker {
if (this.#isMuted) this.#toggleMuteIfMuted()
this.#handleSongEnd(songStateData)
}
}, 500)
}, 1000)
}

#setVideoTime(timeObject) {
Expand Down Expand Up @@ -75,7 +75,7 @@ export default class SongTracker {
}

#atSongEnd(endTime) {
return parseInt(this._video.currentTime, 10) >= parseInt(endTime, 10) + 1
return parseInt(this._video.currentTime, 10) >= parseInt(endTime, 10) - 1
}

#handleSongEnd({ endTime, startTime }) {
Expand Down

0 comments on commit 1884ed1

Please sign in to comment.