Added local audio file playback
This commit is contained in:
@@ -3,7 +3,7 @@ package com.fpghoti.biscuit.audio.queue;
|
||||
import java.awt.Color;
|
||||
|
||||
import com.fpghoti.biscuit.audio.request.RequestType;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
|
||||
@@ -14,14 +14,14 @@ import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class QueuedTrack {
|
||||
|
||||
private Biscuit biscuit;
|
||||
private BiscuitGuild biscuit;
|
||||
private AudioTrack track;
|
||||
private String userId;
|
||||
private TextChannel channel;
|
||||
private RequestType type;
|
||||
private boolean triedAlternative;
|
||||
|
||||
public QueuedTrack(Biscuit biscuit, AudioTrack track, String userId, TextChannel channel, RequestType type) {
|
||||
public QueuedTrack(BiscuitGuild biscuit, AudioTrack track, String userId, TextChannel channel, RequestType type) {
|
||||
this.biscuit = biscuit;
|
||||
this.track = track;
|
||||
this.userId = userId;
|
||||
@@ -30,7 +30,7 @@ public class QueuedTrack {
|
||||
this.triedAlternative = false;
|
||||
}
|
||||
|
||||
public Biscuit getBiscuit() {
|
||||
public BiscuitGuild getBiscuitGuild() {
|
||||
return biscuit;
|
||||
}
|
||||
|
||||
@@ -56,31 +56,35 @@ public class QueuedTrack {
|
||||
|
||||
public MessageEmbed getEmbedMessage(String prefix, boolean showRemaining) {
|
||||
EmbedBuilder embed = new EmbedBuilder();
|
||||
|
||||
String title = track.getInfo().title;
|
||||
if(prefix != null && !prefix.equals("")) {
|
||||
title = prefix + " " + title;
|
||||
}
|
||||
|
||||
embed.setTitle(title, track.getInfo().uri);
|
||||
|
||||
String uri = track.getInfo().uri;
|
||||
if(type.toString().toLowerCase().contains("file")) {
|
||||
if(title.contains("Unknown title") && Util.getLast(title, " ").equals("title")) {
|
||||
title = title.replace("Unknown title", Util.getLast(uri,"\\\\"));
|
||||
}
|
||||
embed.setTitle(title);
|
||||
}else {
|
||||
embed.setTitle(title, uri);
|
||||
}
|
||||
|
||||
embed.setColor(Color.CYAN);
|
||||
|
||||
long duration = track.getDuration();
|
||||
|
||||
//Duration seems to change after track begins playing
|
||||
//This is to make the embeds more consistant with each other
|
||||
//This is to make the embeds more consistent with each other
|
||||
if(showRemaining) {
|
||||
duration+=1000;
|
||||
}
|
||||
|
||||
String desc = "Type: " + type.toString() + "\nAuthor: " + track.getInfo().author + "\nLength: " + Util.getTime(duration);
|
||||
|
||||
if(showRemaining) {
|
||||
desc = desc + "\nTime Remaining: " + Util.getTime(track.getDuration() - track.getPosition());
|
||||
}
|
||||
|
||||
embed.setDescription(desc);
|
||||
|
||||
String name = biscuit.getGuild().getSelfMember().getEffectiveName();
|
||||
String avatar = biscuit.getGuild().getSelfMember().getUser().getEffectiveAvatarUrl();
|
||||
|
||||
@@ -89,13 +93,11 @@ public class QueuedTrack {
|
||||
name = m.getEffectiveName();
|
||||
avatar = m.getUser().getEffectiveAvatarUrl();
|
||||
}
|
||||
|
||||
embed.setAuthor(name, null, avatar);
|
||||
|
||||
if(type.toString().toLowerCase().contains("youtube")) {
|
||||
embed.setThumbnail("https://img.youtube.com/vi/" + track.getIdentifier() + "/mqdefault.jpg");
|
||||
}
|
||||
|
||||
return embed.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user