Skip to content

Commit d705292

Browse files
committed
* Update player reload handling to restart player at the current timestamp
1 parent 7e19728 commit d705292

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/renderer/views/Watch/Watch.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineComponent } from 'vue'
2+
import { isNavigationFailure, NavigationFailureType } from 'vue-router'
23
import { mapActions, mapMutations } from 'vuex'
34
import shaka from 'shaka-player'
45
import { Utils, YTNodes } from 'youtubei.js'
@@ -1909,10 +1910,27 @@ export default defineComponent({
19091910
this.startNextVideoInPip = uiState.startNextVideoInPip
19101911
},
19111912

1912-
onPlayerReloadRequested() {
1913+
async onPlayerReloadRequested() {
19131914
showToast('Reloading player according to SABR request')
19141915
this.sabrReloadCount++
1915-
this.reloadView()
1916+
1917+
const timestamp = this.getTimestamp()
1918+
if (timestamp > 0) {
1919+
// Reload at the middle should restart at current timestamp
1920+
try {
1921+
await this.$router.replace({
1922+
path: this.$route.path,
1923+
query: { ...this.$route.query, timestamp: timestamp },
1924+
})
1925+
} catch (failure) {
1926+
if (isNavigationFailure(failure, NavigationFailureType.duplicated)) {
1927+
return
1928+
}
1929+
1930+
throw failure
1931+
}
1932+
}
1933+
await this.reloadView()
19161934
},
19171935

19181936
...mapActions([

0 commit comments

Comments
 (0)