fix: remove request progress from progress reports & other fixes

This commit is contained in:
MrTimscampi 2020-12-13 08:51:09 +01:00
parent 0514f2e7a3
commit a34eed1cf7
4 changed files with 52 additions and 50 deletions

View File

@ -151,16 +151,19 @@ export default Vue.extend({
...mapActions('snackbar', ['pushSnackbarMessage']),
onVideoPlaying(_event: Event) {
// TODO: Move to playback manager
this.$api.playState.reportPlaybackStart({
playbackStartInfo: {
CanSeek: true,
ItemId: this.item.Id,
PlaySessionId: this.playbackInfo.PlaySessionId,
MediaSourceId: this.playbackInfo.MediaSources?.[0].Id,
AudioStreamIndex: 0, // TODO: Don't hardcode this
SubtitleStreamIndex: 0 // TODO: Don't hardcode this
}
});
this.$api.playState.reportPlaybackStart(
{
playbackStartInfo: {
CanSeek: true,
ItemId: this.item.Id,
PlaySessionId: this.playbackInfo.PlaySessionId,
MediaSourceId: this.playbackInfo.MediaSources?.[0].Id,
AudioStreamIndex: 0, // TODO: Don't hardcode this
SubtitleStreamIndex: 0 // TODO: Don't hardcode this
}
},
{ progress: false }
);
this.lastProgressUpdate = new Date().getTime();
},
@ -168,18 +171,21 @@ export default Vue.extend({
// TODO: Move to playback manager
const now = new Date().getTime();
if (!(now - this.lastProgressUpdate < 700)) {
if (now - this.lastProgressUpdate > 1000) {
const currentTime = (this.$refs.videoPlayer as HTMLVideoElement)
.currentTime;
this.$api.playState.reportPlaybackProgress({
playbackProgressInfo: {
ItemId: this.item.Id,
PlaySessionId: this.playbackInfo.PlaySessionId,
IsPaused: false,
PositionTicks: Math.round(this.msToTicks(currentTime * 1000))
}
});
this.$api.playState.reportPlaybackProgress(
{
playbackProgressInfo: {
ItemId: this.item.Id,
PlaySessionId: this.playbackInfo.PlaySessionId,
IsPaused: false,
PositionTicks: Math.round(this.msToTicks(currentTime * 1000))
}
},
{ progress: false }
);
this.lastProgressUpdate = new Date().getTime();
}
@ -189,27 +195,33 @@ export default Vue.extend({
const currentTime = (this.$refs.videoPlayer as HTMLVideoElement)
.currentTime;
this.$api.playState.reportPlaybackProgress({
playbackProgressInfo: {
ItemId: this.item.Id,
PlaySessionId: this.playbackInfo.PlaySessionId,
IsPaused: true,
PositionTicks: Math.round(this.msToTicks(currentTime * 1000))
}
});
this.$api.playState.reportPlaybackProgress(
{
playbackProgressInfo: {
ItemId: this.item.Id,
PlaySessionId: this.playbackInfo.PlaySessionId,
IsPaused: true,
PositionTicks: Math.round(this.msToTicks(currentTime * 1000))
}
},
{ progress: false }
);
},
onVideoStopped(_event?: Event) {
// TODO: Move to playback manager
const currentTime = (this.$refs.videoPlayer as HTMLVideoElement)
.currentTime;
this.$api.playState.reportPlaybackStopped({
playbackStopInfo: {
ItemId: this.item.Id,
PlaySessionId: this.playbackInfo.PlaySessionId,
PositionTicks: this.msToTicks(currentTime * 1000)
}
});
this.$api.playState.reportPlaybackStopped(
{
playbackStopInfo: {
ItemId: this.item.Id,
PlaySessionId: this.playbackInfo.PlaySessionId,
PositionTicks: this.msToTicks(currentTime * 1000)
}
},
{ progress: false }
);
this.lastProgressUpdate = 0;

View File

@ -8,7 +8,7 @@
"biography": "Biography",
"browserNotSupported": "Your browser is not supported for playing this file.",
"buttons": {
"ok": "OK"
"ok": "Ok"
},
"byArtist": "By",
"changeServer": "Change server",

View File

@ -7,35 +7,25 @@ import Vue from 'vue';
declare module '@nuxt/types' {
interface Context {
errorModalWidth: () => string | number;
smallModalWidth: () => string | number;
}
interface NuxtAppOptions {
errorModalWidth: () => string | number;
smallModalWidth: () => string | number;
}
}
declare module 'vue/types/vue' {
interface Vue {
errorModalWidth: () => string | number;
smallModalWidth: () => string | number;
}
}
const modalHelper = Vue.extend({
computed: {
errorModalWidth(): string | number {
smallModalWidth(): string | number {
if (this.$vuetify.breakpoint.smAndDown) {
return '90%';
} else if (
this.$vuetify.breakpoint.smAndUp &&
!this.$vuetify.breakpoint.mdAndUp
) {
return 600;
} else if (
this.$vuetify.breakpoint.mdAndUp &&
!this.$vuetify.breakpoint.lgAndUp
) {
return 600;
} else {
return 600;
}

View File

@ -7,7 +7,7 @@
@error="handleShakaPlayerError"
/>
<v-dialog v-model="errorDialog" :width="errorModalWidth">
<v-dialog v-model="errorDialog" :width="smallModalWidth">
<v-card>
<v-card-title class="headline">
{{ $t('errors.anErrorHappened') }}