Commit e023a5cc authored by Richard Blechinger's avatar Richard Blechinger
Browse files

WIP

parent 9e4e189d
...@@ -122,6 +122,15 @@ ...@@ -122,6 +122,15 @@
> >
<b class="upDownArrows">&darr;</b> <b class="upDownArrows">&darr;</b>
</b-button> </b-button>
<b-button
v-if="!data.item.file"
variant="info"
@click="editPlaylistItemDuration(data.index)"
>
Duration
</b-button>
<b-button <b-button
variant="danger" variant="danger"
@click="deletePlaylistItem(data.index)" @click="deletePlaylistItem(data.index)"
...@@ -226,8 +235,15 @@ export default { ...@@ -226,8 +235,15 @@ export default {
playlistDuration() { playlistDuration() {
const totalDuration = this.playlistEditor.entries.reduce((acc, entry) => { const totalDuration = this.playlistEditor.entries.reduce((acc, entry) => {
const file = this.getFileById(entry.file.id) const file = entry.file || {}
return acc + file.duration; const { id } = file
const savedFile = this.getFileById(id) || {};
if (Number.isNaN(acc + savedFile.duration)) {
return acc;
}
return acc + savedFile.duration;
}, 0); }, 0);
return this.prettyNanoseconds(totalDuration) return this.prettyNanoseconds(totalDuration)
...@@ -260,6 +276,10 @@ export default { ...@@ -260,6 +276,10 @@ export default {
} }
}, },
editPlaylistItemDuration (index) {
console.log(this.playlistEditor.entries);
},
movePlaylistItemUp (index) { movePlaylistItemUp (index) {
if (index > 0 && index < this.playlistEditor.entries.length) { if (index > 0 && index < this.playlistEditor.entries.length) {
let temp = this.playlistEditor.entries[index - 1] let temp = this.playlistEditor.entries[index - 1]
...@@ -294,7 +314,7 @@ export default { ...@@ -294,7 +314,7 @@ export default {
// add a line input to the playlist that is being edited // add a line input to the playlist that is being edited
addPlaylistItemLine (line) { addPlaylistItemLine (line) {
this.playlistEditor.entries.push({uri: 'line://' + line}) this.playlistEditor.entries.push({uri: 'line://' + line + '?duration=9999999' })
}, },
// controls sub-modal to add a new URI to the playlist editor // controls sub-modal to add a new URI to the playlist editor
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
This column displays the duration of all playlist entries combined This column displays the duration of all playlist entries combined
--> -->
<template v-slot:cell(duration)="data"> <template v-slot:cell(duration)="data">
{{ playlistDuration(data) }} {{ playlistDuration(data) }} ({{ unknownDurationCount(data) }} unspecified)
</template> </template>
<!-- Column: Last edit <!-- Column: Last edit
...@@ -189,9 +189,21 @@ export default { ...@@ -189,9 +189,21 @@ export default {
}, },
playlistDuration({ item }) { playlistDuration({ item }) {
const totalDuration = item.entries.reduce((acc, entry) => acc + entry.duration, 0) const totalDuration = item.entries.reduce((acc, entry) => {
const newDuration = acc + entry.duration;
if (Number.isNaN(newDuration)) {
return acc;
}
return newDuration
}, 0)
return this.prettyNanoseconds(totalDuration) return this.prettyNanoseconds(totalDuration)
},
unknownDurationCount({ item }) {
return item.entries.filter(entry => !entry.duration).length;
} }
}, },
} }
......
...@@ -84,7 +84,7 @@ export default { ...@@ -84,7 +84,7 @@ export default {
var hours = Math.floor(sec_total / 3600) var hours = Math.floor(sec_total / 3600)
var minutes = Math.floor((sec_total - (hours * 3600)) / 60) var minutes = Math.floor((sec_total - (hours * 3600)) / 60)
var seconds = Math.floor((sec_total - (hours * 3600) - (minutes * 60)) * 10) / 10 var seconds = Math.floor((sec_total - (hours * 3600) - (minutes * 60)) * 10) / 10
return hours + ':' + leadingZero(minutes) + ':' + leadingZero(seconds) return hours + ':' + leadingZero(minutes) + ':' + leadingZero(seconds.toFixed(0))
}, },
nanosecondsToMinutes: function(ns) { nanosecondsToMinutes: function(ns) {
return ns / 1000 / 1000 / 1000 / 60; return ns / 1000 / 1000 / 1000 / 60;
......
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