mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-13 08:33:01 -04:00
Update InstantScreenshare
This commit is contained in:
parent
c0b928f166
commit
2893466ba9
5 changed files with 60 additions and 22 deletions
|
@ -4,13 +4,34 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs, EquicordDevs } from "@utils/constants";
|
import { Devs, EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCode, findByProps } from "@webpack";
|
import { findByCode, findByProps } from "@webpack";
|
||||||
import { ChannelStore, SelectedChannelStore, UserStore } from "@webpack/common";
|
import { ChannelStore, SelectedChannelStore, UserStore } from "@webpack/common";
|
||||||
import { VoiceState } from "@webpack/types";
|
import { VoiceState } from "@webpack/types";
|
||||||
|
|
||||||
let hasStreamed = false;
|
const settings = definePluginSettings({
|
||||||
|
streamType: {
|
||||||
|
description: "Stream screen or window",
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
options: [
|
||||||
|
{ label: "Screen", value: "screen" },
|
||||||
|
{ label: "Window", value: "window" }
|
||||||
|
],
|
||||||
|
default: "screen"
|
||||||
|
},
|
||||||
|
streamWindowKeyword: {
|
||||||
|
description: "Keyword to search for in window title",
|
||||||
|
type: OptionType.STRING,
|
||||||
|
default: "",
|
||||||
|
placeholder: "Enter keyword"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let hasStreamed;
|
||||||
|
let sources;
|
||||||
|
let source;
|
||||||
|
|
||||||
async function startStream() {
|
async function startStream() {
|
||||||
const startStream = findByCode('type:"STREAM_START"');
|
const startStream = findByCode('type:"STREAM_START"');
|
||||||
|
@ -19,9 +40,18 @@ async function startStream() {
|
||||||
const selected = SelectedChannelStore.getVoiceChannelId();
|
const selected = SelectedChannelStore.getVoiceChannelId();
|
||||||
if (!selected) return;
|
if (!selected) return;
|
||||||
const channel = ChannelStore.getChannel(selected);
|
const channel = ChannelStore.getChannel(selected);
|
||||||
const sources = await getDesktopSources(mediaEngine, ["screen"], null);
|
|
||||||
if (!sources || sources.length === 0) return;
|
if (settings.store.streamType === "screen") {
|
||||||
const source = sources[0];
|
sources = await getDesktopSources(mediaEngine, ["screen"], null);
|
||||||
|
source = sources[0];
|
||||||
|
} else if (settings.store.streamType === "window") {
|
||||||
|
const keyword = settings.store.streamWindowKeyword?.toLowerCase();
|
||||||
|
sources = await getDesktopSources(mediaEngine, ["window", "application"], null);
|
||||||
|
source = sources.find(s => s.name?.toLowerCase().includes(keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!source) return;
|
||||||
|
|
||||||
startStream(channel.guild_id, selected, {
|
startStream(channel.guild_id, selected, {
|
||||||
"pid": null,
|
"pid": null,
|
||||||
"sourceId": source.id,
|
"sourceId": source.id,
|
||||||
|
@ -34,8 +64,9 @@ async function startStream() {
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "InstantScreenshare",
|
name: "InstantScreenshare",
|
||||||
description: "Instantly screenshare your first screen when joining a voice channel",
|
description: "Instantly screenshare when joining a voice channel",
|
||||||
authors: [Devs.HAHALOSAH, EquicordDevs.thororen],
|
authors: [Devs.HAHALOSAH, EquicordDevs.thororen],
|
||||||
|
settings,
|
||||||
flux: {
|
flux: {
|
||||||
async VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) {
|
async VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) {
|
||||||
const myId = UserStore.getCurrentUser().id;
|
const myId = UserStore.getCurrentUser().id;
|
||||||
|
|
|
@ -191,6 +191,7 @@ function SeekBar() {
|
||||||
{msToHuman(position)}
|
{msToHuman(position)}
|
||||||
</Forms.FormText>
|
</Forms.FormText>
|
||||||
<Menu.MenuSliderControl
|
<Menu.MenuSliderControl
|
||||||
|
key={position}
|
||||||
minValue={0}
|
minValue={0}
|
||||||
maxValue={duration}
|
maxValue={duration}
|
||||||
value={position}
|
value={position}
|
||||||
|
|
|
@ -99,8 +99,8 @@ export default definePlugin({
|
||||||
<ErrorBoundary
|
<ErrorBoundary
|
||||||
fallback={() => (
|
fallback={() => (
|
||||||
<div className="vc-spotify-fallback">
|
<div className="vc-spotify-fallback">
|
||||||
<p>Failed to render Spotify Modal</p>
|
<p>Failed to render Spotify Modal :(</p>
|
||||||
<p>Check the console for errors</p>
|
<p >Check the console for errors</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
|
||||||
#vc-spotify-player {
|
#vc-spotify-player {
|
||||||
padding: 0.375rem 0.5rem;
|
padding: 0.375rem 0.5rem;
|
||||||
border-bottom: 1px solid var(--background-modifier-accent);
|
border-bottom: 1px solid var(--background-modifier-accent);
|
||||||
|
|
||||||
--vc-spotify-green: var(--spotify, #1db954); /* so custom themes can easily change it */
|
--vc-spotify-green: var(--spotify, #1db954);
|
||||||
|
|
||||||
|
/* so custom themes can easily change it */
|
||||||
--vc-spotify-green-90: color-mix(in hsl, var(--vc-spotify-green), transparent 90%);
|
--vc-spotify-green-90: color-mix(in hsl, var(--vc-spotify-green), transparent 90%);
|
||||||
--vc-spotify-green-80: color-mix(in hsl, var(--vc-spotify-green), transparent 80%);
|
--vc-spotify-green-80: color-mix(in hsl, var(--vc-spotify-green), transparent 80%);
|
||||||
}
|
}
|
||||||
|
@ -150,17 +151,17 @@
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vc-spotify-progress-bar > [class^="slider"] {
|
#vc-spotify-progress-bar>[class^="slider"] {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vc-spotify-progress-bar > [class^="slider"] [class^="bar-"] {
|
#vc-spotify-progress-bar>[class^="slider"] [class^="bar-"] {
|
||||||
height: 4px !important;
|
height: 4px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vc-spotify-progress-bar > [class^="slider"] [class^="grabber"] {
|
#vc-spotify-progress-bar>[class^="slider"] [class^="grabber"] {
|
||||||
/* these importants are necessary, it applies a width and height through inline styles */
|
/* these importants are necessary, it applies a width and height through inline styles */
|
||||||
height: 10px !important;
|
height: 10px !important;
|
||||||
width: 10px !important;
|
width: 10px !important;
|
||||||
|
@ -172,7 +173,7 @@
|
||||||
transition: opacity 0.1s;
|
transition: opacity 0.1s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vc-spotify-progress-bar:hover > [class^="slider"] [class^="grabber"] {
|
#vc-spotify-progress-bar:hover>[class^="slider"] [class^="grabber"] {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-spotify-artist, .vc-spotify-album {
|
.vc-spotify-artist,
|
||||||
|
.vc-spotify-album {
|
||||||
color: var(--header-primary);
|
color: var(--header-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,26 +27,26 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vc-spotify-progress-bar > [class^="slider"] {
|
#vc-spotify-progress-bar>[class^="slider"] {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vc-spotify-progress-bar > [class^="slider"] [class^="bar"] {
|
#vc-spotify-progress-bar>[class^="slider"] [class^="bar"] {
|
||||||
height: 3px !important;
|
height: 3px !important;
|
||||||
top: calc(12px - 4px / 2 + var(--bar-offset));
|
top: calc(12px - 4px / 2 + var(--bar-offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
#vc-spotify-progress-bar > [class^="slider"] [class^="barFill"] {
|
#vc-spotify-progress-bar>[class^="slider"] [class^="barFill"] {
|
||||||
background-color: var(--interactive-active);
|
background-color: var(--interactive-active);
|
||||||
}
|
}
|
||||||
|
|
||||||
#vc-spotify-progress-bar > [class^="slider"]:hover [class^="barFill"] {
|
#vc-spotify-progress-bar>[class^="slider"]:hover [class^="barFill"] {
|
||||||
background-color: var(--vc-spotify-green);
|
background-color: var(--vc-spotify-green);
|
||||||
}
|
}
|
||||||
|
|
||||||
#vc-spotify-progress-bar > [class^="slider"] [class^="grabber"] {
|
#vc-spotify-progress-bar>[class^="slider"] [class^="grabber"] {
|
||||||
background-color: var(--interactive-active);
|
background-color: var(--interactive-active);
|
||||||
width: 16px !important;
|
width: 16px !important;
|
||||||
height: 16px !important;
|
height: 16px !important;
|
||||||
|
@ -67,11 +68,15 @@
|
||||||
border-radius: var(--radius-sm);
|
border-radius: var(--radius-sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-spotify-repeat-context, .vc-spotify-repeat-track, .vc-spotify-shuffle-on {
|
.vc-spotify-repeat-context,
|
||||||
|
.vc-spotify-repeat-track,
|
||||||
|
.vc-spotify-shuffle-on {
|
||||||
background-color: var(--vc-spotify-green-90);
|
background-color: var(--vc-spotify-green-90);
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-spotify-repeat-context:hover, .vc-spotify-repeat-track:hover, .vc-spotify-shuffle-on:hover {
|
.vc-spotify-repeat-context:hover,
|
||||||
|
.vc-spotify-repeat-track:hover,
|
||||||
|
.vc-spotify-shuffle-on:hover {
|
||||||
background-color: var(--vc-spotify-green-80);
|
background-color: var(--vc-spotify-green-80);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue