Merge branch 'mstratford-broadcast-ui'

This commit is contained in:
Matthew Stratford 2020-03-28 15:32:15 +00:00
commit 33816488a3
2 changed files with 37 additions and 9 deletions

View file

@ -40,13 +40,13 @@ export const toggleTracklisting = (): AppThunk => dispatch => {
export const tracklistStart = (trackid: number): AppThunk =>(dispatch, getState) => {
console.log("Attempting to tracklist: " + trackid);
if (getState().broadcast.tracklisting) {
console.log(myradioApiRequest("/TracklistItem", "POST", { trackid: trackid, source: 'w', state: 'c' }));
return myradioApiRequest("/TracklistItem", "POST", { trackid: trackid, source: 'w', state: 'c' });
}
};
export const tracklistEnd = (trackid: number): AppThunk => (dispatch, getState) => {
console.log("Attempting to tracklist: " + trackid);
export const tracklistEnd = (tracklistitemid: number): AppThunk => (dispatch, getState) => {
console.log("Attempting to end tracklistitem: " + tracklistitemid);
if (getState().broadcast.tracklisting) {
myradioApiRequest("/TracklistItem", "POST", { trackid: trackid, source: 'w', state: 'c' });
myradioApiRequest("/TracklistItem/" + tracklistitemid + "/endtime", "PUT", { });
}
};

View file

@ -57,6 +57,7 @@ interface PlayerState {
playOnLoad: Boolean;
autoAdvance: Boolean;
repeat: PlayerRepeatEnum;
tracklistItemID: number;
}
interface MicState {
@ -87,7 +88,8 @@ const mixerState = createSlice({
timeLength: 0,
playOnLoad: false,
autoAdvance: true,
repeat: "none"
repeat: "none",
tracklistItemID: -1
},
{
loadedItem: null,
@ -101,7 +103,8 @@ const mixerState = createSlice({
timeLength: 0,
playOnLoad: false,
autoAdvance: true,
repeat: "none"
repeat: "none",
tracklistItemID: -1
},
{
loadedItem: null,
@ -115,7 +118,8 @@ const mixerState = createSlice({
timeLength: 0,
playOnLoad: false,
autoAdvance: true,
repeat: "none"
repeat: "none",
tracklistItemID: -1
}
],
mic: {
@ -238,6 +242,15 @@ const mixerState = createSlice({
break;
}
state.players[action.payload.player].repeat = playVal;
},
setTracklistItemID(
state,
action: PayloadAction<{
player: number,
id: number
}>
) {
state.players[action.payload.player].tracklistItemID = action.payload.id;
}
}
});
@ -297,6 +310,12 @@ export const load = (
wavesurfer.on("ready", () => {
dispatch(mixerState.actions.itemLoadComplete({ player }));
dispatch(
mixerState.actions.setTimeCurrent({
player,
time: 0
})
);
dispatch(
mixerState.actions.setTimeLength({
player,
@ -315,9 +334,10 @@ export const load = (
console.log(item);
if ("album" in item) {
//track
dispatch(
console.log(dispatch(
BroadcastState.tracklistStart(item.trackid)
);
));
//dispatch(mixerState.actions.setTracklistItemID({ player, id }));
}
@ -334,6 +354,9 @@ export const load = (
dispatch(
mixerState.actions.setPlayerState({ player, state: "stopped" })
);
console.log(dispatch(
BroadcastState.tracklistEnd(0)
));
const state = getState().mixer.players[player];
if (state.repeat === "one") {
wavesurfer.play();
@ -423,6 +446,11 @@ export const stop = (player: number): AppThunk => (dispatch, getState) => {
return;
}
wavesurfers[player].stop();
console.log(dispatch(
BroadcastState.tracklistEnd(0)
));
};
export const toggleAutoAdvance = (player: number): AppThunk => dispatch => {