koel/resources/assets/js/mixins/shuffle-selected.js
2015-12-14 12:25:42 +08:00

28 lines
753 B
JavaScript

import $ from 'jquery';
import playback from '../services/playback';
/**
* Add a "shuffle selected" functionality to any component containing a song-list component using this mixin.
* Such a component should:
* - pass "selectedSongs" SYNC prop into the song-list component, e.g.
* <song-list :items="state.songs" :selected-songs.sync="selectedSongs" type="queue"></song-list>
* - trigger shuffling with shuffleSelected() method
*/
export default {
data() {
return {
selectedSongs: [],
};
},
methods: {
shuffleSelected() {
if (this.selectedSongs.length < 2) {
return;
}
playback.queueAndPlay(this.selectedSongs, true);
},
},
};