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

267 lines
4.6 KiB
JavaScript
Raw Normal View History

import * as helpers from '../../helpers'
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
}
}
export function instruct( call, value ){
return {
type: 'MOPIDY_INSTRUCT',
call: call,
value: value
}
}
export function debug( call, value ){
return {
type: 'MOPIDY_DEBUG',
call: call,
value: value
}
}
/**
* Playback-oriented actions
**/
export function changeTrack( tlid ){
return {
type: 'MOPIDY_INSTRUCT',
call: 'playback.play',
value: { tlid: tlid }
}
}
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
}
}
2017-02-14 12:13:07 +13:00
export function enqueueURIsNext( uris, from_uri = null ){
if( typeof(uris) !== 'object' ) uris = [uris]
return {
type: 'MOPIDY_ENQUEUE_URIS_NEXT',
2017-02-14 12:13:07 +13:00
uris: uris,
from_uri: from_uri
}
}
2017-02-14 12:13:07 +13:00
export function enqueueURIs( uris, from_uri = null, at_position = false ){
return {
type: 'MOPIDY_ENQUEUE_URIS',
uris: uris,
at_position: at_position,
from_uri: from_uri
2016-10-19 14:09:34 +13:00
}
}
export function removeTracks( tlids ){
return {
type: 'MOPIDY_INSTRUCT',
call: 'tracklist.remove',
value: { 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(){
return instruct('tracklist.clear');
}
export function play(){
return instruct('playback.play');
}
export function pause(){
return instruct('playback.pause');
}
2016-11-03 18:22:26 +13:00
export function stop(){
return instruct('playback.stop');
}
export function next(){
return instruct('playback.next');
}
export function previous(){
return instruct('playback.previous');
}
2016-11-04 13:51:17 +13:00
export function setVolume( volume ){
return {
type: 'MOPIDY_INSTRUCT',
call: 'playback.setVolume',
value: { volume: volume }
}
}
2016-11-03 18:22:26 +13:00
export function seek( time_position ){
return {
type: 'MOPIDY_INSTRUCT',
call: 'playback.seek',
2017-03-27 15:03:30 +13:00
value: { time_position: parseInt(time_position) }
2016-11-03 18:22:26 +13:00
}
}
export function getTimePosition(){
return {
type: 'MOPIDY_INSTRUCT',
call: 'playback.getTimePosition'
}
}
2016-11-08 16:57:44 +13:00
export function setTimePosition( time_position ){
return {
type: 'MOPIDY_TIMEPOSITION',
data: time_position
}
}
/**
* Asset-oriented actions
**/
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
}
}
export function getDirectory( uri ){
2016-11-01 11:49:04 +13:00
return {
type: 'MOPIDY_GET_DIRECTORY',
2016-11-01 11:49:04 +13:00
data: { uri: uri }
}
}
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-01-26 09:15:54 +13:00
export function getLibraryArtists(){
2016-11-01 19:27:59 +13:00
return {
2017-01-26 09:15:54 +13:00
type: 'MOPIDY_GET_LIBRARY_ARTISTS'
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 ){
return {
type: 'MOPIDY_GET_ALBUMS',
uris: uris
}
}
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'
}
}
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
**/
export function getTrackSearchResults(query, limit = 100, uri_scheme){
2016-11-06 18:29:49 +13:00
return {
2017-03-24 23:05:43 +13:00
type: 'MOPIDY_GET_TRACK_SEARCH_RESULTS',
query: query,
limit: limit,
uri_scheme: uri_scheme
2016-11-06 18:29:49 +13:00
}
}
2017-02-10 09:06:41 +13:00
export function getArtistSearchResults(query, limit = 100, uri_scheme){
2017-03-24 16:06:49 +13:00
return {
type: 'MOPIDY_GET_ARTIST_SEARCH_RESULTS',
2017-03-24 23:05:43 +13:00
query: query,
limit: limit,
uri_scheme: uri_scheme
2017-03-24 23:05:43 +13:00
}
}
export function getAlbumSearchResults(query, limit = 100, uri_scheme){
2017-03-24 23:05:43 +13:00
return {
type: 'MOPIDY_GET_ALBUM_SEARCH_RESULTS',
query: query,
limit: limit,
uri_scheme: uri_scheme
2017-03-24 16:06:49 +13:00
}
}
export function getPlaylistSearchResults(query, limit = 100, uri_scheme){
2017-03-24 23:05:43 +13:00
return {
type: 'MOPIDY_GET_PLAYLIST_SEARCH_RESULTS',
query: query,
limit: limit,
uri_scheme: uri_scheme
2017-03-24 23:05:43 +13:00
}
}
/**
* Other general actions
**/
2017-02-10 09:06:41 +13:00
export function getQueueHistory(){
return {
type: 'MOPIDY_INSTRUCT',
call: 'history.getHistory'
}
}