Files
Iris/src/js/services/mopidy/actions.js

280 lines
4.7 KiB
JavaScript
Raw Normal View History

import * as helpers from '../../helpers'
2017-05-19 11:33:06 +12:00
export function setConfig(config){
return {
type: 'MOPIDY_SET_CONFIG',
config: config
}
}
export function connect(){
return {
type: 'MOPIDY_CONNECT'
}
}
export function disconnect(){
2016-10-18 08:56:53 +13:00
return {
type: 'MOPIDY_DISCONNECT'
2016-10-18 08:56:53 +13:00
}
}
2017-05-19 11:33:06 +12:00
export function instruct(call, value){
return {
type: 'MOPIDY_INSTRUCT',
call: call,
value: value
}
}
2017-05-19 11:33:06 +12:00
export function debug(call, value){
return {
type: 'MOPIDY_DEBUG',
call: call,
value: value
}
}
/**
* Playback-oriented actions
**/
export function changeTrack( tlid ){
2017-05-19 11:33:06 +12:00
return instruct('playback.play', {tlid: tlid})
}
2017-05-05 03:56:55 +12:00
export function playURIs(uris, from_uri = null){
2016-10-19 14:09:34 +13:00
return {
type: 'MOPIDY_PLAY_URIS',
uris: uris,
from_uri: from_uri
}
}
export function enqueueURIs(uris, from_uri = null, next = false, at_position = null, offset = 0){
return {
type: 'MOPIDY_ENQUEUE_URIS',
uris: uris,
at_position: at_position,
next: next,
from_uri: from_uri,
offset: offset
2016-10-19 14:09:34 +13:00
}
}
2017-05-05 03:56:55 +12:00
export function enqueueURIsBatchDone(){
return {
type: 'MOPIDY_ENQUEUE_URIS_BATCH_DONE'
}
}
export function playPlaylist(uri){
return {
type: 'MOPIDY_PLAY_PLAYLIST',
uri: uri
}
}
export function playAlbum(uri){
return {
type: 'MOPIDY_PLAY_ALBUM',
uri: uri
}
}
export function removeTracks( tlids ){
2017-05-19 11:33:06 +12:00
return instruct('tracklist.remove', {tlid: tlids})
}
export function reorderTracklist( indexes, insert_before ){
var range = helpers.createRange( indexes );
2016-11-25 19:04:27 +13:00
if( insert_before > range.start ) insert_before = insert_before - range.length
return {
type: 'MOPIDY_REORDER_TRACKLIST',
range_start: range.start,
range_length: range.length,
insert_before: insert_before
}
}
2017-01-22 12:54:20 +13:00
export function clearTracklist(){
2017-05-19 11:33:06 +12:00
return instruct('tracklist.clear')
2017-01-22 12:54:20 +13:00
}
export function play(){
2017-05-19 11:33:06 +12:00
return instruct('playback.play')
}
export function pause(){
2017-05-19 11:33:06 +12:00
return instruct('playback.pause')
}
2016-11-03 18:22:26 +13:00
export function stop(){
2017-05-19 11:33:06 +12:00
return instruct('playback.stop')
2016-11-03 18:22:26 +13:00
}
export function next(){
2017-05-19 11:33:06 +12:00
return instruct('playback.next')
}
export function previous(){
2017-05-19 11:33:06 +12:00
return instruct('playback.previous')
}
2017-05-19 11:33:06 +12:00
export function setMute(mute){
return instruct('mixer.setMute', {mute: mute})
2016-11-04 13:51:17 +13:00
}
2017-05-19 11:33:06 +12:00
export function setVolume(volume){
return instruct('playback.setVolume', {volume: volume})
}
export function seek(time_position){
return instruct('playback.seek', {time_position: parseInt(time_position)})
2016-11-03 18:22:26 +13:00
}
export function getTimePosition(){
2017-05-19 11:33:06 +12:00
return instruct('playback.getTimePosition')
2016-11-03 18:22:26 +13:00
}
2017-05-19 11:33:06 +12:00
export function setTimePosition(time_position){
2016-11-08 16:57:44 +13:00
return {
type: 'MOPIDY_TIMEPOSITION',
data: time_position
}
}
/**
* Asset-oriented actions
**/
export function getImages( context, uris ){
return {
type: 'MOPIDY_GET_IMAGES',
context: context,
uris: uris
}
}
2017-08-22 20:44:36 +12:00
export function createPlaylist(name, scheme){
return {
type: 'MOPIDY_CREATE_PLAYLIST',
name: name,
scheme: scheme
}
}
2016-11-14 11:20:02 +13:00
export function deletePlaylist( uri ){
return {
type: 'MOPIDY_DELETE_PLAYLIST',
uri: uri
}
}
export function getLibraryPlaylists(){
return { type: 'MOPIDY_GET_LIBRARY_PLAYLISTS' }
}
export function getPlaylist( uri ){
return {
type: 'MOPIDY_GET_PLAYLIST',
data: { uri: uri }
2016-11-01 07:37:18 +13:00
}
}
2017-08-13 21:42:19 +12:00
export function getPlaylists(uris, processor = null){
return {
type: 'MOPIDY_GET_PLAYLISTS',
uris: uris,
processor: processor
}
}
export function getDirectory( uri ){
2016-11-01 11:49:04 +13:00
return {
type: 'MOPIDY_GET_DIRECTORY',
2017-07-07 08:25:58 +12:00
data: { uri: uri }
2016-11-01 11:49:04 +13:00
}
}
2017-08-13 21:42:19 +12:00
export function getLibraryArtists(){
return {
type: 'MOPIDY_GET_LIBRARY_ARTISTS'
}
}
2016-11-01 16:41:04 +13:00
export function getArtist( uri ){
return {
type: 'MOPIDY_GET_ARTIST',
2016-11-01 16:41:04 +13:00
data: { uri: uri }
}
}
2017-08-13 21:42:19 +12:00
export function getArtists(uris, processor = null){
2016-11-01 19:27:59 +13:00
return {
2017-08-13 21:42:19 +12:00
type: 'MOPIDY_GET_ARTISTS',
uris: uris,
processor: processor
2016-11-01 19:27:59 +13:00
}
}
2017-01-15 21:06:24 +13:00
export function getAlbum( uri ){
return {
type: 'MOPIDY_GET_ALBUM',
data: { uri: uri }
}
}
export function getAlbums(uris, processor = null){
return {
type: 'MOPIDY_GET_ALBUMS',
uris: uris,
processor: processor
}
}
2017-01-26 09:15:54 +13:00
export function getLibraryAlbums(){
return {
2017-01-26 09:15:54 +13:00
type: 'MOPIDY_GET_LIBRARY_ALBUMS'
}
}
export function runProcessor(processor){
return {
type: processor
}
}
export function cancelProcessor(processor){
return {
type: processor+'_CANCEL'
}
}
2016-11-06 18:29:49 +13:00
/**
2017-03-24 23:05:43 +13:00
* Searching
2016-11-06 18:29:49 +13:00
**/
2017-09-04 08:17:28 +12:00
export function getSearchResults(context, query, limit = 100){
2016-11-06 18:29:49 +13:00
return {
2017-09-04 08:17:28 +12:00
type: 'MOPIDY_GET_SEARCH_RESULTS',
context: context,
2017-03-24 23:05:43 +13:00
query: query,
2017-09-04 08:17:28 +12:00
limit: limit
2017-03-24 23:05:43 +13:00
}
}
/**
* Other general actions
**/
2017-02-10 09:06:41 +13:00
export function getQueueHistory(){
2017-05-19 11:33:06 +12:00
return instruct('history.getHistory')
2017-02-10 09:06:41 +13:00
}