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

WIP

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