tracklisting

This commit is contained in:
Marks Polakovs 2020-04-13 14:14:42 +02:00
parent bebdd0186b
commit 86c29a997f
2 changed files with 12 additions and 2 deletions

View file

@ -1,6 +1,7 @@
import SdpTransform from "sdp-transform";
import * as DateFns from "date-fns";
import * as BroadcastState from "./state";
import * as MixerState from "../mixer/state";
import {
@ -8,6 +9,7 @@ import {
ConnectionStateListener,
ConnectionStateEnum
} from "./streamer";
import store from "../store";
type StreamerState = "HELLO" | "OFFER" | "ANSWER" | "CONNECTED";
@ -110,10 +112,13 @@ export class WebRTCStreamer extends Streamer {
now.getMinutes() >= 2 ||
(now.getMinutes() === 1 && now.getSeconds() < 50)
) {
const newsEndTime = DateFns.set(now, {
let newsEndTime = DateFns.set(now, {
minutes: 0,
seconds: 55
});
if (now.getMinutes() > 2) {
newsEndTime = DateFns.add(newsEndTime, { hours: 1 });
}
console.log("end time", newsEndTime);
const delta = newsEndTime.valueOf() - now.valueOf();
this.newsOutTimeout = window.setTimeout(async () => {
@ -181,10 +186,12 @@ export class WebRTCStreamer extends Streamer {
case "ACTIVATED":
this.isActive = true;
this.onStateChange("LIVE");
store.dispatch(BroadcastState.setTracklisting(true));
break;
case "DEACTIVATED":
this.isActive = false;
this.onStateChange(this.mapStateToConnectionState());
store.dispatch(BroadcastState.setTracklisting(false));
break;
case "DIED":
// oo-er

View file

@ -55,6 +55,9 @@ const broadcastState = createSlice({
toggleTracklisting(state) {
state.tracklisting = !state.tracklisting;
},
setTracklisting(state, action: PayloadAction<boolean>) {
state.tracklisting = action.payload;
},
setConnID(state, action: PayloadAction<number | null>) {
state.connID = action.payload;
if (action.payload != null) {
@ -202,7 +205,7 @@ export function sendBroadcastChange(
});
}
export const { toggleTracklisting } = broadcastState.actions;
export const { toggleTracklisting, setTracklisting } = broadcastState.actions;
export const tracklistStart = (
player: number,