add
This commit is contained in:
42
TomatenMusic/Models/BasicTrackInfo.cs
Normal file
42
TomatenMusic/Models/BasicTrackInfo.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Lavalink4NET.Player;
|
||||
using System.Text.Json.Serialization;
|
||||
using TomatenMusic.Music.Entitites;
|
||||
|
||||
namespace TomatenMusic_Api.Models
|
||||
{
|
||||
public class BasicTrackInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public TrackPlatform Platform { get; set; }
|
||||
|
||||
public string YoutubeId { get; set; }
|
||||
|
||||
public string SpotifyId { get; set; }
|
||||
|
||||
public Uri URL { get; set; }
|
||||
|
||||
public BasicTrackInfo(LavalinkTrack track)
|
||||
{
|
||||
if (track == null)
|
||||
return;
|
||||
FullTrackContext ctx = (FullTrackContext)track.Context;
|
||||
|
||||
if (ctx == null)
|
||||
return;
|
||||
|
||||
Name = track.Title;
|
||||
Platform = ctx.SpotifyIdentifier == null ? TrackPlatform.YOUTUBE : TrackPlatform.SPOTIFY;
|
||||
YoutubeId = track.TrackIdentifier;
|
||||
SpotifyId = ctx.SpotifyIdentifier;
|
||||
URL = new Uri(track.Source);
|
||||
}
|
||||
}
|
||||
|
||||
public enum TrackPlatform
|
||||
{
|
||||
YOUTUBE,
|
||||
SPOTIFY,
|
||||
FILE
|
||||
}
|
||||
}
|
13
TomatenMusic/Models/ChannelConnectRequest.cs
Normal file
13
TomatenMusic/Models/ChannelConnectRequest.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using DSharpPlus.Entities;
|
||||
using Emzi0767.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace TomatenMusic_Api.Models
|
||||
{
|
||||
public class ChannelConnectRequest
|
||||
{
|
||||
public ulong Channel_Id { get; set; }
|
||||
public ulong Guild_Id { get; set; }
|
||||
|
||||
}
|
||||
}
|
7
TomatenMusic/Models/ChannelDisconnectRequest.cs
Normal file
7
TomatenMusic/Models/ChannelDisconnectRequest.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace TomatenMusic_Api.Models.EventArgs
|
||||
{
|
||||
public class ChannelDisconnectRequest
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
}
|
||||
}
|
18
TomatenMusic/Models/EventArgs/ChannelConnectArgs.cs
Normal file
18
TomatenMusic/Models/EventArgs/ChannelConnectArgs.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using DSharpPlus.Entities;
|
||||
using Emzi0767.Utilities;
|
||||
|
||||
namespace TomatenMusic_Api.Models.EventArgs
|
||||
{
|
||||
public class ChannelConnectArgs : AsyncEventArgs
|
||||
{
|
||||
public ulong Guild_Id { get; set; }
|
||||
|
||||
public DiscordChannel Channel { get; set; }
|
||||
|
||||
public ChannelConnectArgs(ulong guild_Id, DiscordChannel channel)
|
||||
{
|
||||
Guild_Id = guild_Id;
|
||||
Channel = channel;
|
||||
}
|
||||
}
|
||||
}
|
13
TomatenMusic/Models/EventArgs/ChannelDisconnectArgs.cs
Normal file
13
TomatenMusic/Models/EventArgs/ChannelDisconnectArgs.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Emzi0767.Utilities;
|
||||
|
||||
namespace TomatenMusic_Api.Models.EventArgs
|
||||
{
|
||||
public class ChannelDisconnectArgs : AsyncEventArgs
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
|
||||
public ChannelDisconnectArgs(ulong guildId) { GuildId = guildId; }
|
||||
}
|
||||
|
||||
|
||||
}
|
22
TomatenMusic/Models/EventArgs/TrackPlayArgs.cs
Normal file
22
TomatenMusic/Models/EventArgs/TrackPlayArgs.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Emzi0767.Utilities;
|
||||
using Lavalink4NET.Player;
|
||||
using TomatenMusic.Music;
|
||||
|
||||
namespace TomatenMusic_Api.Models.EventArgs
|
||||
{
|
||||
public class TrackPlayArgs : AsyncEventArgs
|
||||
{
|
||||
public MusicActionResponse Response { get; set; }
|
||||
public ulong GuildId { get; set; }
|
||||
public TimeSpan StartTime { get; set; }
|
||||
public bool Now { get; set; }
|
||||
|
||||
public TrackPlayArgs(MusicActionResponse response, ulong guildId, TimeSpan startTime, bool now)
|
||||
{
|
||||
Response = response;
|
||||
GuildId = guildId;
|
||||
StartTime = startTime;
|
||||
Now = now;
|
||||
}
|
||||
}
|
||||
}
|
62
TomatenMusic/Models/PlayerConnectionInfo.cs
Normal file
62
TomatenMusic/Models/PlayerConnectionInfo.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using DSharpPlus.Entities;
|
||||
using Lavalink4NET;
|
||||
using Lavalink4NET.Player;
|
||||
using TomatenMusic;
|
||||
using TomatenMusic.Music;
|
||||
|
||||
namespace TomatenMusic_Api.Models
|
||||
{
|
||||
public class PlayerConnectionInfo
|
||||
{
|
||||
|
||||
public static async Task<PlayerConnectionInfo> Create(GuildPlayer player)
|
||||
{
|
||||
PlayerConnectionInfo response = new PlayerConnectionInfo();
|
||||
|
||||
response.PlaybackPosition = player.TrackPosition;
|
||||
response.Channel_Id = (ulong)player.VoiceChannelId;
|
||||
response.Guild_Id = player.GuildId;
|
||||
response.Paused = player.State == PlayerState.Paused;
|
||||
response.CurrentTrack = new BasicTrackInfo(player.CurrentTrack);
|
||||
response.LoopType = player.PlayerQueue.LoopType;
|
||||
|
||||
response.Queue = player.PlayerQueue.Queue.ToList().ConvertAll(x => new BasicTrackInfo(x));
|
||||
response.PlayedTracks = player.PlayerQueue.PlayedTracks.ToList().ConvertAll(x => new BasicTrackInfo(x));
|
||||
response.State = player.State;
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
// Summary:
|
||||
// Gets the current playback position.
|
||||
public TimeSpan PlaybackPosition
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
public PlayerState State { get; set; }
|
||||
//
|
||||
// Summary:
|
||||
// Gets the voice channel associated with this connection.
|
||||
public ulong Channel_Id { get; set; }
|
||||
|
||||
//
|
||||
// Summary:
|
||||
// Gets the guild associated with this connection.
|
||||
public ulong Guild_Id {get; set; }
|
||||
|
||||
public bool Paused { get; set; }
|
||||
|
||||
public BasicTrackInfo CurrentTrack { get; set; }
|
||||
|
||||
public LoopType LoopType { get; set; }
|
||||
|
||||
public List<BasicTrackInfo> Queue { get; set; }
|
||||
|
||||
public List<BasicTrackInfo> PlayedTracks { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
10
TomatenMusic/Models/TrackPlayRequest.cs
Normal file
10
TomatenMusic/Models/TrackPlayRequest.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace TomatenMusic_Api.Models
|
||||
{
|
||||
public class TrackPlayRequest
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public string TrackUri { get; set; }
|
||||
public bool Now { get; set; }
|
||||
public int StartTimeSeconds { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user