Add project files.

This commit is contained in:
Tim Müller
2022-03-15 22:38:41 +01:00
parent 78b2d02e9f
commit ae4125574c
63 changed files with 4785 additions and 0 deletions

View 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.Identifier;
SpotifyId = ctx.SpotifyIdentifier;
URL = ctx.YoutubeUri;
}
}
public enum TrackPlatform
{
YOUTUBE,
SPOTIFY,
FILE
}
}

View 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; }
}
}

View 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; }
}
}