Commit 9d07526d authored by Richard Blechinger's avatar Richard Blechinger
Browse files

Show total duration of playlist in relevant spots

parent 736db302
......@@ -31,7 +31,10 @@
<hr>
<p>Playlist entries:</p>
<p class="d-flex justify-content-between">
<span class="font-weight-bold">Playlist entries</span>
<span>Duration: {{ playlistDuration }}</span>
</p>
<!-- If no entries are here (i.e. we add a new playlist), only show
a hint that there's nothing here yet. -->
......@@ -221,6 +224,15 @@ export default {
}
},
playlistDuration() {
const totalDuration = this.playlistEditor.entries.reduce((acc, entry) => {
const file = this.getFileById(entry.file.id)
return acc + file.duration;
}, 0);
return this.prettyNanoseconds(totalDuration)
},
...mapGetters({
selectedShow: 'shows/selectedShow',
getPlaylistById: 'playlists/getPlaylistById',
......
......@@ -68,6 +68,13 @@
</b-button>
</template>
<!-- Column: Duration
This column displays the duration of all playlist entries combined
-->
<template v-slot:cell(duration)="data">
{{ durationSum(data) }}
</template>
<!-- Column: Last edit
This column lists the last date this playlist was changed.
-->
......@@ -128,6 +135,7 @@ export default {
{ key: 'id', label: 'Index' },
{ key: 'description', label: 'Description' },
{ key: 'entries', label: 'Entries' },
{ key: 'duration', label: 'Duration' },
{ key: 'updated', label: 'Last edit' },
{ key: 'actions', label: 'Actions', class: 'text-right' },
],
......@@ -179,6 +187,12 @@ export default {
editPlaylist (id) {
this.$refs.editPlaylistsModal.editPlaylist(id)
},
durationSum({ item }) {
const totalDuration = item.entries.reduce((acc, entry) => acc + entry.duration, 0)
return this.prettyNanoseconds(totalDuration)
}
},
}
</script>
......@@ -81,7 +81,8 @@ export default {
var hours = Math.floor(sec_total / 3600)
var minutes = Math.floor((sec_total - (hours * 3600)) / 60)
var seconds = Math.floor((sec_total - (hours * 3600) - (minutes * 60)) * 10) / 10
return hours + ':' + leadingZero(minutes) + ':' + leadingZero(seconds)
return leadingZero(hours) + ':' + leadingZero(minutes) + ':' + leadingZero(seconds)
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment