handle streams without duration

This commit is contained in:
Thomas Amland 2020-08-23 14:47:01 +02:00
parent d80fb85484
commit 0b7d731ed4
2 changed files with 6 additions and 1 deletions

View File

@ -118,7 +118,9 @@ export const playerModule: Module<State, any> = {
return dispatch('play') return dispatch('play')
}, },
seek({ commit, state }, value) { seek({ commit, state }, value) {
commit('setPosition', state.duration * value) if (isFinite(state.duration)) {
commit('setPosition', state.duration * value)
}
}, },
playNext({ commit }, track) { playNext({ commit }, track) {
commit('setNextInQueue', track) commit('setNextInQueue', track)

View File

@ -1,6 +1,9 @@
import Vue from 'vue' import Vue from 'vue'
Vue.filter('duration', (value: number) => { Vue.filter('duration', (value: number) => {
if (!isFinite(value)) {
return '∞'
}
const minutes = Math.floor(value / 60) const minutes = Math.floor(value / 60)
const seconds = Math.floor(value % 60) const seconds = Math.floor(value % 60)
return (minutes < 10 ? '0' : '') + minutes + ':' + (seconds < 10 ? '0' : '') + seconds return (minutes < 10 ? '0' : '') + minutes + ':' + (seconds < 10 ? '0' : '') + seconds