Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
хуетень ебанная, во первых онли фор спотик, во вторых смысл этой хуйни спрашивается
Смотрите видео ниже, чтобы узнать, как установить наш сайт в качестве веб-приложения на домашнем экране.
Примечание: Эта возможность может быть недоступна в некоторых браузерах.
хуетень ебанная, во первых онли фор спотик, во вторых смысл этой хуйни спрашивается
типа красива свитяшке, а так, если бы была норм либка(а не ток для спотика) то можно было бы переключать в теорииво вторых смысл этой хуйни спрашивается
Дай пж DisplayUtils.newrect и DisplayUtils.drawRoundedOutlineхуетень ебанная, во первых онли фор спотик, во вторых смысл этой хуйни спрашивается
да бля, я просто не понимаю нахуя засорять экран всяким бесполезным мусором, в одном клиенте вообще 15 разных поебатеней в худе видел, это пиздецтипа красива свитяшке, а так, если бы была норм либка(а не ток для спотика) то можно было бы переключать в теории
Можешь утилку дать?типа красива свитяшке, а так, если бы была норм либка(а не ток для спотика) то можно было бы переключать в теории
пицот рублейМожешь утилку дать?
"чел сливает киллку на юг" чел: хуня ибо это онли киллка, ты должен был скинуть сурсы. Cколько длится песня нельзя получить из за либок, тут все зависит от либки, что позволяет либка, то и использую максимум, я предоставил возможность такую для спотика, дальше рендером сами хуярьтесь, я не буду на блюдочке все давать ибо я хотел слить онли функциональностьПасиба бро
Хуйня ибо только на спотифай
Рендер дрист полный, думаю тут итак понятно
Нет рендера хотя бы статичной картинки "иконки" музыки
Исполнитель и название песни в одной строке
В длительности пишется сколько длится песня (можно заменить на текущее время/макс время или отрисовать полосочку
"название темы: SPOTIFY", чел: хуетень потому что это онли спотикхуетень ебанная, во первых онли фор спотик, во вторых смысл этой хуйни спрашивается
у меня даже светяшке нету ты о чемтипа красива свитяшке
дай аннотейшн native пж и шрифтss:
Посмотреть вложение 300484
Посмотреть вложение 300485
library:Пожалуйста, авторизуйтесь для просмотра ссылки.
util:
Java:package im.quantum.utils.spotify; import de.labystudio.spotifyapi.SpotifyAPI; import de.labystudio.spotifyapi.SpotifyAPIFactory; import de.labystudio.spotifyapi.SpotifyListener; import de.labystudio.spotifyapi.model.Track; import lombok.Getter; import java.time.Duration; import quantumprotect.annotations.Native; @Native public class SpotifyUtil { private static final SpotifyAPI api = SpotifyAPIFactory.create(); @Getter private static Track currentTrack; private static boolean isPlaying; @Getter private static int currentPosition; static { api.registerListener(new SpotifyListener() { @Override public void onConnect() { // System.out.println("Connected to Spotify!"); } @Override public void onTrackChanged(Track track) { currentTrack = track; // System.out.printf("Track changed: %s (%s)\n", track.getArtist() + " - " + track.getName(), formatDuration(Duration.ofMillis(track.getLength()))); } @Override public void onPositionChanged(int position) { if (!api.hasTrack()) { return; } int length = api.getTrack().getLength(); float percentage = 100.0F / length * position; // System.out.printf( // "Position changed: %s of %s (%d%%)\n", // formatDuration(Duration.ofSeconds(position)), // formatDuration(Duration.ofSeconds(length)), // (int) percentage // ); } @Override public void onPlayBackChanged(boolean playing) { isPlaying = playing; System.out.println(playing ? "Song started playing" : "Song stopped playing"); } @Override public void onSync() {} @Override public void onDisconnect(Exception exception) { System.out.println("Disconnected: " + exception.getMessage()); } }); api.initialize(); } public static String getCurrentTrackInfo() { if (currentTrack == null) return "Трек не найден"; return currentTrack.getArtist() + " - " + currentTrack.getName(); } public static String getCurrentListeningTime() { return formatDuration(Duration.ofMillis(currentPosition)); } public static boolean isPlaying() { return isPlaying; } public static String getCurrentTrackDuration() { if (currentTrack == null) return "Длительность: неизвестно"; return formatDuration(Duration.ofMillis(currentTrack.getLength())); } public static String formatDuration(Duration duration) { long seconds = duration.getSeconds(); long minutes = seconds / 60; seconds %= 60; return String.format("%02d:%02d", minutes, seconds); } }
render:
модеры одобрите тему пжпжпжпJava:package im.quantum.ui.display.impl; import com.mojang.blaze3d.matrix.MatrixStack; import im.quantum.events.EventDisplay; import im.quantum.functions.impl.Interface.HUD; import im.quantum.ui.display.ElementRenderer; import im.quantum.utils.animations.impl.DecelerateAnimation; import im.quantum.utils.drag.Dragging; import im.quantum.utils.render.DisplayUtils; import im.quantum.utils.render.font.Fonts; import im.quantum.utils.spotify.SpotifyUtil; import lombok.AccessLevel; import lombok.RequiredArgsConstructor; import lombok.experimental.FieldDefaults; import net.minecraft.util.math.vector.Vector4f; import ru.hogoshi.Animation; import quantumprotect.annotations.Native; @Native @FieldDefaults(level = AccessLevel.PRIVATE) @RequiredArgsConstructor public class SpotifyRenderer implements ElementRenderer { final Dragging dragging; float width; float height; @Override public void render(EventDisplay eventDisplay) { MatrixStack ms = eventDisplay.getMatrixStack(); float posX = dragging.getX(); float posY = dragging.getY(); String duration = "Длительность: " + /*SpotifyUtil.getCurrentPosition() + " : " + */SpotifyUtil.getCurrentTrackDuration(); String dNotFound = "Длительность: неизвестно"; String notFound = "Трек не найден"; float nameWidth = Fonts.sSB.getWidth(SpotifyUtil.getCurrentTrackInfo(), 8.5f); float nameNotFound = Fonts.sSB.getWidth("Трек не найден", 8.5f); float nameHeight = Fonts.sSB.getHeight(8.5f); float padding = 5; float durationWidth = Fonts.sSB.getWidth(duration, 8.5f); float durationNotFound = Fonts.sSB.getWidth("Длительность: неизвестно", 8.5f); DisplayUtils.newrect(posX, posY, width, height, new Vector4f(5, 5, 5, 5), 190); DisplayUtils.drawRoundedOutline(posX - 0.25f, posY, width, height, 5, 1, HUD.getColor(90, 1.5f)); if(SpotifyUtil.isPlaying()) { if(nameWidth>durationWidth){ width = padding*2 + nameWidth; } else{ width = padding*2 + durationWidth; } height = padding*2 + nameHeight*2 + padding; Fonts.sSB.drawText(ms, SpotifyUtil.getCurrentTrackInfo(), posX + width/2 - nameWidth/2, posY + padding, -1, 8.5f); Fonts.sSB.drawText(ms, duration, posX + width/2 - durationWidth/2, posY + padding + nameHeight + padding, -1, 8.5f); } else { width = padding*2 + nameNotFound; height = padding*2 + nameHeight; Fonts.sSB.drawText(ms, notFound, posX + padding, posY + padding, -1, 8.5f); } dragging.setWidth(width); dragging.setHeight(height); } }
зачем тебе аннотация, это для нативки мне надодай аннотейшн native пж и шрифт
где говно код? утилка с гитхаба, в рендере все норм, укажи где говнокод, а то я не понял/del говно код
у тебя есть норм либка которая не только для спотифай? если есть можешь слить)типа красива свитяшке, а так, если бы была норм либка(а не ток для спотика) то можно было бы переключать в теории
пицот рублейу тебя есть норм либка которая не только для спотифай? если есть можешь слить)
6р могу датьпицот рублей
А что нужно, типо ну смену цвета максимум да и про 3 тема так и подписана spotify render1. в твоем коде 0 функционала
2. говно код
3. работает только для спотифая
итог: говнище
package im.quantum.utils.media;
import de.labystudio.spotifyapi.SpotifyAPI;
import de.labystudio.spotifyapi.SpotifyAPIFactory;
import de.labystudio.spotifyapi.SpotifyListener;
import de.labystudio.spotifyapi.model.Track;
import lombok.Getter;
import java.time.Duration;
import quantumprotect.annotations.Native;
@Native
public class MediaUtil {
private static final SpotifyAPI spotifyApi = SpotifyAPIFactory.create();
@Getter
private static Track currentSpotifyTrack;
@Getter
private static String currentYoutubeTitle;
private static boolean isSpotifyPlaying;
private static boolean isYoutubePlaying;
@Getter
private static int currentSpotifyPosition;
@Getter
private static int currentYoutubePosition;
@Getter
private static int currentYoutubeLength;
@Getter
private static MediaSource currentSource = MediaSource.NONE;
public enum MediaSource {
SPOTIFY,
YOUTUBE,
NONE
}
static {
spotifyApi.registerListener(new SpotifyListener() {
@Override
public void onConnect() {
currentSource = MediaSource.SPOTIFY;
}
@Override
public void onTrackChanged(Track track) {
currentSpotifyTrack = track;
currentSource = MediaSource.SPOTIFY;
}
@Override
public void onPositionChanged(int position) {
if (!spotifyApi.hasTrack()) {
return;
}
currentSpotifyPosition = position;
}
@Override
public void onPlayBackChanged(boolean playing) {
isSpotifyPlaying = playing;
if (playing) {
currentSource = MediaSource.SPOTIFY;
} else if (currentSource == MediaSource.SPOTIFY) {
currentSource = isYoutubePlaying ? MediaSource.YOUTUBE : MediaSource.NONE;
}
}
@Override
public void onSync() {}
@Override
public void onDisconnect(Exception exception) {
if (currentSource == MediaSource.SPOTIFY) {
currentSource = isYoutubePlaying ? MediaSource.YOUTUBE : MediaSource.NONE;
}
}
});
spotifyApi.initialize();
// YouTube initialization would go here
initializeYouTube();
}
private static void initializeYouTube() {
// This would be implemented with a proper YouTube API
// For now, providing a dummy implementation that can be replaced later
}
// YouTube integration methods
public static void updateYouTubeStatus(String title, int position, int length, boolean playing) {
currentYoutubeTitle = title;
currentYoutubePosition = position;
currentYoutubeLength = length;
isYoutubePlaying = playing;
if (playing && (currentSource == MediaSource.NONE || currentSource == MediaSource.YOUTUBE)) {
currentSource = MediaSource.YOUTUBE;
} else if (!playing && currentSource == MediaSource.YOUTUBE) {
currentSource = isSpotifyPlaying ? MediaSource.SPOTIFY : MediaSource.NONE;
}
}
// Player control actions
public static void playPause() {
if (currentSource == MediaSource.SPOTIFY) {
// Toggle Spotify playback
// spotifyApi.playPause(); - implement if API supports this
} else if (currentSource == MediaSource.YOUTUBE) {
// Toggle YouTube playback
// Implement YouTube playback toggle
}
}
public static void skip() {
if (currentSource == MediaSource.SPOTIFY) {
// Skip Spotify track
// spotifyApi.next(); - implement if API supports this
} else if (currentSource == MediaSource.YOUTUBE) {
// Skip YouTube video
// Implement YouTube skip
}
}
public static void previous() {
if (currentSource == MediaSource.SPOTIFY) {
// Previous Spotify track
// spotifyApi.previous(); - implement if API supports this
} else if (currentSource == MediaSource.YOUTUBE) {
// Previous YouTube video
// Implement YouTube previous
}
}
public static String getCurrentTrackInfo() {
if (currentSource == MediaSource.SPOTIFY) {
if (currentSpotifyTrack == null) return "Трек не найден";
return currentSpotifyTrack.getArtist() + " - " + currentSpotifyTrack.getName();
} else if (currentSource == MediaSource.YOUTUBE) {
if (currentYoutubeTitle == null) return "Видео не найдено";
return currentYoutubeTitle;
}
return "Медиа не найдено";
}
public static String getCurrentListeningTime() {
if (currentSource == MediaSource.SPOTIFY) {
return formatDuration(Duration.ofMillis(currentSpotifyPosition));
} else if (currentSource == MediaSource.YOUTUBE) {
return formatDuration(Duration.ofMillis(currentYoutubePosition));
}
return "00:00";
}
public static boolean isPlaying() {
return currentSource == MediaSource.SPOTIFY ? isSpotifyPlaying :
currentSource == MediaSource.YOUTUBE ? isYoutubePlaying : false;
}
public static String getCurrentTrackDuration() {
if (currentSource == MediaSource.SPOTIFY) {
if (currentSpotifyTrack == null) return "Длительность: неизвестно";
return formatDuration(Duration.ofMillis(currentSpotifyTrack.getLength()));
} else if (currentSource == MediaSource.YOUTUBE) {
return formatDuration(Duration.ofMillis(currentYoutubeLength));
}
return "Длительность: неизвестно";
}
public static String formatDuration(Duration duration) {
long seconds = duration.getSeconds();
long minutes = seconds / 60;
seconds %= 60;
return String.format("%02d:%02d", minutes, seconds);
}
}
package im.quantum.ui.display.impl;
import com.mojang.blaze3d.matrix.MatrixStack;
import im.quantum.events.EventDisplay;
import im.quantum.functions.impl.Interface.HUD;
import im.quantum.ui.display.ElementRenderer;
import im.quantum.utils.animations.impl.DecelerateAnimation;
import im.quantum.utils.drag.Dragging;
import im.quantum.utils.render.DisplayUtils;
import im.quantum.utils.render.font.Fonts;
import im.quantum.utils.media.MediaUtil;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.util.math.vector.Vector4f;
import ru.hogoshi.Animation;
import quantumprotect.annotations.Native;
@Native
@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class MediaRenderer implements ElementRenderer {
final Dragging dragging;
float width;
float height;
// Animation for buttons
Animation playPauseHoverAnimation = new DecelerateAnimation(250, false);
Animation skipHoverAnimation = new DecelerateAnimation(250, false);
Animation previousHoverAnimation = new DecelerateAnimation(250, false);
boolean playPauseHover = false;
boolean skipHover = false;
boolean previousHover = false;
@Override
public void render(EventDisplay eventDisplay) {
MatrixStack ms = eventDisplay.getMatrixStack();
float posX = dragging.getX();
float posY = dragging.getY();
String duration = "Длительность: " + MediaUtil.getCurrentTrackDuration();
String dNotFound = "Длительность: неизвестно";
String notFound = "Медиа не найдено";
float nameWidth = Fonts.sSB.getWidth(MediaUtil.getCurrentTrackInfo(), 8.5f);
float nameNotFound = Fonts.sSB.getWidth(notFound, 8.5f);
float nameHeight = Fonts.sSB.getHeight(8.5f);
float padding = 5;
float durationWidth = Fonts.sSB.getWidth(duration, 8.5f);
float durationNotFound = Fonts.sSB.getWidth(dNotFound, 8.5f);
// Calculate button sizes
float buttonSize = nameHeight + 4;
float buttonsWidth = buttonSize * 3 + padding * 2; // 3 buttons with padding between them
// Update animations
playPauseHoverAnimation.setValue(playPauseHover ? 1 : 0);
skipHoverAnimation.setValue(skipHover ? 1 : 0);
previousHoverAnimation.setValue(previousHover ? 1 : 0);
// Calculate width and height based on content
if (MediaUtil.isPlaying()) {
width = padding * 2 + Math.max(Math.max(nameWidth, durationWidth), buttonsWidth);
height = padding * 2 + nameHeight * 2 + padding + buttonSize + padding;
} else {
width = padding * 2 + Math.max(nameNotFound, durationNotFound);
height = padding * 2 + nameHeight;
}
// Draw background
DisplayUtils.newrect(posX, posY, width, height, new Vector4f(5, 5, 5, 5), 190);
DisplayUtils.drawRoundedOutline(posX - 0.25f, posY, width, height, 5, 1, HUD.getColor(90, 1.5f));
if (MediaUtil.isPlaying()) {
// Draw track info
Fonts.sSB.drawText(ms, MediaUtil.getCurrentTrackInfo(), posX + width/2 - nameWidth/2, posY + padding, -1, 8.5f);
Fonts.sSB.drawText(ms, duration, posX + width/2 - durationWidth/2, posY + padding + nameHeight + padding, -1, 8.5f);
// Draw control buttons
float buttonsY = posY + padding + nameHeight * 2 + padding;
float buttonsStartX = posX + width/2 - buttonsWidth/2;
// Previous button
float prevX = buttonsStartX;
drawButton(ms, prevX, buttonsY, buttonSize, "◄", previousHoverAnimation.getValue());
// Play/Pause button
float playX = prevX + buttonSize + padding;
drawButton(ms, playX, buttonsY, buttonSize, MediaUtil.isPlaying() ? "⏸" : "►", playPauseHoverAnimation.getValue());
// Skip button
float skipX = playX + buttonSize + padding;
drawButton(ms, skipX, buttonsY, buttonSize, "►|", skipHoverAnimation.getValue());
// Handle button hover states
float mouseX = eventDisplay.getMouseX();
float mouseY = eventDisplay.getMouseY();
previousHover = isHovering(mouseX, mouseY, prevX, buttonsY, buttonSize, buttonSize);
playPauseHover = isHovering(mouseX, mouseY, playX, buttonsY, buttonSize, buttonSize);
skipHover = isHovering(mouseX, mouseY, skipX, buttonsY, buttonSize, buttonSize);
// Handle button clicks
if (eventDisplay.isLeftClicked()) {
if (previousHover) {
MediaUtil.previous();
} else if (playPauseHover) {
MediaUtil.playPause();
} else if (skipHover) {
MediaUtil.skip();
}
}
} else {
Fonts.sSB.drawText(ms, notFound, posX + width/2 - nameNotFound/2, posY + padding, -1, 8.5f);
}
dragging.setWidth(width);
dragging.setHeight(height);
}
private void drawButton(MatrixStack ms, float x, float y, float size, String symbol, float hoverProgress) {
// Draw button background with hover effect
int baseColor = 0x505050;
int hoverColor = HUD.getColor(90, 1.5f);
int blendedColor = blendColors(baseColor, hoverColor, hoverProgress);
DisplayUtils.newrect(x, y, size, size, new Vector4f(3, 3, 3, 3), blendedColor);
// Draw symbol
float symbolWidth = Fonts.sSB.getWidth(symbol, 10f);
float symbolHeight = Fonts.sSB.getHeight(10f);
Fonts.sSB.drawText(ms, symbol, x + size/2 - symbolWidth/2, y + size/2 - symbolHeight/2, -1, 10f);
}
private boolean isHovering(float mouseX, float mouseY, float x, float y, float width, float height) {
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
}
private int blendColors(int color1, int color2, float blendFactor) {
int r1 = (color1 >> 16) & 0xFF;
int g1 = (color1 >> 8) & 0xFF;
int b1 = color1 & 0xFF;
int r2 = (color2 >> 16) & 0xFF;
int g2 = (color2 >> 8) & 0xFF;
int b2 = color2 & 0xFF;
int r = (int) (r1 + (r2 - r1) * blendFactor);
int g = (int) (g1 + (g2 - g1) * blendFactor);
int b = (int) (b1 + (b2 - b1) * blendFactor);
return (r << 16) | (g << 8) | b;
}
}
package im.quantum.ui.chat;
import com.mojang.blaze3d.matrix.MatrixStack;
import im.quantum.functions.impl.Interface.HUD;
import im.quantum.utils.animations.impl.DecelerateAnimation;
import im.quantum.utils.render.DisplayUtils;
import im.quantum.utils.render.font.Fonts;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.util.math.vector.Vector4f;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import ru.hogoshi.Animation;
import quantumprotect.annotations.Native;
@Native
public class ChatButtons {
private static final Animation skipButtonHover = new DecelerateAnimation(250, false);
private static final Animation playPauseButtonHover = new DecelerateAnimation(250, false);
private static boolean skipHovered = false;
private static boolean playPauseHovered = false;
@SubscribeEvent
public static void onGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) {
if (!(event.getGui() instanceof ChatScreen)) return;
ChatScreen chatScreen = (ChatScreen) event.getGui();
MatrixStack ms = event.getMatrixStack();
int mouseX = event.getMouseX();
int mouseY = event.getMouseY();
int width = Minecraft.getInstance().getMainWindow().getScaledWidth();
int height = Minecraft.getInstance().getMainWindow().getScaledHeight();
// Button dimensions
int buttonWidth = 80;
int buttonHeight = 20;
int padding = 5;
// Skip button
int skipX = width - buttonWidth - padding;
int skipY = height - 50; // Position above chat input
// Play/Pause button
int playPauseX = skipX - buttonWidth - padding;
int playPauseY = skipY;
// Update hover states
skipHovered = isHovering(mouseX, mouseY, skipX, skipY, buttonWidth, buttonHeight);
playPauseHovered = isHovering(mouseX, mouseY, playPauseX, playPauseY, buttonWidth, buttonHeight);
skipButtonHover.setValue(skipHovered ? 1 : 0);
playPauseButtonHover.setValue(playPauseHovered ? 1 : 0);
// Draw buttons
drawButton(ms, skipX, skipY, buttonWidth, buttonHeight, "Пропустить", skipButtonHover.getValue());
drawButton(ms, playPauseX, playPauseY, buttonWidth, buttonHeight, "Запустить/Выключить", playPauseButtonHover.getValue());
}
@SubscribeEvent
public static void onGuiMouseClicked(GuiScreenEvent.MouseClickedEvent.Pre event) {
if (!(event.getGui() instanceof ChatScreen)) return;
if (event.getButton() == 0) { // Left click
if (skipHovered) {
// Handle skip button click
// Implement the action to skip
event.setCanceled(true);
} else if (playPauseHovered) {
// Handle play/pause button click
// Implement the action to play/pause
event.setCanceled(true);
}
}
}
private static void drawButton(MatrixStack ms, int x, int y, int width, int height, String text, float hoverProgress) {
// Draw button background with hover effect
int baseColor = 0x50505050;
int hoverColor = HUD.getColor(90, 1.5f);
int blendedColor = blendColors(baseColor, hoverColor, hoverProgress);
DisplayUtils.newrect(x, y, width, height, new Vector4f(3, 3, 3, 3), blendedColor);
// Draw text
float textWidth = Fonts.sSB.getWidth(text, 8.5f);
float textHeight = Fonts.sSB.getHeight(8.5f);
Fonts.sSB.drawText(ms, text, x + width/2 - textWidth/2, y + height/2 - textHeight/2, -1, 8.5f);
}
private static boolean isHovering(int mouseX, int mouseY, int x, int y, int width, int height) {
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
}
private static int blendColors(int color1, int color2, float blendFactor) {
int a1 = (color1 >> 24) & 0xFF;
int r1 = (color1 >> 16) & 0xFF;
int g1 = (color1 >> 8) & 0xFF;
int b1 = color1 & 0xFF;
int a2 = (color2 >> 24) & 0xFF;
int r2 = (color2 >> 16) & 0xFF;
int g2 = (color2 >> 8) & 0xFF;
int b2 = color2 & 0xFF;
int a = (int) (a1 + (a2 - a1) * blendFactor);
int r = (int) (r1 + (r2 - r1) * blendFactor);
int g = (int) (g1 + (g2 - g1) * blendFactor);
int b = (int) (b1 + (b2 - b1) * blendFactor);
return (a << 24) | (r << 16) | (g << 8) | b;
}
}
package im.quantum.utils.media;
import lombok.Getter;
import quantumprotect.annotations.Native;
/**
* Integration with YouTube for tracking video playback
*/
@Native
public class YouTubeIntegration {
@Getter
private static boolean initialized = false;
/**
* Initialize the YouTube integration
*/
public static void initialize() {
if (initialized) return;
try {
// Initialize browser hooks or API connection
// This implementation would connect to browser extension or use YouTube API
initialized = true;
// Start periodic polling for YouTube status if necessary
startPolling();
} catch (Exception e) {
System.out.println("Error initializing YouTube integration: " + e.getMessage());
}
}
/**
* Start polling for YouTube status updates
*/
private static void startPolling() {
// Create a thread that periodically checks YouTube status
Thread pollingThread = new Thread(() -> {
while (initialized) {
try {
// Get current YouTube state from browser/extension
String currentTitle = getCurrentVideoTitle();
int currentPosition = getCurrentVideoPosition();
int totalLength = getCurrentVideoLength();
boolean isPlaying = isVideoPlaying();
// Update the MediaUtil with YouTube information
MediaUtil.updateYouTubeStatus(
currentTitle,
currentPosition,
totalLength,
isPlaying
);
// Sleep for a short time before next update
Thread.sleep(1000);
} catch (Exception e) {
// Silently handle errors during polling
}
}
});
pollingThread.setDaemon(true);
pollingThread.start();
}
/**
* Get the current YouTube video title
*/
private static String getCurrentVideoTitle() {
// This would be implemented with browser extension or YouTube API
// For now, returning a dummy implementation
return null; // Change to actual implementation
}
/**
* Get the current position in the YouTube video (in milliseconds)
*/
private static int getCurrentVideoPosition() {
// This would be implemented with browser extension or YouTube API
return 0; // Change to actual implementation
}
/**
* Get the total length of the YouTube video (in milliseconds)
*/
private static int getCurrentVideoLength() {
// This would be implemented with browser extension or YouTube API
return 0; // Change to actual implementation
}
/**
* Check if a YouTube video is currently playing
*/
private static boolean isVideoPlaying() {
// This would be implemented with browser extension or YouTube API
return false; // Change to actual implementation
}
/**
* Play or pause the current YouTube video
*/
public static void playPause() {
// Implement YouTube play/pause functionality
}
/**
* Skip to the next video in YouTube
*/
public static void next() {
// Implement YouTube next video functionality
}
/**
* Go to the previous video in YouTube
*/
public static void previous() {
// Implement YouTube previous video functionality
}
/**
* Shutdown the YouTube integration
*/
public static void shutdown() {
initialized = false;
}
}
аннотация уже не нада мне надо displayutils и шрифт и всезачем тебе аннотация, это для нативки мне надо
Вот тебе функционал[Q
Код:package im.quantum.utils.media; import de.labystudio.spotifyapi.SpotifyAPI; import de.labystudio.spotifyapi.SpotifyAPIFactory; import de.labystudio.spotifyapi.SpotifyListener; import de.labystudio.spotifyapi.model.Track; import lombok.Getter; import java.time.Duration; import quantumprotect.annotations.Native; @Native public class MediaUtil { private static final SpotifyAPI spotifyApi = SpotifyAPIFactory.create(); @Getter private static Track currentSpotifyTrack; @Getter private static String currentYoutubeTitle; private static boolean isSpotifyPlaying; private static boolean isYoutubePlaying; @Getter private static int currentSpotifyPosition; @Getter private static int currentYoutubePosition; @Getter private static int currentYoutubeLength; @Getter private static MediaSource currentSource = MediaSource.NONE; public enum MediaSource { SPOTIFY, YOUTUBE, NONE } static { spotifyApi.registerListener(new SpotifyListener() { @Override public void onConnect() { currentSource = MediaSource.SPOTIFY; } @Override public void onTrackChanged(Track track) { currentSpotifyTrack = track; currentSource = MediaSource.SPOTIFY; } @Override public void onPositionChanged(int position) { if (!spotifyApi.hasTrack()) { return; } currentSpotifyPosition = position; } @Override public void onPlayBackChanged(boolean playing) { isSpotifyPlaying = playing; if (playing) { currentSource = MediaSource.SPOTIFY; } else if (currentSource == MediaSource.SPOTIFY) { currentSource = isYoutubePlaying ? MediaSource.YOUTUBE : MediaSource.NONE; } } @Override public void onSync() {} @Override public void onDisconnect(Exception exception) { if (currentSource == MediaSource.SPOTIFY) { currentSource = isYoutubePlaying ? MediaSource.YOUTUBE : MediaSource.NONE; } } }); spotifyApi.initialize(); // YouTube initialization would go here initializeYouTube(); } private static void initializeYouTube() { // This would be implemented with a proper YouTube API // For now, providing a dummy implementation that can be replaced later } // YouTube integration methods public static void updateYouTubeStatus(String title, int position, int length, boolean playing) { currentYoutubeTitle = title; currentYoutubePosition = position; currentYoutubeLength = length; isYoutubePlaying = playing; if (playing && (currentSource == MediaSource.NONE || currentSource == MediaSource.YOUTUBE)) { currentSource = MediaSource.YOUTUBE; } else if (!playing && currentSource == MediaSource.YOUTUBE) { currentSource = isSpotifyPlaying ? MediaSource.SPOTIFY : MediaSource.NONE; } } // Player control actions public static void playPause() { if (currentSource == MediaSource.SPOTIFY) { // Toggle Spotify playback // spotifyApi.playPause(); - implement if API supports this } else if (currentSource == MediaSource.YOUTUBE) { // Toggle YouTube playback // Implement YouTube playback toggle } } public static void skip() { if (currentSource == MediaSource.SPOTIFY) { // Skip Spotify track // spotifyApi.next(); - implement if API supports this } else if (currentSource == MediaSource.YOUTUBE) { // Skip YouTube video // Implement YouTube skip } } public static void previous() { if (currentSource == MediaSource.SPOTIFY) { // Previous Spotify track // spotifyApi.previous(); - implement if API supports this } else if (currentSource == MediaSource.YOUTUBE) { // Previous YouTube video // Implement YouTube previous } } public static String getCurrentTrackInfo() { if (currentSource == MediaSource.SPOTIFY) { if (currentSpotifyTrack == null) return "Трек не найден"; return currentSpotifyTrack.getArtist() + " - " + currentSpotifyTrack.getName(); } else if (currentSource == MediaSource.YOUTUBE) { if (currentYoutubeTitle == null) return "Видео не найдено"; return currentYoutubeTitle; } return "Медиа не найдено"; } public static String getCurrentListeningTime() { if (currentSource == MediaSource.SPOTIFY) { return formatDuration(Duration.ofMillis(currentSpotifyPosition)); } else if (currentSource == MediaSource.YOUTUBE) { return formatDuration(Duration.ofMillis(currentYoutubePosition)); } return "00:00"; } public static boolean isPlaying() { return currentSource == MediaSource.SPOTIFY ? isSpotifyPlaying : currentSource == MediaSource.YOUTUBE ? isYoutubePlaying : false; } public static String getCurrentTrackDuration() { if (currentSource == MediaSource.SPOTIFY) { if (currentSpotifyTrack == null) return "Длительность: неизвестно"; return formatDuration(Duration.ofMillis(currentSpotifyTrack.getLength())); } else if (currentSource == MediaSource.YOUTUBE) { return formatDuration(Duration.ofMillis(currentYoutubeLength)); } return "Длительность: неизвестно"; } public static String formatDuration(Duration duration) { long seconds = duration.getSeconds(); long minutes = seconds / 60; seconds %= 60; return String.format("%02d:%02d", minutes, seconds); } }
Код:package im.quantum.ui.display.impl; import com.mojang.blaze3d.matrix.MatrixStack; import im.quantum.events.EventDisplay; import im.quantum.functions.impl.Interface.HUD; import im.quantum.ui.display.ElementRenderer; import im.quantum.utils.animations.impl.DecelerateAnimation; import im.quantum.utils.drag.Dragging; import im.quantum.utils.render.DisplayUtils; import im.quantum.utils.render.font.Fonts; import im.quantum.utils.media.MediaUtil; import lombok.AccessLevel; import lombok.RequiredArgsConstructor; import lombok.experimental.FieldDefaults; import net.minecraft.util.math.vector.Vector4f; import ru.hogoshi.Animation; import quantumprotect.annotations.Native; @Native @FieldDefaults(level = AccessLevel.PRIVATE) @RequiredArgsConstructor public class MediaRenderer implements ElementRenderer { final Dragging dragging; float width; float height; // Animation for buttons Animation playPauseHoverAnimation = new DecelerateAnimation(250, false); Animation skipHoverAnimation = new DecelerateAnimation(250, false); Animation previousHoverAnimation = new DecelerateAnimation(250, false); boolean playPauseHover = false; boolean skipHover = false; boolean previousHover = false; @Override public void render(EventDisplay eventDisplay) { MatrixStack ms = eventDisplay.getMatrixStack(); float posX = dragging.getX(); float posY = dragging.getY(); String duration = "Длительность: " + MediaUtil.getCurrentTrackDuration(); String dNotFound = "Длительность: неизвестно"; String notFound = "Медиа не найдено"; float nameWidth = Fonts.sSB.getWidth(MediaUtil.getCurrentTrackInfo(), 8.5f); float nameNotFound = Fonts.sSB.getWidth(notFound, 8.5f); float nameHeight = Fonts.sSB.getHeight(8.5f); float padding = 5; float durationWidth = Fonts.sSB.getWidth(duration, 8.5f); float durationNotFound = Fonts.sSB.getWidth(dNotFound, 8.5f); // Calculate button sizes float buttonSize = nameHeight + 4; float buttonsWidth = buttonSize * 3 + padding * 2; // 3 buttons with padding between them // Update animations playPauseHoverAnimation.setValue(playPauseHover ? 1 : 0); skipHoverAnimation.setValue(skipHover ? 1 : 0); previousHoverAnimation.setValue(previousHover ? 1 : 0); // Calculate width and height based on content if (MediaUtil.isPlaying()) { width = padding * 2 + Math.max(Math.max(nameWidth, durationWidth), buttonsWidth); height = padding * 2 + nameHeight * 2 + padding + buttonSize + padding; } else { width = padding * 2 + Math.max(nameNotFound, durationNotFound); height = padding * 2 + nameHeight; } // Draw background DisplayUtils.newrect(posX, posY, width, height, new Vector4f(5, 5, 5, 5), 190); DisplayUtils.drawRoundedOutline(posX - 0.25f, posY, width, height, 5, 1, HUD.getColor(90, 1.5f)); if (MediaUtil.isPlaying()) { // Draw track info Fonts.sSB.drawText(ms, MediaUtil.getCurrentTrackInfo(), posX + width/2 - nameWidth/2, posY + padding, -1, 8.5f); Fonts.sSB.drawText(ms, duration, posX + width/2 - durationWidth/2, posY + padding + nameHeight + padding, -1, 8.5f); // Draw control buttons float buttonsY = posY + padding + nameHeight * 2 + padding; float buttonsStartX = posX + width/2 - buttonsWidth/2; // Previous button float prevX = buttonsStartX; drawButton(ms, prevX, buttonsY, buttonSize, "◄", previousHoverAnimation.getValue()); // Play/Pause button float playX = prevX + buttonSize + padding; drawButton(ms, playX, buttonsY, buttonSize, MediaUtil.isPlaying() ? "⏸" : "►", playPauseHoverAnimation.getValue()); // Skip button float skipX = playX + buttonSize + padding; drawButton(ms, skipX, buttonsY, buttonSize, "►|", skipHoverAnimation.getValue()); // Handle button hover states float mouseX = eventDisplay.getMouseX(); float mouseY = eventDisplay.getMouseY(); previousHover = isHovering(mouseX, mouseY, prevX, buttonsY, buttonSize, buttonSize); playPauseHover = isHovering(mouseX, mouseY, playX, buttonsY, buttonSize, buttonSize); skipHover = isHovering(mouseX, mouseY, skipX, buttonsY, buttonSize, buttonSize); // Handle button clicks if (eventDisplay.isLeftClicked()) { if (previousHover) { MediaUtil.previous(); } else if (playPauseHover) { MediaUtil.playPause(); } else if (skipHover) { MediaUtil.skip(); } } } else { Fonts.sSB.drawText(ms, notFound, posX + width/2 - nameNotFound/2, posY + padding, -1, 8.5f); } dragging.setWidth(width); dragging.setHeight(height); } private void drawButton(MatrixStack ms, float x, float y, float size, String symbol, float hoverProgress) { // Draw button background with hover effect int baseColor = 0x505050; int hoverColor = HUD.getColor(90, 1.5f); int blendedColor = blendColors(baseColor, hoverColor, hoverProgress); DisplayUtils.newrect(x, y, size, size, new Vector4f(3, 3, 3, 3), blendedColor); // Draw symbol float symbolWidth = Fonts.sSB.getWidth(symbol, 10f); float symbolHeight = Fonts.sSB.getHeight(10f); Fonts.sSB.drawText(ms, symbol, x + size/2 - symbolWidth/2, y + size/2 - symbolHeight/2, -1, 10f); } private boolean isHovering(float mouseX, float mouseY, float x, float y, float width, float height) { return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height; } private int blendColors(int color1, int color2, float blendFactor) { int r1 = (color1 >> 16) & 0xFF; int g1 = (color1 >> 8) & 0xFF; int b1 = color1 & 0xFF; int r2 = (color2 >> 16) & 0xFF; int g2 = (color2 >> 8) & 0xFF; int b2 = color2 & 0xFF; int r = (int) (r1 + (r2 - r1) * blendFactor); int g = (int) (g1 + (g2 - g1) * blendFactor); int b = (int) (b1 + (b2 - b1) * blendFactor); return (r << 16) | (g << 8) | b; } }
Код:package im.quantum.ui.chat; import com.mojang.blaze3d.matrix.MatrixStack; import im.quantum.functions.impl.Interface.HUD; import im.quantum.utils.animations.impl.DecelerateAnimation; import im.quantum.utils.render.DisplayUtils; import im.quantum.utils.render.font.Fonts; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.ChatScreen; import net.minecraft.util.math.vector.Vector4f; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import ru.hogoshi.Animation; import quantumprotect.annotations.Native; @Native public class ChatButtons { private static final Animation skipButtonHover = new DecelerateAnimation(250, false); private static final Animation playPauseButtonHover = new DecelerateAnimation(250, false); private static boolean skipHovered = false; private static boolean playPauseHovered = false; @SubscribeEvent public static void onGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) { if (!(event.getGui() instanceof ChatScreen)) return; ChatScreen chatScreen = (ChatScreen) event.getGui(); MatrixStack ms = event.getMatrixStack(); int mouseX = event.getMouseX(); int mouseY = event.getMouseY(); int width = Minecraft.getInstance().getMainWindow().getScaledWidth(); int height = Minecraft.getInstance().getMainWindow().getScaledHeight(); // Button dimensions int buttonWidth = 80; int buttonHeight = 20; int padding = 5; // Skip button int skipX = width - buttonWidth - padding; int skipY = height - 50; // Position above chat input // Play/Pause button int playPauseX = skipX - buttonWidth - padding; int playPauseY = skipY; // Update hover states skipHovered = isHovering(mouseX, mouseY, skipX, skipY, buttonWidth, buttonHeight); playPauseHovered = isHovering(mouseX, mouseY, playPauseX, playPauseY, buttonWidth, buttonHeight); skipButtonHover.setValue(skipHovered ? 1 : 0); playPauseButtonHover.setValue(playPauseHovered ? 1 : 0); // Draw buttons drawButton(ms, skipX, skipY, buttonWidth, buttonHeight, "Пропустить", skipButtonHover.getValue()); drawButton(ms, playPauseX, playPauseY, buttonWidth, buttonHeight, "Запустить/Выключить", playPauseButtonHover.getValue()); } @SubscribeEvent public static void onGuiMouseClicked(GuiScreenEvent.MouseClickedEvent.Pre event) { if (!(event.getGui() instanceof ChatScreen)) return; if (event.getButton() == 0) { // Left click if (skipHovered) { // Handle skip button click // Implement the action to skip event.setCanceled(true); } else if (playPauseHovered) { // Handle play/pause button click // Implement the action to play/pause event.setCanceled(true); } } } private static void drawButton(MatrixStack ms, int x, int y, int width, int height, String text, float hoverProgress) { // Draw button background with hover effect int baseColor = 0x50505050; int hoverColor = HUD.getColor(90, 1.5f); int blendedColor = blendColors(baseColor, hoverColor, hoverProgress); DisplayUtils.newrect(x, y, width, height, new Vector4f(3, 3, 3, 3), blendedColor); // Draw text float textWidth = Fonts.sSB.getWidth(text, 8.5f); float textHeight = Fonts.sSB.getHeight(8.5f); Fonts.sSB.drawText(ms, text, x + width/2 - textWidth/2, y + height/2 - textHeight/2, -1, 8.5f); } private static boolean isHovering(int mouseX, int mouseY, int x, int y, int width, int height) { return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height; } private static int blendColors(int color1, int color2, float blendFactor) { int a1 = (color1 >> 24) & 0xFF; int r1 = (color1 >> 16) & 0xFF; int g1 = (color1 >> 8) & 0xFF; int b1 = color1 & 0xFF; int a2 = (color2 >> 24) & 0xFF; int r2 = (color2 >> 16) & 0xFF; int g2 = (color2 >> 8) & 0xFF; int b2 = color2 & 0xFF; int a = (int) (a1 + (a2 - a1) * blendFactor); int r = (int) (r1 + (r2 - r1) * blendFactor); int g = (int) (g1 + (g2 - g1) * blendFactor); int b = (int) (b1 + (b2 - b1) * blendFactor); return (a << 24) | (r << 16) | (g << 8) | b; } }
Код:package im.quantum.utils.media; import lombok.Getter; import quantumprotect.annotations.Native; /** * Integration with YouTube for tracking video playback */ @Native public class YouTubeIntegration { @Getter private static boolean initialized = false; /** * Initialize the YouTube integration */ public static void initialize() { if (initialized) return; try { // Initialize browser hooks or API connection // This implementation would connect to browser extension or use YouTube API initialized = true; // Start periodic polling for YouTube status if necessary startPolling(); } catch (Exception e) { System.out.println("Error initializing YouTube integration: " + e.getMessage()); } } /** * Start polling for YouTube status updates */ private static void startPolling() { // Create a thread that periodically checks YouTube status Thread pollingThread = new Thread(() -> { while (initialized) { try { // Get current YouTube state from browser/extension String currentTitle = getCurrentVideoTitle(); int currentPosition = getCurrentVideoPosition(); int totalLength = getCurrentVideoLength(); boolean isPlaying = isVideoPlaying(); // Update the MediaUtil with YouTube information MediaUtil.updateYouTubeStatus( currentTitle, currentPosition, totalLength, isPlaying ); // Sleep for a short time before next update Thread.sleep(1000); } catch (Exception e) { // Silently handle errors during polling } } }); pollingThread.setDaemon(true); pollingThread.start(); } /** * Get the current YouTube video title */ private static String getCurrentVideoTitle() { // This would be implemented with browser extension or YouTube API // For now, returning a dummy implementation return null; // Change to actual implementation } /** * Get the current position in the YouTube video (in milliseconds) */ private static int getCurrentVideoPosition() { // This would be implemented with browser extension or YouTube API return 0; // Change to actual implementation } /** * Get the total length of the YouTube video (in milliseconds) */ private static int getCurrentVideoLength() { // This would be implemented with browser extension or YouTube API return 0; // Change to actual implementation } /** * Check if a YouTube video is currently playing */ private static boolean isVideoPlaying() { // This would be implemented with browser extension or YouTube API return false; // Change to actual implementation } /** * Play or pause the current YouTube video */ public static void playPause() { // Implement YouTube play/pause functionality } /** * Skip to the next video in YouTube */ public static void next() { // Implement YouTube next video functionality } /** * Go to the previous video in YouTube */ public static void previous() { // Implement YouTube previous video functionality } /** * Shutdown the YouTube integration */ public static void shutdown() { initialized = false; } }
1. в твоем коде 0 функционала
2. говно код
3. работает только для спотифая
итог: говнище
У меня есть норм такая штука для всех площадок но я сливать не буду , продам ее пишите в тг @polinakcaхуетень ебанная, во первых онли фор спотик, во вторых смысл этой хуйни спрашивается
Проект предоставляет различный материал, относящийся к сфере киберспорта, программирования, ПО для игр, а также позволяет его участникам общаться на многие другие темы. Почта для жалоб: admin@yougame.biz