2016-10-14 22:42:45 +13:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Actions and Action Creators
|
|
|
|
|
**/
|
|
|
|
|
|
2016-10-18 21:57:29 +13:00
|
|
|
export function setConfig( config ){
|
2016-10-14 22:42:45 +13:00
|
|
|
return {
|
2016-10-18 21:57:29 +13:00
|
|
|
type: 'MOPIDY_SET_CONFIG',
|
|
|
|
|
config: config
|
2016-10-14 22:42:45 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-18 21:57:29 +13:00
|
|
|
export function connect(){
|
2016-10-14 22:42:45 +13:00
|
|
|
return {
|
2016-10-18 21:57:29 +13:00
|
|
|
type: 'MOPIDY_CONNECT'
|
2016-10-16 12:37:37 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-18 21:57:29 +13:00
|
|
|
export function disconnect(){
|
2016-10-18 08:56:53 +13:00
|
|
|
return {
|
2016-10-18 21:57:29 +13:00
|
|
|
type: 'MOPIDY_DISCONNECT'
|
2016-10-18 08:56:53 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-21 23:27:50 +13:00
|
|
|
export function instruct( call, value ){
|
|
|
|
|
return {
|
|
|
|
|
type: 'MOPIDY_INSTRUCT',
|
|
|
|
|
call: call,
|
|
|
|
|
value: value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Playback-oriented actions
|
|
|
|
|
**/
|
|
|
|
|
|
2016-10-16 12:37:37 +13:00
|
|
|
export function changeTrack( tlid ){
|
|
|
|
|
return {
|
2016-10-21 09:56:07 +13:00
|
|
|
type: 'MOPIDY_INSTRUCT',
|
2016-10-16 12:37:37 +13:00
|
|
|
call: 'playback.play',
|
|
|
|
|
value: { tlid: tlid }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-19 14:09:34 +13:00
|
|
|
export function playTracks( uris ){
|
|
|
|
|
return {
|
|
|
|
|
type: 'MOPIDY_PLAY_TRACKS',
|
2016-10-20 21:38:01 +13:00
|
|
|
uris: uris
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function enqueueTracks( uris, at_position = false ){
|
2016-10-21 09:56:07 +13:00
|
|
|
if( typeof(uris) !== 'object' ) uris = [uris];
|
2016-10-20 21:38:01 +13:00
|
|
|
var value = { uris: uris };
|
|
|
|
|
if( at_position ) value.at_position = at_position;
|
|
|
|
|
return {
|
2016-10-21 09:56:07 +13:00
|
|
|
type: 'MOPIDY_INSTRUCT',
|
2016-10-19 14:09:34 +13:00
|
|
|
call: 'tracklist.add',
|
2016-10-20 21:38:01 +13:00
|
|
|
value: value
|
2016-10-19 14:09:34 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-16 12:37:37 +13:00
|
|
|
export function removeTracks( tlids ){
|
|
|
|
|
return {
|
2016-10-21 09:56:07 +13:00
|
|
|
type: 'MOPIDY_INSTRUCT',
|
2016-10-16 12:37:37 +13:00
|
|
|
call: 'tracklist.remove',
|
|
|
|
|
value: { tlid: tlids }
|
2016-10-14 22:42:45 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-20 21:38:01 +13:00
|
|
|
export function play(){
|
|
|
|
|
return instruct('playback.play');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function pause(){
|
|
|
|
|
return instruct('playback.pause');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function next(){
|
|
|
|
|
return instruct('playback.next');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function previous(){
|
|
|
|
|
return instruct('playback.previous');
|
|
|
|
|
}
|
2016-10-21 23:27:50 +13:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Asset-oriented actions
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
export function getPlaylists(){
|
|
|
|
|
return { type: 'MOPIDY_PLAYLISTS' }
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-02 16:51:00 +13:00
|
|
|
export function getPlaylist( uri ){
|
|
|
|
|
return {
|
|
|
|
|
type: 'MOPIDY_PLAYLIST',
|
|
|
|
|
data: { uri: uri }
|
2016-11-01 07:37:18 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-02 16:51:00 +13:00
|
|
|
export function getDirectory( uri ){
|
2016-11-01 11:49:04 +13:00
|
|
|
return {
|
2016-11-02 16:51:00 +13:00
|
|
|
type: 'MOPIDY_DIRECTORY',
|
2016-11-01 11:49:04 +13:00
|
|
|
data: { uri: uri }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-01 13:19:51 +13:00
|
|
|
export function getAlbum( uri ){
|
|
|
|
|
return {
|
|
|
|
|
type: 'MOPIDY_ALBUM',
|
|
|
|
|
data: { uri: uri }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-01 16:41:04 +13:00
|
|
|
export function getArtist( uri ){
|
|
|
|
|
return {
|
|
|
|
|
type: 'MOPIDY_ARTIST',
|
|
|
|
|
data: { uri: uri }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-01 19:27:59 +13:00
|
|
|
export function getArtists(){
|
|
|
|
|
return {
|
|
|
|
|
type: 'MOPIDY_ARTISTS'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-02 16:51:00 +13:00
|
|
|
export function getAlbums(){
|
|
|
|
|
return {
|
|
|
|
|
type: 'MOPIDY_ALBUMS'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|