Skip to content

Commit

Permalink
Merge pull request #95 from esamarathon/feat/omnibar-current-track
Browse files Browse the repository at this point in the history
Add music track to omnibar options
  • Loading branch information
zoton2 authored Feb 11, 2024
2 parents 6103181 + b7dc4c6 commit 06559f1
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,4 @@ streamdeck-plugin/com.esamarathon.streamdeck.sdPlugin
streamdeck-plugin/DistributionTool.exe
*.psd
/boxart/
.idea/
3 changes: 2 additions & 1 deletion schemas/omnibar.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"UpcomingRun",
"Prize",
"Bid",
"Milestone"
"Milestone",
"MusicTrack"
]
},
"alerts": {
Expand Down
5 changes: 4 additions & 1 deletion src/browser_shared/replicant_store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Bids, BigbuttonPlayerMap, Commentators, Countdown, CurrentRunDelay, DonationAlerts, DonationReader, DonationTotal, DonationTotalMilestones, DonationsToRead, GameLayouts, IntermissionSlides, ObsData, Omnibar, OtherStreamData, Prizes, ReaderIntroduction, ServerTimestamp, StreamDeckData, TtsVoices, UpcomingRunID, VideoPlayer } from '@esa-layouts/types/schemas';
import type { Bids, BigbuttonPlayerMap, Commentators, Countdown, CurrentRunDelay, DonationAlerts, DonationReader, DonationTotal, DonationTotalMilestones, DonationsToRead, GameLayouts, IntermissionSlides, MusicData, ObsData, Omnibar, OtherStreamData, Prizes, ReaderIntroduction, ServerTimestamp, StreamDeckData, TtsVoices, UpcomingRunID, VideoPlayer } from '@esa-layouts/types/schemas';
import type NodeCGTypes from '@nodecg/types';
import clone from 'clone';
import { SpeedcontrolUtilBrowser } from 'speedcontrol-util';
Expand Down Expand Up @@ -28,6 +28,7 @@ export const reps: {
donationTotalMilestones: NodeCGTypes.ClientReplicant<DonationTotalMilestones>;
gameLayouts: NodeCGTypes.ClientReplicant<GameLayouts>;
intermissionSlides: NodeCGTypes.ClientReplicant<IntermissionSlides>;
musicData: NodeCGTypes.ClientReplicant<MusicData>;
obsData: NodeCGTypes.ClientReplicant<ObsData>;
omnibar: NodeCGTypes.ClientReplicant<Omnibar>;
otherStreamData: NodeCGTypes.ClientReplicant<OtherStreamData>;
Expand Down Expand Up @@ -59,6 +60,7 @@ export const reps: {
donationTotalMilestones: nodecg.Replicant('donationTotalMilestones'),
gameLayouts: nodecg.Replicant('gameLayouts'),
intermissionSlides: nodecg.Replicant('intermissionSlides'),
musicData: nodecg.Replicant('musicData'),
obsData: nodecg.Replicant('obsData'),
omnibar: nodecg.Replicant('omnibar'),
otherStreamData: nodecg.Replicant('otherStreamData'),
Expand Down Expand Up @@ -92,6 +94,7 @@ export interface ReplicantTypes {
donationTotalMilestones: DonationTotalMilestones;
gameLayouts: GameLayouts;
intermissionSlides: IntermissionSlides;
musicData: MusicData;
obsData: ObsData;
omnibar: Omnibar;
otherStreamData: OtherStreamData;
Expand Down
29 changes: 29 additions & 0 deletions src/dashboard/omnibar-ticker-control/components/MusicTrack.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<v-card class="pa-2">
<speed-dial :id="id" />
<div>
<span class="font-weight-bold">Type:</span>
Current song
</div>
<div>
<span class="font-weight-bold">Length:</span>
{{ seconds }} seconds
</div>
</v-card>
</template>

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';
import SpeedDial from './SpeedDial.vue';
@Component({
name: 'UpcomingRun',
components: {
SpeedDial,
},
})
export default class extends Vue {
@Prop({ type: String, required: true }) readonly id!: string;
@Prop({ type: Number, default: 25 }) readonly seconds!: number;
}
</script>
6 changes: 6 additions & 0 deletions src/dashboard/omnibar-ticker-control/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import GenericMsg from './components/GenericMsg.vue';
import Milestone from './components/Milestone.vue';
import Prize from './components/Prize.vue';
import UpcomingRun from './components/UpcomingRun.vue';
import MusicTrack from './components/MusicTrack.vue';
import { storeModule } from './store';
@Component({
Expand All @@ -103,6 +104,7 @@ import { storeModule } from './store';
Milestone,
Prize,
UpcomingRun,
MusicTrack,
},
})
export default class OmnibarTickerControl extends Vue {
Expand All @@ -112,6 +114,10 @@ export default class OmnibarTickerControl extends Vue {
key: 'GenericMsg',
name: 'Generic Message',
},
{
key: 'MusicTrack',
name: 'Current song',
},
{
key: 'Bid',
name: 'Random Bid (favours sooner)',
Expand Down
2 changes: 2 additions & 0 deletions src/graphics/omnibar/components/Ticker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import UpcomingRun from './Ticker/UpcomingRun.vue';
import Prize from './Ticker/Prize.vue';
import Bid from './Ticker/Bid.vue';
import Milestone from './Ticker/Milestone.vue';
import MusicTrack from './Ticker/MusicTrack.vue';
@Component({
components: {
Expand All @@ -44,6 +45,7 @@ import Milestone from './Ticker/Milestone.vue';
UpcomingRun,
Prize,
Milestone,
MusicTrack,
Bid,
},
})
Expand Down
48 changes: 48 additions & 0 deletions src/graphics/omnibar/components/Ticker/MusicTrack.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<template>
<div
class="Flex"
:style="{
'font-size': '33px',
'white-space': 'nowrap',
'font-weight': 500,
'text-align': 'center',
'line-height': '100%',
}"
>
<span>🎵 {{ trackInformation }}</span>
</div>
</template>

<script lang="ts">
import { replicantNS } from '@esa-layouts/browser_shared/replicant_store';
import { wait } from '@esa-layouts/graphics/_misc/helpers';
import { Vue, Component, Prop } from 'vue-property-decorator';
import { MusicData } from '@esa-layouts/types/schemas';
@Component({
name: 'MusicTrack',
})
export default class extends Vue {
@replicantNS.State((s) => s.reps.musicData) readonly musicData!: MusicData;
@Prop({ type: Number, default: 25 }) readonly seconds!: number;
get trackInformation(): string | undefined {
const info = [
this.musicData?.track?.title,
this.musicData?.track?.artist,
].filter(Boolean);
return info.length ? info.join(' - ') : undefined;
}
async created(): Promise<void> {
// Skip display if no track is playing
if (!this.trackInformation) {
this.$emit('end');
return;
}
await wait(this.seconds * 1000); // Wait the specified length.
this.$emit('end');
}
}
</script>
6 changes: 4 additions & 2 deletions src/types/schemas/omnibar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

export interface Omnibar {
rotation: {
type: 'GenericMsg' | 'UpcomingRun' | 'Prize' | 'Bid' | 'Milestone';
type: 'GenericMsg' | 'UpcomingRun' | 'Prize' | 'Bid' | 'Milestone' | 'MusicTrack';
id: string;
props?: Props;
}[];
Expand All @@ -19,7 +19,9 @@ export interface Omnibar {
};
}[];
current: {
type: ('GenericMsg' | 'UpcomingRun' | 'Prize' | 'Bid' | 'Milestone') | ('Tweet' | 'CrowdControl' | 'MiniCredits');
type:
| ('GenericMsg' | 'UpcomingRun' | 'Prize' | 'Bid' | 'Milestone' | 'MusicTrack')
| ('Tweet' | 'CrowdControl' | 'MiniCredits');
id: string;
props?: Props;
} | null;
Expand Down

0 comments on commit 06559f1

Please sign in to comment.