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