2015-12-13 04:42:28 +00:00
|
|
|
<template>
|
2016-06-25 16:05:24 +00:00
|
|
|
<tr
|
|
|
|
class="song-item"
|
|
|
|
draggable="true"
|
|
|
|
:data-song-id="song.id"
|
2017-01-14 13:09:38 +00:00
|
|
|
@click="clicked"
|
2016-06-25 16:05:24 +00:00
|
|
|
@dblclick.prevent="playRightAwayyyyyyy"
|
2017-01-14 13:09:38 +00:00
|
|
|
@dragstart="dragStart"
|
|
|
|
@dragleave="removeDroppableState"
|
|
|
|
@dragover.prevent="allowDrop"
|
|
|
|
@drop.stop.prevent="handleDrop"
|
|
|
|
@contextmenu.prevent="openContextMenu"
|
|
|
|
:class="{ selected: item.selected, playing: playing }"
|
2016-06-25 16:05:24 +00:00
|
|
|
>
|
|
|
|
<td class="track-number">{{ song.track || '' }}</td>
|
|
|
|
<td class="title">{{ song.title }}</td>
|
|
|
|
<td class="artist">{{ song.artist.name }}</td>
|
|
|
|
<td class="album">{{ song.album.name }}</td>
|
2016-09-10 07:41:44 +00:00
|
|
|
<td class="time">{{ song.fmtLength }}</td>
|
2016-06-25 16:05:24 +00:00
|
|
|
<td class="play" @click.stop="doPlayback">
|
2016-10-31 04:28:12 +00:00
|
|
|
<i class="fa fa-pause-circle" v-if="song.playbackState === 'playing'"/>
|
|
|
|
<i class="fa fa-play-circle" v-else/>
|
2016-06-25 16:05:24 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
2015-12-13 04:42:28 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2016-11-26 03:25:35 +00:00
|
|
|
import { playback } from '../../services'
|
|
|
|
import { queueStore } from '../../stores'
|
2017-01-14 13:09:38 +00:00
|
|
|
import $v from 'vuequery'
|
2016-06-25 16:05:24 +00:00
|
|
|
|
|
|
|
export default {
|
2017-01-14 13:09:38 +00:00
|
|
|
props: ['item'],
|
|
|
|
name: 'song-item',
|
2016-06-25 16:05:24 +00:00
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
data () {
|
2016-06-25 16:05:24 +00:00
|
|
|
return {
|
2017-01-14 13:09:38 +00:00
|
|
|
parentSongList: null
|
2016-11-26 03:25:35 +00:00
|
|
|
}
|
2016-06-25 16:05:24 +00:00
|
|
|
},
|
|
|
|
|
2016-11-15 07:54:41 +00:00
|
|
|
computed: {
|
2017-01-14 13:09:38 +00:00
|
|
|
/**
|
|
|
|
* A shortcut to access the current vm's song (instead of this.item.song).
|
|
|
|
* @return {Object}
|
|
|
|
*/
|
|
|
|
song () {
|
|
|
|
return this.item.song
|
|
|
|
},
|
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
playing () {
|
|
|
|
return this.song.playbackState === 'playing' || this.song.playbackState === 'paused'
|
|
|
|
}
|
2016-11-15 07:54:41 +00:00
|
|
|
},
|
|
|
|
|
2017-01-14 13:09:38 +00:00
|
|
|
created () {
|
|
|
|
this.parentSongList = $v(this).closest('song-list').vm
|
|
|
|
},
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
methods: {
|
|
|
|
/**
|
|
|
|
* Play the song right away.
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
playRightAwayyyyyyy () {
|
2016-06-25 16:05:24 +00:00
|
|
|
if (!queueStore.contains(this.song)) {
|
2016-11-26 03:25:35 +00:00
|
|
|
queueStore.queueAfterCurrent(this.song)
|
2016-06-25 16:05:24 +00:00
|
|
|
}
|
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
playback.play(this.song)
|
2016-06-25 16:05:24 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Take the right playback action based on the current playback state.
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
doPlayback () {
|
2016-06-25 16:05:24 +00:00
|
|
|
switch (this.song.playbackState) {
|
|
|
|
case 'playing':
|
2016-11-26 03:25:35 +00:00
|
|
|
playback.pause()
|
|
|
|
break
|
2016-06-25 16:05:24 +00:00
|
|
|
case 'paused':
|
2016-11-26 03:25:35 +00:00
|
|
|
playback.resume()
|
|
|
|
break
|
2016-06-25 16:05:24 +00:00
|
|
|
default:
|
2016-11-26 03:25:35 +00:00
|
|
|
this.playRightAwayyyyyyy()
|
|
|
|
break
|
2016-06-25 16:05:24 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-01-14 13:09:38 +00:00
|
|
|
clicked (event) {
|
|
|
|
this.parentSongList.rowClicked(this, event)
|
2016-06-25 16:05:24 +00:00
|
|
|
},
|
|
|
|
|
2017-01-14 13:09:38 +00:00
|
|
|
dragStart (event) {
|
|
|
|
this.parentSongList.dragStart(this, event)
|
2016-06-25 16:05:24 +00:00
|
|
|
},
|
|
|
|
|
2017-01-14 13:09:38 +00:00
|
|
|
removeDroppableState (event) {
|
|
|
|
this.parentSongList.removeDroppableState(event)
|
2016-06-25 16:05:24 +00:00
|
|
|
},
|
2016-11-15 07:54:41 +00:00
|
|
|
|
|
|
|
/**
|
2017-01-14 13:09:38 +00:00
|
|
|
* Add a "droppable" class and set the drop effect when other songs are dragged over the row.
|
|
|
|
*
|
|
|
|
* @param {Object} event The dragover event.
|
2016-11-15 07:54:41 +00:00
|
|
|
*/
|
2017-01-14 13:09:38 +00:00
|
|
|
allowDrop (event) {
|
|
|
|
this.parentSongList.allowDrop(event)
|
|
|
|
},
|
|
|
|
|
|
|
|
handleDrop (event) {
|
|
|
|
this.parentSongList.handleDrop(this, event)
|
|
|
|
},
|
|
|
|
|
|
|
|
openContextMenu (event) {
|
|
|
|
this.parentSongList.openContextMenu(this, event)
|
2016-11-26 03:25:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="sass">
|
2016-06-25 16:05:24 +00:00
|
|
|
@import "../../../sass/partials/_vars.scss";
|
|
|
|
@import "../../../sass/partials/_mixins.scss";
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
.song-item {
|
|
|
|
border-bottom: 1px solid $color2ndBgr;
|
2017-01-14 13:09:38 +00:00
|
|
|
height: 35px;
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
html.no-touchevents &:hover {
|
|
|
|
background: rgba(255, 255, 255, .05);
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
.time, .track-number {
|
|
|
|
color: $color2ndText;
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
.title {
|
|
|
|
min-width: 192px;
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
.play {
|
|
|
|
max-width: 32px;
|
|
|
|
opacity: .5;
|
2016-01-07 04:22:02 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
i {
|
|
|
|
font-size: 1.5rem;
|
|
|
|
}
|
|
|
|
}
|
2016-01-06 16:41:59 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
&.selected {
|
|
|
|
background-color: rgba(255, 255, 255, .08);
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2017-01-14 13:39:08 +00:00
|
|
|
&.playing td {
|
2016-06-25 16:05:24 +00:00
|
|
|
color: $colorHighlight;
|
|
|
|
}
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
</style>
|