Skip to content

Commit

Permalink
Fix blocking error when navigating away from an age-restricted video (#…
Browse files Browse the repository at this point in the history
…5343)

* Fix blocking error when navigating away from an age-restricted video

* Also fix playlists and watch history

* Simplify playlist check

Co-authored-by: Jason <[email protected]>

---------

Co-authored-by: Jason <[email protected]>
  • Loading branch information
absidue and kommunarr authored Jul 4, 2024
1 parent 8fca0be commit ed39608
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,9 +1100,9 @@ export default defineComponent({

handleWatchProgress: function () {
if (this.rememberHistory && !this.isUpcoming && !this.isLoading && !this.isLive) {
const player = this.$refs.videoPlayer.player
const player = this.$refs.videoPlayer?.player

if (player !== null && this.saveWatchedProgress) {
if (player && this.saveWatchedProgress) {
const currentTime = this.getWatchedProgress()
const payload = {
videoId: this.videoId,
Expand Down Expand Up @@ -1339,7 +1339,7 @@ export default defineComponent({
return
}

if (this.watchingPlaylist && this.$refs.watchVideoPlaylist.shouldStopDueToPlaylistEnd) {
if (this.watchingPlaylist && this.$refs.watchVideoPlaylist?.shouldStopDueToPlaylistEnd) {
// Let `watchVideoPlaylist` handle end of playlist, no countdown needed
this.$refs.watchVideoPlaylist.playNextVideo()
return
Expand All @@ -1359,8 +1359,8 @@ export default defineComponent({

const nextVideoInterval = this.defaultInterval
this.playNextTimeout = setTimeout(() => {
const player = this.$refs.videoPlayer.player
if (player !== null && player.paused()) {
const player = this.$refs.videoPlayer?.player
if (player && player.paused()) {
if (this.watchingPlaylist) {
this.$refs.watchVideoPlaylist.playNextVideo()
} else {
Expand Down Expand Up @@ -1408,9 +1408,9 @@ export default defineComponent({
this.handleWatchProgress()

if (!this.isUpcoming && !this.isLoading) {
const player = this.$refs.videoPlayer.player
const player = this.$refs.videoPlayer?.player

if (player !== null && !player.paused() && player.isInPictureInPicture()) {
if (player && !player.paused() && player.isInPictureInPicture()) {
setTimeout(() => {
player.play()
player.on('leavepictureinpicture', (event) => {
Expand Down

0 comments on commit ed39608

Please sign in to comment.