2015-12-13 04:42:28 +00:00
|
|
|
<template>
|
2016-02-08 12:21:24 +00:00
|
|
|
<tr
|
|
|
|
@dblclick.prevent="playRightAwayyyyyyy"
|
2015-12-13 04:42:28 +00:00
|
|
|
class="song-item"
|
2016-02-08 12:21:24 +00:00
|
|
|
:class="{ selected: selected, playing: song.playbackState === 'playing' || song.playbackState === 'paused' }"
|
2015-12-13 04:42:28 +00:00
|
|
|
>
|
2016-02-08 14:33:07 +00:00
|
|
|
<td class="title">
|
|
|
|
<span class="play-count" v-if="showPlayCount"
|
|
|
|
title="{{ song.playCount }} {{ song.playCount | pluralize 'play' }}"
|
|
|
|
:style="{ width: song.playCount * 100 / topPlayCount + '%' }"
|
|
|
|
>{{ song.title }}
|
|
|
|
</span>
|
|
|
|
<span v-else>{{ song.title }}</span>
|
|
|
|
</td>
|
2015-12-13 04:42:28 +00:00
|
|
|
<td class="artist">{{ song.album.artist.name }}</td>
|
|
|
|
<td class="album">{{ song.album.name }}</td>
|
|
|
|
<td class="time">{{ song.fmtLength }}</td>
|
2016-01-11 14:06:42 +00:00
|
|
|
<td class="play" @click.stop="doPlayback">
|
2016-02-08 12:21:24 +00:00
|
|
|
<i class="fa fa-pause-circle" v-show="song.playbackState === 'playing'"></i>
|
2016-01-11 14:06:42 +00:00
|
|
|
<i class="fa fa-play-circle" v-else></i>
|
2016-01-07 04:22:02 +00:00
|
|
|
</td>
|
2015-12-13 04:42:28 +00:00
|
|
|
</tr>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import playback from '../../services/playback';
|
2016-01-07 08:11:11 +00:00
|
|
|
import queueStore from '../../stores/queue';
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
export default {
|
2016-02-08 14:33:07 +00:00
|
|
|
props: [
|
|
|
|
'song',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not we should display the play count indicators.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
'showPlayCount',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The play count of the most-played song, so that we can have some percentage-base comparison.
|
|
|
|
*
|
|
|
|
* @type {integer}
|
|
|
|
*/
|
|
|
|
'topPlayCount'
|
|
|
|
],
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2016-01-17 09:59:58 +00:00
|
|
|
selected: false,
|
2015-12-13 04:42:28 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
/**
|
2016-01-07 08:11:11 +00:00
|
|
|
* Play the song right away.
|
2015-12-13 04:42:28 +00:00
|
|
|
*/
|
2016-01-31 15:59:06 +00:00
|
|
|
playRightAwayyyyyyy() {
|
2016-01-07 08:11:11 +00:00
|
|
|
if (!queueStore.contains(this.song)) {
|
|
|
|
queueStore.queueAfterCurrent(this.song);
|
|
|
|
}
|
2016-02-08 12:21:24 +00:00
|
|
|
|
|
|
|
playback.play(this.song);
|
2015-12-13 04:42:28 +00:00
|
|
|
},
|
2016-01-06 16:41:59 +00:00
|
|
|
|
2016-01-11 14:06:42 +00:00
|
|
|
/**
|
|
|
|
* Take the right playback action based on the current playback state.
|
|
|
|
*/
|
|
|
|
doPlayback() {
|
2016-02-08 12:21:24 +00:00
|
|
|
switch (this.song.playbackState) {
|
2016-01-11 14:06:42 +00:00
|
|
|
case 'playing':
|
|
|
|
playback.pause();
|
|
|
|
break;
|
|
|
|
case 'paused':
|
|
|
|
playback.resume();
|
|
|
|
break;
|
|
|
|
default:
|
2016-01-31 15:59:06 +00:00
|
|
|
this.playRightAwayyyyyyy();
|
2016-01-11 14:06:42 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-01-06 16:41:59 +00:00
|
|
|
},
|
2016-01-17 09:59:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle the "selected" state of the current component.
|
|
|
|
*/
|
|
|
|
toggleSelectedState() {
|
|
|
|
this.selected = !this.selected;
|
|
|
|
},
|
|
|
|
|
2016-01-17 14:08:39 +00:00
|
|
|
/**
|
|
|
|
* Select the current component (apply a CSS class on its DOM).
|
|
|
|
*/
|
2016-01-17 09:59:58 +00:00
|
|
|
select() {
|
|
|
|
this.selected = true;
|
|
|
|
},
|
|
|
|
|
2016-01-17 14:08:39 +00:00
|
|
|
/**
|
|
|
|
* Deselect the current component.
|
|
|
|
*/
|
2016-01-17 09:59:58 +00:00
|
|
|
deselect() {
|
|
|
|
this.selected = false;
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="sass">
|
|
|
|
@import "resources/assets/sass/partials/_vars.scss";
|
|
|
|
@import "resources/assets/sass/partials/_mixins.scss";
|
|
|
|
|
|
|
|
.song-item {
|
|
|
|
border-bottom: 1px solid $color2ndBgr;
|
|
|
|
|
2016-01-07 04:22:02 +00:00
|
|
|
html.no-touchevents &:hover {
|
2015-12-13 04:42:28 +00:00
|
|
|
background: rgba(255, 255, 255, .05);
|
|
|
|
}
|
|
|
|
|
|
|
|
.time {
|
|
|
|
color: $color2ndText;
|
|
|
|
}
|
|
|
|
|
|
|
|
.title {
|
|
|
|
min-width: 192px;
|
2016-02-08 14:33:07 +00:00
|
|
|
padding: 0;
|
|
|
|
|
|
|
|
span {
|
|
|
|
display: inline-block;
|
|
|
|
padding: 8px;
|
|
|
|
|
|
|
|
&.play-count {
|
|
|
|
background: rgba(255, 255, 255, 0.08);
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
}
|
|
|
|
|
2016-01-07 04:22:02 +00:00
|
|
|
.play {
|
2016-01-06 16:41:59 +00:00
|
|
|
max-width: 32px;
|
2016-01-07 04:22:02 +00:00
|
|
|
opacity: .5;
|
|
|
|
|
|
|
|
i {
|
|
|
|
font-size: 150%;
|
|
|
|
}
|
2016-01-06 16:41:59 +00:00
|
|
|
}
|
|
|
|
|
2015-12-13 04:42:28 +00:00
|
|
|
&.selected {
|
|
|
|
background-color: rgba(255, 255, 255, .08);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.playing {
|
|
|
|
color: $colorHighlight;
|
|
|
|
}
|
2016-02-08 14:33:07 +00:00
|
|
|
|
|
|
|
@media only screen and (max-device-width : 768px) {
|
|
|
|
.title {
|
|
|
|
padding: 0;
|
|
|
|
|
|
|
|
span {
|
|
|
|
display: inline;
|
|
|
|
padding: 0;
|
|
|
|
|
|
|
|
&.play-count {
|
|
|
|
background: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
}
|
|
|
|
</style>
|