Updated to .NET Core and reimplemented auth strategies

This commit is contained in:
Jonas Dellinger 2018-08-24 14:10:13 +02:00
parent 73976e0d6b
commit 5c2a901f75
125 changed files with 647 additions and 4963 deletions

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

View File

@ -1,114 +0,0 @@
namespace SpotifyAPI.Example
{
partial class ExampleForm
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.localControl1 = new SpotifyAPI.Example.LocalControl();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.webControl2 = new SpotifyAPI.Example.WebControl();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(984, 702);
this.tabControl1.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.localControl1);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(976, 676);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Local-API";
this.tabPage1.UseVisualStyleBackColor = true;
//
// localControl1
//
this.localControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.localControl1.Location = new System.Drawing.Point(3, 3);
this.localControl1.Name = "localControl1";
this.localControl1.Size = new System.Drawing.Size(970, 670);
this.localControl1.TabIndex = 0;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.webControl2);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(976, 676);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Web-API";
this.tabPage2.UseVisualStyleBackColor = true;
//
// webControl2
//
this.webControl2.Dock = System.Windows.Forms.DockStyle.Fill;
this.webControl2.Location = new System.Drawing.Point(3, 3);
this.webControl2.Name = "webControl2";
this.webControl2.Size = new System.Drawing.Size(970, 670);
this.webControl2.TabIndex = 0;
//
// ExampleForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(984, 702);
this.Controls.Add(this.tabControl1);
this.Name = "ExampleForm";
this.Text = "SpoitfyAPI .NET Example";
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private LocalControl localControl1;
private WebControl webControl2;
}
}

View File

@ -1,12 +0,0 @@
using System.Windows.Forms;
namespace SpotifyAPI.Example
{
public partial class ExampleForm : Form
{
public ExampleForm()
{
InitializeComponent();
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,686 +0,0 @@
namespace SpotifyAPI.Example
{
partial class LocalControl
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Komponenten-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.bigAlbumPicture = new System.Windows.Forms.PictureBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.volumeMixerLabel = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.volumeUpBtn = new System.Windows.Forms.Button();
this.volumeDownBtn = new System.Windows.Forms.Button();
this.repeatShuffleLabel = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.versionLabel = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.clientVersionLabel = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.skipBtn = new System.Windows.Forms.Button();
this.prevBtn = new System.Windows.Forms.Button();
this.pauseBtn = new System.Windows.Forms.Button();
this.playBtn = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.contextTextBox = new System.Windows.Forms.TextBox();
this.playUrlBtn = new System.Windows.Forms.Button();
this.playTextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.isPlayingLabel = new System.Windows.Forms.Label();
this.volumeLabel = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.connectBtn = new System.Windows.Forms.Button();
this.trackInfoBox = new System.Windows.Forms.GroupBox();
this.advertLabel = new System.Windows.Forms.Label();
this.timeLabel = new System.Windows.Forms.Label();
this.timeProgressBar = new System.Windows.Forms.ProgressBar();
this.label5 = new System.Windows.Forms.Label();
this.smallAlbumPicture = new System.Windows.Forms.PictureBox();
this.label4 = new System.Windows.Forms.Label();
this.artistLinkLabel = new System.Windows.Forms.LinkLabel();
this.titleLinkLabel = new System.Windows.Forms.LinkLabel();
this.label3 = new System.Windows.Forms.Label();
this.albumLinkLabel = new System.Windows.Forms.LinkLabel();
this.proxyGroupBox = new System.Windows.Forms.GroupBox();
this.proxyPortUpDown = new System.Windows.Forms.NumericUpDown();
this.proxyPasswordTextBox = new System.Windows.Forms.TextBox();
this.label15 = new System.Windows.Forms.Label();
this.proxyUsernameTextBox = new System.Windows.Forms.TextBox();
this.label14 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.proxyHostTextBox = new System.Windows.Forms.TextBox();
this.label12 = new System.Windows.Forms.Label();
this.applyProxyBtn = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.bigAlbumPicture)).BeginInit();
this.groupBox1.SuspendLayout();
this.trackInfoBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.smallAlbumPicture)).BeginInit();
this.proxyGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.proxyPortUpDown)).BeginInit();
this.SuspendLayout();
//
// bigAlbumPicture
//
this.bigAlbumPicture.Location = new System.Drawing.Point(407, 93);
this.bigAlbumPicture.Name = "bigAlbumPicture";
this.bigAlbumPicture.Size = new System.Drawing.Size(560, 560);
this.bigAlbumPicture.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.bigAlbumPicture.TabIndex = 2;
this.bigAlbumPicture.TabStop = false;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.volumeMixerLabel);
this.groupBox1.Controls.Add(this.label9);
this.groupBox1.Controls.Add(this.volumeUpBtn);
this.groupBox1.Controls.Add(this.volumeDownBtn);
this.groupBox1.Controls.Add(this.repeatShuffleLabel);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.versionLabel);
this.groupBox1.Controls.Add(this.label11);
this.groupBox1.Controls.Add(this.clientVersionLabel);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.skipBtn);
this.groupBox1.Controls.Add(this.prevBtn);
this.groupBox1.Controls.Add(this.pauseBtn);
this.groupBox1.Controls.Add(this.playBtn);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.contextTextBox);
this.groupBox1.Controls.Add(this.playUrlBtn);
this.groupBox1.Controls.Add(this.playTextBox);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.isPlayingLabel);
this.groupBox1.Controls.Add(this.volumeLabel);
this.groupBox1.Controls.Add(this.label10);
this.groupBox1.Controls.Add(this.label8);
this.groupBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.groupBox1.Location = new System.Drawing.Point(3, 55);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(398, 286);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Spotify Info";
//
// volumeMixerLabel
//
this.volumeMixerLabel.AutoSize = true;
this.volumeMixerLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.volumeMixerLabel.Location = new System.Drawing.Point(168, 117);
this.volumeMixerLabel.Name = "volumeMixerLabel";
this.volumeMixerLabel.Size = new System.Drawing.Size(13, 17);
this.volumeMixerLabel.TabIndex = 35;
this.volumeMixerLabel.Text = "-";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label9.Location = new System.Drawing.Point(7, 117);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(155, 17);
this.label9.TabIndex = 34;
this.label9.Text = "Volume Mixer\'s volume:";
//
// volumeUpBtn
//
this.volumeUpBtn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.volumeUpBtn.Location = new System.Drawing.Point(300, 114);
this.volumeUpBtn.Margin = new System.Windows.Forms.Padding(0);
this.volumeUpBtn.Name = "volumeUpBtn";
this.volumeUpBtn.Size = new System.Drawing.Size(92, 24);
this.volumeUpBtn.TabIndex = 33;
this.volumeUpBtn.Text = "Volume+";
this.volumeUpBtn.UseVisualStyleBackColor = true;
this.volumeUpBtn.Click += new System.EventHandler(this.volumeUpBtn_Click);
//
// volumeDownBtn
//
this.volumeDownBtn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.volumeDownBtn.Location = new System.Drawing.Point(300, 138);
this.volumeDownBtn.Margin = new System.Windows.Forms.Padding(0);
this.volumeDownBtn.Name = "volumeDownBtn";
this.volumeDownBtn.Size = new System.Drawing.Size(92, 24);
this.volumeDownBtn.TabIndex = 32;
this.volumeDownBtn.Text = "Volume-";
this.volumeDownBtn.UseVisualStyleBackColor = true;
this.volumeDownBtn.Click += new System.EventHandler(this.volumeDownBtn_Click);
//
// repeatShuffleLabel
//
this.repeatShuffleLabel.AutoSize = true;
this.repeatShuffleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.repeatShuffleLabel.Location = new System.Drawing.Point(146, 88);
this.repeatShuffleLabel.Name = "repeatShuffleLabel";
this.repeatShuffleLabel.Size = new System.Drawing.Size(13, 17);
this.repeatShuffleLabel.TabIndex = 30;
this.repeatShuffleLabel.Text = "-";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label6.Location = new System.Drawing.Point(6, 88);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(134, 17);
this.label6.TabIndex = 29;
this.label6.Text = "Repeat and Shuffle:";
//
// versionLabel
//
this.versionLabel.AutoSize = true;
this.versionLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.versionLabel.Location = new System.Drawing.Point(72, 37);
this.versionLabel.Name = "versionLabel";
this.versionLabel.Size = new System.Drawing.Size(13, 17);
this.versionLabel.TabIndex = 28;
this.versionLabel.Text = "-";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label11.Location = new System.Drawing.Point(6, 37);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(60, 17);
this.label11.TabIndex = 27;
this.label11.Text = "Version:";
//
// clientVersionLabel
//
this.clientVersionLabel.AutoSize = true;
this.clientVersionLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.clientVersionLabel.Location = new System.Drawing.Point(108, 20);
this.clientVersionLabel.Name = "clientVersionLabel";
this.clientVersionLabel.Size = new System.Drawing.Size(13, 17);
this.clientVersionLabel.TabIndex = 26;
this.clientVersionLabel.Text = "-";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label7.Location = new System.Drawing.Point(6, 20);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(96, 17);
this.label7.TabIndex = 25;
this.label7.Text = "Client-Version";
//
// skipBtn
//
this.skipBtn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.skipBtn.Location = new System.Drawing.Point(300, 252);
this.skipBtn.Name = "skipBtn";
this.skipBtn.Size = new System.Drawing.Size(92, 23);
this.skipBtn.TabIndex = 24;
this.skipBtn.Text = "Skip";
this.skipBtn.UseVisualStyleBackColor = true;
this.skipBtn.Click += new System.EventHandler(this.skipBtn_Click);
//
// prevBtn
//
this.prevBtn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.prevBtn.Location = new System.Drawing.Point(202, 252);
this.prevBtn.Name = "prevBtn";
this.prevBtn.Size = new System.Drawing.Size(92, 23);
this.prevBtn.TabIndex = 23;
this.prevBtn.Text = "Previous";
this.prevBtn.UseVisualStyleBackColor = true;
this.prevBtn.Click += new System.EventHandler(this.prevBtn_Click);
//
// pauseBtn
//
this.pauseBtn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.pauseBtn.Location = new System.Drawing.Point(104, 252);
this.pauseBtn.Name = "pauseBtn";
this.pauseBtn.Size = new System.Drawing.Size(92, 23);
this.pauseBtn.TabIndex = 22;
this.pauseBtn.Text = "Pause";
this.pauseBtn.UseVisualStyleBackColor = true;
this.pauseBtn.Click += new System.EventHandler(this.pauseBtn_Click);
//
// playBtn
//
this.playBtn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.playBtn.Location = new System.Drawing.Point(6, 252);
this.playBtn.Name = "playBtn";
this.playBtn.Size = new System.Drawing.Size(92, 23);
this.playBtn.TabIndex = 21;
this.playBtn.Text = "Play";
this.playBtn.UseVisualStyleBackColor = true;
this.playBtn.Click += new System.EventHandler(this.playBtn_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(6, 206);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(110, 17);
this.label1.TabIndex = 20;
this.label1.Text = "Playing-Context:";
//
// contextTextBox
//
this.contextTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.contextTextBox.Location = new System.Drawing.Point(9, 226);
this.contextTextBox.Name = "contextTextBox";
this.contextTextBox.Size = new System.Drawing.Size(285, 20);
this.contextTextBox.TabIndex = 19;
//
// playUrlBtn
//
this.playUrlBtn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.playUrlBtn.Location = new System.Drawing.Point(300, 165);
this.playUrlBtn.Name = "playUrlBtn";
this.playUrlBtn.Size = new System.Drawing.Size(92, 81);
this.playUrlBtn.TabIndex = 18;
this.playUrlBtn.Text = "PlayURL";
this.playUrlBtn.UseVisualStyleBackColor = true;
this.playUrlBtn.Click += new System.EventHandler(this.playUrlBtn_Click);
//
// playTextBox
//
this.playTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.playTextBox.Location = new System.Drawing.Point(6, 185);
this.playTextBox.Name = "playTextBox";
this.playTextBox.Size = new System.Drawing.Size(288, 20);
this.playTextBox.TabIndex = 17;
this.playTextBox.Text = "https://open.spotify.com/track/4myBMnNWZlgvVelYeTu55w";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(6, 165);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(131, 17);
this.label2.TabIndex = 16;
this.label2.Text = "Spotify URI or URL:";
//
// isPlayingLabel
//
this.isPlayingLabel.AutoSize = true;
this.isPlayingLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.isPlayingLabel.Location = new System.Drawing.Point(84, 71);
this.isPlayingLabel.Name = "isPlayingLabel";
this.isPlayingLabel.Size = new System.Drawing.Size(13, 17);
this.isPlayingLabel.TabIndex = 14;
this.isPlayingLabel.Text = "-";
//
// volumeLabel
//
this.volumeLabel.AutoSize = true;
this.volumeLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.volumeLabel.Location = new System.Drawing.Point(71, 54);
this.volumeLabel.Name = "volumeLabel";
this.volumeLabel.Size = new System.Drawing.Size(13, 17);
this.volumeLabel.TabIndex = 13;
this.volumeLabel.Text = "-";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label10.Location = new System.Drawing.Point(6, 54);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(59, 17);
this.label10.TabIndex = 11;
this.label10.Text = "Volume:";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label8.Location = new System.Drawing.Point(6, 71);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(72, 17);
this.label8.TabIndex = 10;
this.label8.Text = "Is Playing:";
//
// connectBtn
//
this.connectBtn.Location = new System.Drawing.Point(3, 13);
this.connectBtn.Name = "connectBtn";
this.connectBtn.Size = new System.Drawing.Size(398, 36);
this.connectBtn.TabIndex = 4;
this.connectBtn.Text = "Connect to Spotify";
this.connectBtn.UseVisualStyleBackColor = true;
this.connectBtn.Click += new System.EventHandler(this.connectBtn_Click);
//
// trackInfoBox
//
this.trackInfoBox.Controls.Add(this.advertLabel);
this.trackInfoBox.Controls.Add(this.timeLabel);
this.trackInfoBox.Controls.Add(this.timeProgressBar);
this.trackInfoBox.Controls.Add(this.label5);
this.trackInfoBox.Controls.Add(this.smallAlbumPicture);
this.trackInfoBox.Controls.Add(this.label4);
this.trackInfoBox.Controls.Add(this.artistLinkLabel);
this.trackInfoBox.Controls.Add(this.titleLinkLabel);
this.trackInfoBox.Controls.Add(this.label3);
this.trackInfoBox.Controls.Add(this.albumLinkLabel);
this.trackInfoBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.trackInfoBox.Location = new System.Drawing.Point(3, 347);
this.trackInfoBox.Name = "trackInfoBox";
this.trackInfoBox.Size = new System.Drawing.Size(398, 306);
this.trackInfoBox.TabIndex = 4;
this.trackInfoBox.TabStop = false;
this.trackInfoBox.Text = "Track Info";
//
// advertLabel
//
this.advertLabel.AutoSize = true;
this.advertLabel.Location = new System.Drawing.Point(6, 67);
this.advertLabel.Name = "advertLabel";
this.advertLabel.Size = new System.Drawing.Size(0, 17);
this.advertLabel.TabIndex = 31;
//
// timeLabel
//
this.timeLabel.AutoSize = true;
this.timeLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.timeLabel.Location = new System.Drawing.Point(7, 281);
this.timeLabel.Name = "timeLabel";
this.timeLabel.Size = new System.Drawing.Size(13, 17);
this.timeLabel.TabIndex = 29;
this.timeLabel.Text = "-";
//
// timeProgressBar
//
this.timeProgressBar.Location = new System.Drawing.Point(6, 255);
this.timeProgressBar.Name = "timeProgressBar";
this.timeProgressBar.Size = new System.Drawing.Size(386, 23);
this.timeProgressBar.TabIndex = 28;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point(10, 227);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(51, 17);
this.label5.TabIndex = 27;
this.label5.Text = "Album:";
//
// smallAlbumPicture
//
this.smallAlbumPicture.Location = new System.Drawing.Point(123, 22);
this.smallAlbumPicture.Name = "smallAlbumPicture";
this.smallAlbumPicture.Size = new System.Drawing.Size(150, 150);
this.smallAlbumPicture.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.smallAlbumPicture.TabIndex = 5;
this.smallAlbumPicture.TabStop = false;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(17, 204);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(44, 17);
this.label4.TabIndex = 26;
this.label4.Text = "Artist:";
//
// artistLinkLabel
//
this.artistLinkLabel.AutoSize = true;
this.artistLinkLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.artistLinkLabel.Location = new System.Drawing.Point(67, 204);
this.artistLinkLabel.Name = "artistLinkLabel";
this.artistLinkLabel.Size = new System.Drawing.Size(13, 17);
this.artistLinkLabel.TabIndex = 6;
this.artistLinkLabel.TabStop = true;
this.artistLinkLabel.Text = "-";
this.artistLinkLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// titleLinkLabel
//
this.titleLinkLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.titleLinkLabel.AutoSize = true;
this.titleLinkLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.titleLinkLabel.Location = new System.Drawing.Point(67, 182);
this.titleLinkLabel.Name = "titleLinkLabel";
this.titleLinkLabel.Size = new System.Drawing.Size(13, 17);
this.titleLinkLabel.TabIndex = 5;
this.titleLinkLabel.TabStop = true;
this.titleLinkLabel.Text = "-";
this.titleLinkLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(22, 182);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(39, 17);
this.label3.TabIndex = 25;
this.label3.Text = "Title:";
//
// albumLinkLabel
//
this.albumLinkLabel.AutoSize = true;
this.albumLinkLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.albumLinkLabel.Location = new System.Drawing.Point(67, 227);
this.albumLinkLabel.Name = "albumLinkLabel";
this.albumLinkLabel.Size = new System.Drawing.Size(13, 17);
this.albumLinkLabel.TabIndex = 7;
this.albumLinkLabel.TabStop = true;
this.albumLinkLabel.Text = "-";
this.albumLinkLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// proxyGroupBox
//
this.proxyGroupBox.Controls.Add(this.proxyPortUpDown);
this.proxyGroupBox.Controls.Add(this.proxyPasswordTextBox);
this.proxyGroupBox.Controls.Add(this.label15);
this.proxyGroupBox.Controls.Add(this.proxyUsernameTextBox);
this.proxyGroupBox.Controls.Add(this.label14);
this.proxyGroupBox.Controls.Add(this.label13);
this.proxyGroupBox.Controls.Add(this.proxyHostTextBox);
this.proxyGroupBox.Controls.Add(this.label12);
this.proxyGroupBox.Controls.Add(this.applyProxyBtn);
this.proxyGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F);
this.proxyGroupBox.Location = new System.Drawing.Point(407, 10);
this.proxyGroupBox.Name = "proxyGroupBox";
this.proxyGroupBox.Size = new System.Drawing.Size(560, 77);
this.proxyGroupBox.TabIndex = 5;
this.proxyGroupBox.TabStop = false;
this.proxyGroupBox.Text = "Proxy Config";
//
// proxyPortUpDown
//
this.proxyPortUpDown.Location = new System.Drawing.Point(324, 18);
this.proxyPortUpDown.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.proxyPortUpDown.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.proxyPortUpDown.Name = "proxyPortUpDown";
this.proxyPortUpDown.Size = new System.Drawing.Size(157, 24);
this.proxyPortUpDown.TabIndex = 6;
this.proxyPortUpDown.Value = new decimal(new int[] {
80,
0,
0,
0});
//
// proxyPasswordTextBox
//
this.proxyPasswordTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.proxyPasswordTextBox.Location = new System.Drawing.Point(359, 47);
this.proxyPasswordTextBox.Name = "proxyPasswordTextBox";
this.proxyPasswordTextBox.Size = new System.Drawing.Size(122, 20);
this.proxyPasswordTextBox.TabIndex = 42;
//
// label15
//
this.label15.AutoSize = true;
this.label15.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label15.Location = new System.Drawing.Point(280, 48);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(73, 17);
this.label15.TabIndex = 41;
this.label15.Text = "Password:";
//
// proxyUsernameTextBox
//
this.proxyUsernameTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.proxyUsernameTextBox.Location = new System.Drawing.Point(89, 47);
this.proxyUsernameTextBox.Name = "proxyUsernameTextBox";
this.proxyUsernameTextBox.Size = new System.Drawing.Size(185, 20);
this.proxyUsernameTextBox.TabIndex = 40;
//
// label14
//
this.label14.AutoSize = true;
this.label14.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label14.Location = new System.Drawing.Point(6, 48);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(77, 17);
this.label14.TabIndex = 39;
this.label14.Text = "Username:";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label13.Location = new System.Drawing.Point(280, 22);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(38, 17);
this.label13.TabIndex = 37;
this.label13.Text = "Port:";
//
// proxyHostTextBox
//
this.proxyHostTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.proxyHostTextBox.Location = new System.Drawing.Point(49, 21);
this.proxyHostTextBox.Name = "proxyHostTextBox";
this.proxyHostTextBox.Size = new System.Drawing.Size(225, 20);
this.proxyHostTextBox.TabIndex = 36;
//
// label12
//
this.label12.AutoSize = true;
this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label12.Location = new System.Drawing.Point(6, 22);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(41, 17);
this.label12.TabIndex = 36;
this.label12.Text = "Host:";
//
// applyProxyBtn
//
this.applyProxyBtn.Location = new System.Drawing.Point(487, 15);
this.applyProxyBtn.Name = "applyProxyBtn";
this.applyProxyBtn.Size = new System.Drawing.Size(67, 56);
this.applyProxyBtn.TabIndex = 0;
this.applyProxyBtn.Text = "Apply";
this.applyProxyBtn.UseVisualStyleBackColor = true;
this.applyProxyBtn.Click += new System.EventHandler(this.applyProxyBtn_Click);
//
// LocalControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.proxyGroupBox);
this.Controls.Add(this.trackInfoBox);
this.Controls.Add(this.connectBtn);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.bigAlbumPicture);
this.Name = "LocalControl";
this.Size = new System.Drawing.Size(970, 670);
((System.ComponentModel.ISupportInitialize)(this.bigAlbumPicture)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.trackInfoBox.ResumeLayout(false);
this.trackInfoBox.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.smallAlbumPicture)).EndInit();
this.proxyGroupBox.ResumeLayout(false);
this.proxyGroupBox.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.proxyPortUpDown)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox bigAlbumPicture;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button connectBtn;
private System.Windows.Forms.GroupBox trackInfoBox;
private System.Windows.Forms.PictureBox smallAlbumPicture;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label volumeLabel;
private System.Windows.Forms.Label isPlayingLabel;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox playTextBox;
private System.Windows.Forms.Button playUrlBtn;
private System.Windows.Forms.TextBox contextTextBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button playBtn;
private System.Windows.Forms.Button skipBtn;
private System.Windows.Forms.Button prevBtn;
private System.Windows.Forms.Button pauseBtn;
private System.Windows.Forms.LinkLabel artistLinkLabel;
private System.Windows.Forms.LinkLabel titleLinkLabel;
private System.Windows.Forms.LinkLabel albumLinkLabel;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label timeLabel;
private System.Windows.Forms.ProgressBar timeProgressBar;
private System.Windows.Forms.Label clientVersionLabel;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label versionLabel;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label repeatShuffleLabel;
private System.Windows.Forms.Label advertLabel;
private System.Windows.Forms.Button volumeUpBtn;
private System.Windows.Forms.Button volumeDownBtn;
private System.Windows.Forms.Label volumeMixerLabel;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.GroupBox proxyGroupBox;
private System.Windows.Forms.TextBox proxyPasswordTextBox;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.TextBox proxyUsernameTextBox;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.TextBox proxyHostTextBox;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Button applyProxyBtn;
private System.Windows.Forms.NumericUpDown proxyPortUpDown;
}
}

View File

@ -1,251 +0,0 @@
using SpotifyAPI.Local;
using SpotifyAPI.Local.Enums;
using SpotifyAPI.Local.Models;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Windows.Forms;
namespace SpotifyAPI.Example
{
public partial class LocalControl : UserControl
{
private readonly SpotifyLocalAPIConfig _config;
private SpotifyLocalAPI _spotify;
private Track _currentTrack;
public LocalControl()
{
InitializeComponent();
_config = new SpotifyLocalAPIConfig
{
ProxyConfig = new ProxyConfig()
};
_spotify = new SpotifyLocalAPI(_config);
_spotify.OnPlayStateChange += _spotify_OnPlayStateChange;
_spotify.OnTrackChange += _spotify_OnTrackChange;
_spotify.OnTrackTimeChange += _spotify_OnTrackTimeChange;
_spotify.OnVolumeChange += _spotify_OnVolumeChange;
//_spotify.SynchronizingObject = this;
artistLinkLabel.Click += (sender, args) => Process.Start(artistLinkLabel.Tag.ToString());
albumLinkLabel.Click += (sender, args) => Process.Start(albumLinkLabel.Tag.ToString());
titleLinkLabel.Click += (sender, args) => Process.Start(titleLinkLabel.Tag.ToString());
}
public void Connect()
{
if (!SpotifyLocalAPI.IsSpotifyRunning())
{
MessageBox.Show(@"Spotify isn't running!");
return;
}
if (!SpotifyLocalAPI.IsSpotifyWebHelperRunning())
{
MessageBox.Show(@"SpotifyWebHelper isn't running!");
return;
}
bool successful = _spotify.Connect();
if (successful)
{
connectBtn.Text = @"Connection to Spotify successful";
connectBtn.Enabled = false;
UpdateInfos();
_spotify.ListenForEvents = true;
}
else
{
DialogResult res = MessageBox.Show(@"Couldn't connect to the spotify client. Retry?", @"Spotify", MessageBoxButtons.YesNo);
if (res == DialogResult.Yes)
Connect();
}
}
public void UpdateInfos()
{
StatusResponse status = _spotify.GetStatus();
if (status == null)
return;
//Basic Spotify Infos
UpdatePlayingStatus(status.Playing);
clientVersionLabel.Text = status.ClientVersion;
versionLabel.Text = status.Version.ToString();
repeatShuffleLabel.Text = status.Repeat + @" and " + status.Shuffle;
if (status.Track != null) //Update track infos
UpdateTrack(status.Track);
RefreshVolumeMixerVolume();
}
public async void UpdateTrack(Track track)
{
_currentTrack = track;
advertLabel.Text = track.IsAd() ? "ADVERT" : "";
timeProgressBar.Maximum = track.Length;
if (track.IsAd())
return; //Don't process further, maybe null values
titleLinkLabel.Text = track.TrackResource?.Name;
titleLinkLabel.Tag = track.TrackResource?.Uri;
artistLinkLabel.Text = track.ArtistResource?.Name;
artistLinkLabel.Tag = track.ArtistResource?.Uri;
albumLinkLabel.Text = track.AlbumResource?.Name;
albumLinkLabel.Tag = track.AlbumResource?.Uri;
SpotifyUri uri = track.TrackResource?.ParseUri();
trackInfoBox.Text = $@"Track Info - {uri?.Id}";
bigAlbumPicture.Image = track.AlbumResource != null ? await track.GetAlbumArtAsync(AlbumArtSize.Size640, _config.ProxyConfig) : null;
smallAlbumPicture.Image = track.AlbumResource != null ? await track.GetAlbumArtAsync(AlbumArtSize.Size160, _config.ProxyConfig) : null;
}
public void UpdatePlayingStatus(bool playing)
{
isPlayingLabel.Text = playing.ToString();
}
public void RefreshVolumeMixerVolume()
{
volumeMixerLabel.Text = _spotify.GetSpotifyVolume().ToString(CultureInfo.InvariantCulture);
}
private void applyProxyBtn_Click(object sender, EventArgs e)
{
_config.ProxyConfig.Host = proxyHostTextBox.Text;
_config.ProxyConfig.Port = (int)proxyPortUpDown.Value;
_config.ProxyConfig.Username = proxyUsernameTextBox.Text;
_config.ProxyConfig.Password = proxyPasswordTextBox.Text;
bool connected = _spotify.ListenForEvents;
if (connected)
{
// Reconnect using new proxy
_spotify.ListenForEvents = false;
_spotify.OnPlayStateChange -= _spotify_OnPlayStateChange;
_spotify.OnTrackChange -= _spotify_OnTrackChange;
_spotify.OnTrackTimeChange -= _spotify_OnTrackTimeChange;
_spotify.OnVolumeChange -= _spotify_OnVolumeChange;
_spotify.Dispose();
_spotify = new SpotifyLocalAPI(_config);
_spotify.OnPlayStateChange += _spotify_OnPlayStateChange;
_spotify.OnTrackChange += _spotify_OnTrackChange;
_spotify.OnTrackTimeChange += _spotify_OnTrackTimeChange;
_spotify.OnVolumeChange += _spotify_OnVolumeChange;
connectBtn.Text = @"Reconnecting...";
Connect();
}
}
private void _spotify_OnVolumeChange(object sender, VolumeChangeEventArgs e)
{
if (InvokeRequired)
{
Invoke(new Action(() => _spotify_OnVolumeChange(sender, e)));
return;
}
volumeLabel.Text = (e.NewVolume * 100).ToString(CultureInfo.InvariantCulture);
}
private void _spotify_OnTrackTimeChange(object sender, TrackTimeChangeEventArgs e)
{
if (InvokeRequired)
{
Invoke(new Action(() => _spotify_OnTrackTimeChange(sender, e)));
return;
}
timeLabel.Text = $@"{FormatTime(e.TrackTime)}/{FormatTime(_currentTrack.Length)}";
if(e.TrackTime < _currentTrack.Length)
timeProgressBar.Value = (int)e.TrackTime;
}
private void _spotify_OnTrackChange(object sender, TrackChangeEventArgs e)
{
if (InvokeRequired)
{
Invoke(new Action(() => _spotify_OnTrackChange(sender, e)));
return;
}
UpdateTrack(e.NewTrack);
}
private void _spotify_OnPlayStateChange(object sender, PlayStateEventArgs e)
{
if (InvokeRequired)
{
Invoke(new Action(() => _spotify_OnPlayStateChange(sender, e)));
return;
}
UpdatePlayingStatus(e.Playing);
}
private void connectBtn_Click(object sender, EventArgs e)
{
Connect();
}
private async void playUrlBtn_Click(object sender, EventArgs e)
{
await _spotify.PlayURL(playTextBox.Text, contextTextBox.Text);
}
private async void playBtn_Click(object sender, EventArgs e)
{
await _spotify.Play();
}
private async void pauseBtn_Click(object sender, EventArgs e)
{
await _spotify.Pause();
}
private void prevBtn_Click(object sender, EventArgs e)
{
_spotify.Previous();
}
private void skipBtn_Click(object sender, EventArgs e)
{
_spotify.Skip();
}
private void volumeUpBtn_Click(object sender, EventArgs e)
{
float currentVolume = _spotify.GetSpotifyVolume();
float newVolume = currentVolume + 2.0f;
_spotify.SetSpotifyVolume(newVolume >= 100.0f ? 100.0f : newVolume);
RefreshVolumeMixerVolume();
}
private void volumeDownBtn_Click(object sender, EventArgs e)
{
float currentVolume = _spotify.GetSpotifyVolume();
float newVolume = currentVolume - 2.0f;
_spotify.SetSpotifyVolume(newVolume <= 0.0f ? 0.0f : newVolume);
RefreshVolumeMixerVolume();
}
private static String FormatTime(double sec)
{
TimeSpan span = TimeSpan.FromSeconds(sec);
String secs = span.Seconds.ToString(), mins = span.Minutes.ToString();
if (secs.Length < 2)
secs = "0" + secs;
return mins + ":" + secs;
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,19 +0,0 @@
using System;
using System.Windows.Forms;
namespace SpotifyAPI.Example
{
internal static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ExampleForm());
}
}
}

View File

@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("SpotifyAPI.Example")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SpotifyAPI.Example")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("22aa2afd-11be-4d66-b7d8-c337877ce14b")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,71 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.34209
//
// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
// der Code neu generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SpotifyAPI.Example.Properties
{
/// <summary>
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
/// </summary>
// Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
// über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SpotifyAPI.Example.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
/// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -1,117 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,30 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SpotifyAPI.Example.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -1,7 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -1,112 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C8968A03-497E-4BAB-B492-5651AE7E0C06}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SpotifyAPI.Example</RootNamespace>
<AssemblyName>SpotifyAPI.Example</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ExampleForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ExampleForm.Designer.cs">
<DependentUpon>ExampleForm.cs</DependentUpon>
</Compile>
<Compile Include="LocalControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="LocalControl.Designer.cs">
<DependentUpon>LocalControl.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WebControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="WebControl.Designer.cs">
<DependentUpon>WebControl.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="ExampleForm.resx">
<DependentUpon>ExampleForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LocalControl.resx">
<DependentUpon>LocalControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="WebControl.resx">
<DependentUpon>WebControl.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SpotifyAPI\SpotifyAPI.csproj">
<Project>{ebbe35e2-7b91-4d7d-b8fc-3a0472f5119d}</Project>
<Name>SpotifyAPI</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,420 +0,0 @@
namespace SpotifyAPI.Example
{
partial class WebControl
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Komponenten-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.authButton = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.savedTracksListView = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.savedTracksCountLabel = new System.Windows.Forms.Label();
this.playlistsListBox = new System.Windows.Forms.ListBox();
this.playlistsCountLabel = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.displayNameLabel = new System.Windows.Forms.Label();
this.countryLabel = new System.Windows.Forms.Label();
this.emailLabel = new System.Windows.Forms.Label();
this.accountLabel = new System.Windows.Forms.Label();
this.avatarPictureBox = new System.Windows.Forms.PictureBox();
this.proxyGroupBox = new System.Windows.Forms.GroupBox();
this.proxyPortUpDown = new System.Windows.Forms.NumericUpDown();
this.proxyPasswordTextBox = new System.Windows.Forms.TextBox();
this.label15 = new System.Windows.Forms.Label();
this.proxyUsernameTextBox = new System.Windows.Forms.TextBox();
this.label14 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.proxyHostTextBox = new System.Windows.Forms.TextBox();
this.label12 = new System.Windows.Forms.Label();
this.applyProxyBtn = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.avatarPictureBox)).BeginInit();
this.proxyGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.proxyPortUpDown)).BeginInit();
this.SuspendLayout();
//
// authButton
//
this.authButton.Location = new System.Drawing.Point(3, 3);
this.authButton.Name = "authButton";
this.authButton.Size = new System.Drawing.Size(964, 48);
this.authButton.TabIndex = 0;
this.authButton.Text = "Authenticate SpotifyWeb API";
this.authButton.UseVisualStyleBackColor = true;
this.authButton.Click += new System.EventHandler(this.authButton_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(3, 251);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(100, 17);
this.label3.TabIndex = 5;
this.label3.Text = "Display-Name:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(3, 268);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(61, 17);
this.label4.TabIndex = 6;
this.label4.Text = "Country:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point(3, 285);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(51, 17);
this.label5.TabIndex = 7;
this.label5.Text = "E-Mail:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(3, 302);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 17);
this.label1.TabIndex = 8;
this.label1.Text = "Account-Type:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(240, 73);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(100, 17);
this.label2.TabIndex = 9;
this.label2.Text = "Saved-Tracks:";
//
// savedTracksListView
//
this.savedTracksListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3});
this.savedTracksListView.FullRowSelect = true;
this.savedTracksListView.Location = new System.Drawing.Point(243, 93);
this.savedTracksListView.Name = "savedTracksListView";
this.savedTracksListView.Size = new System.Drawing.Size(385, 563);
this.savedTracksListView.TabIndex = 10;
this.savedTracksListView.UseCompatibleStateImageBehavior = false;
this.savedTracksListView.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Title";
this.columnHeader1.Width = 120;
//
// columnHeader2
//
this.columnHeader2.Text = "Artist";
this.columnHeader2.Width = 117;
//
// columnHeader3
//
this.columnHeader3.Text = "Album";
this.columnHeader3.Width = 131;
//
// savedTracksCountLabel
//
this.savedTracksCountLabel.AutoSize = true;
this.savedTracksCountLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.savedTracksCountLabel.Location = new System.Drawing.Point(346, 73);
this.savedTracksCountLabel.Name = "savedTracksCountLabel";
this.savedTracksCountLabel.Size = new System.Drawing.Size(13, 17);
this.savedTracksCountLabel.TabIndex = 11;
this.savedTracksCountLabel.Text = "-";
//
// playlistsListBox
//
this.playlistsListBox.FormattingEnabled = true;
this.playlistsListBox.Location = new System.Drawing.Point(634, 93);
this.playlistsListBox.Name = "playlistsListBox";
this.playlistsListBox.Size = new System.Drawing.Size(305, 563);
this.playlistsListBox.TabIndex = 12;
//
// playlistsCountLabel
//
this.playlistsCountLabel.AutoSize = true;
this.playlistsCountLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.playlistsCountLabel.Location = new System.Drawing.Point(700, 73);
this.playlistsCountLabel.Name = "playlistsCountLabel";
this.playlistsCountLabel.Size = new System.Drawing.Size(13, 17);
this.playlistsCountLabel.TabIndex = 14;
this.playlistsCountLabel.Text = "-";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label7.Location = new System.Drawing.Point(631, 73);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(63, 17);
this.label7.TabIndex = 13;
this.label7.Text = "Playlists:";
//
// displayNameLabel
//
this.displayNameLabel.AutoSize = true;
this.displayNameLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.displayNameLabel.Location = new System.Drawing.Point(109, 251);
this.displayNameLabel.Name = "displayNameLabel";
this.displayNameLabel.Size = new System.Drawing.Size(13, 17);
this.displayNameLabel.TabIndex = 15;
this.displayNameLabel.Text = "-";
//
// countryLabel
//
this.countryLabel.AutoSize = true;
this.countryLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.countryLabel.Location = new System.Drawing.Point(70, 268);
this.countryLabel.Name = "countryLabel";
this.countryLabel.Size = new System.Drawing.Size(13, 17);
this.countryLabel.TabIndex = 16;
this.countryLabel.Text = "-";
//
// emailLabel
//
this.emailLabel.AutoSize = true;
this.emailLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.emailLabel.Location = new System.Drawing.Point(60, 285);
this.emailLabel.Name = "emailLabel";
this.emailLabel.Size = new System.Drawing.Size(13, 17);
this.emailLabel.TabIndex = 17;
this.emailLabel.Text = "-";
//
// accountLabel
//
this.accountLabel.AutoSize = true;
this.accountLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.accountLabel.Location = new System.Drawing.Point(109, 302);
this.accountLabel.Name = "accountLabel";
this.accountLabel.Size = new System.Drawing.Size(13, 17);
this.accountLabel.TabIndex = 18;
this.accountLabel.Text = "-";
//
// avatarPictureBox
//
this.avatarPictureBox.Location = new System.Drawing.Point(3, 322);
this.avatarPictureBox.Name = "avatarPictureBox";
this.avatarPictureBox.Size = new System.Drawing.Size(234, 212);
this.avatarPictureBox.TabIndex = 19;
this.avatarPictureBox.TabStop = false;
//
// proxyGroupBox
//
this.proxyGroupBox.Controls.Add(this.proxyPortUpDown);
this.proxyGroupBox.Controls.Add(this.proxyPasswordTextBox);
this.proxyGroupBox.Controls.Add(this.label15);
this.proxyGroupBox.Controls.Add(this.proxyUsernameTextBox);
this.proxyGroupBox.Controls.Add(this.label14);
this.proxyGroupBox.Controls.Add(this.label13);
this.proxyGroupBox.Controls.Add(this.proxyHostTextBox);
this.proxyGroupBox.Controls.Add(this.label12);
this.proxyGroupBox.Controls.Add(this.applyProxyBtn);
this.proxyGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F);
this.proxyGroupBox.Location = new System.Drawing.Point(6, 73);
this.proxyGroupBox.Name = "proxyGroupBox";
this.proxyGroupBox.Size = new System.Drawing.Size(231, 167);
this.proxyGroupBox.TabIndex = 20;
this.proxyGroupBox.TabStop = false;
this.proxyGroupBox.Text = "Proxy Config";
//
// proxyPortUpDown
//
this.proxyPortUpDown.Location = new System.Drawing.Point(50, 47);
this.proxyPortUpDown.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.proxyPortUpDown.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.proxyPortUpDown.Name = "proxyPortUpDown";
this.proxyPortUpDown.Size = new System.Drawing.Size(76, 24);
this.proxyPortUpDown.TabIndex = 6;
this.proxyPortUpDown.Value = new decimal(new int[] {
80,
0,
0,
0});
//
// proxyPasswordTextBox
//
this.proxyPasswordTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.proxyPasswordTextBox.Location = new System.Drawing.Point(85, 103);
this.proxyPasswordTextBox.Name = "proxyPasswordTextBox";
this.proxyPasswordTextBox.Size = new System.Drawing.Size(140, 20);
this.proxyPasswordTextBox.TabIndex = 42;
//
// label15
//
this.label15.AutoSize = true;
this.label15.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label15.Location = new System.Drawing.Point(6, 104);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(73, 17);
this.label15.TabIndex = 41;
this.label15.Text = "Password:";
//
// proxyUsernameTextBox
//
this.proxyUsernameTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.proxyUsernameTextBox.Location = new System.Drawing.Point(89, 77);
this.proxyUsernameTextBox.Name = "proxyUsernameTextBox";
this.proxyUsernameTextBox.Size = new System.Drawing.Size(136, 20);
this.proxyUsernameTextBox.TabIndex = 40;
//
// label14
//
this.label14.AutoSize = true;
this.label14.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label14.Location = new System.Drawing.Point(6, 78);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(77, 17);
this.label14.TabIndex = 39;
this.label14.Text = "Username:";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label13.Location = new System.Drawing.Point(6, 51);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(38, 17);
this.label13.TabIndex = 37;
this.label13.Text = "Port:";
//
// proxyHostTextBox
//
this.proxyHostTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.proxyHostTextBox.Location = new System.Drawing.Point(49, 21);
this.proxyHostTextBox.Name = "proxyHostTextBox";
this.proxyHostTextBox.Size = new System.Drawing.Size(176, 20);
this.proxyHostTextBox.TabIndex = 36;
//
// label12
//
this.label12.AutoSize = true;
this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label12.Location = new System.Drawing.Point(6, 22);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(41, 17);
this.label12.TabIndex = 36;
this.label12.Text = "Host:";
//
// applyProxyBtn
//
this.applyProxyBtn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.applyProxyBtn.Location = new System.Drawing.Point(147, 136);
this.applyProxyBtn.Name = "applyProxyBtn";
this.applyProxyBtn.Size = new System.Drawing.Size(78, 25);
this.applyProxyBtn.TabIndex = 0;
this.applyProxyBtn.Text = "Apply";
this.applyProxyBtn.UseVisualStyleBackColor = true;
this.applyProxyBtn.Click += new System.EventHandler(this.applyProxyBtn_Click);
//
// WebControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.proxyGroupBox);
this.Controls.Add(this.avatarPictureBox);
this.Controls.Add(this.accountLabel);
this.Controls.Add(this.emailLabel);
this.Controls.Add(this.countryLabel);
this.Controls.Add(this.displayNameLabel);
this.Controls.Add(this.playlistsCountLabel);
this.Controls.Add(this.label7);
this.Controls.Add(this.playlistsListBox);
this.Controls.Add(this.savedTracksCountLabel);
this.Controls.Add(this.savedTracksListView);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.authButton);
this.Name = "WebControl";
this.Size = new System.Drawing.Size(970, 670);
((System.ComponentModel.ISupportInitialize)(this.avatarPictureBox)).EndInit();
this.proxyGroupBox.ResumeLayout(false);
this.proxyGroupBox.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.proxyPortUpDown)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button authButton;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ListView savedTracksListView;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.Label savedTracksCountLabel;
private System.Windows.Forms.ListBox playlistsListBox;
private System.Windows.Forms.Label playlistsCountLabel;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label displayNameLabel;
private System.Windows.Forms.Label countryLabel;
private System.Windows.Forms.Label emailLabel;
private System.Windows.Forms.Label accountLabel;
private System.Windows.Forms.PictureBox avatarPictureBox;
private System.Windows.Forms.GroupBox proxyGroupBox;
private System.Windows.Forms.NumericUpDown proxyPortUpDown;
private System.Windows.Forms.TextBox proxyPasswordTextBox;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.TextBox proxyUsernameTextBox;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.TextBox proxyHostTextBox;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Button applyProxyBtn;
}
}

View File

@ -1,140 +0,0 @@
using SpotifyAPI.Web;
using SpotifyAPI.Web.Auth;
using SpotifyAPI.Web.Enums;
using SpotifyAPI.Web.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;
using Image = System.Drawing.Image;
namespace SpotifyAPI.Example
{
public partial class WebControl : UserControl
{
private readonly ProxyConfig _proxyConfig;
private SpotifyWebAPI _spotify;
private PrivateProfile _profile;
private List<FullTrack> _savedTracks;
private List<SimplePlaylist> _playlists;
public WebControl()
{
InitializeComponent();
_proxyConfig = new ProxyConfig();
_savedTracks = new List<FullTrack>();
}
private async void InitialSetup()
{
if (InvokeRequired)
{
Invoke(new Action(InitialSetup));
return;
}
authButton.Enabled = false;
_profile = await _spotify.GetPrivateProfileAsync();
_savedTracks = GetSavedTracks();
savedTracksCountLabel.Text = _savedTracks.Count.ToString();
_savedTracks.ForEach(track => savedTracksListView.Items.Add(new ListViewItem()
{
Text = track.Name,
SubItems = { string.Join(",", track.Artists.Select(source => source.Name)), track.Album.Name }
}));
_playlists = GetPlaylists();
playlistsCountLabel.Text = _playlists.Count.ToString();
_playlists.ForEach(playlist => playlistsListBox.Items.Add(playlist.Name));
displayNameLabel.Text = _profile.DisplayName;
countryLabel.Text = _profile.Country;
emailLabel.Text = _profile.Email;
accountLabel.Text = _profile.Product;
if (_profile.Images != null && _profile.Images.Count > 0)
{
using (WebClient wc = new WebClient())
{
byte[] imageBytes = await wc.DownloadDataTaskAsync(new Uri(_profile.Images[0].Url));
using (MemoryStream stream = new MemoryStream(imageBytes))
avatarPictureBox.Image = Image.FromStream(stream);
}
}
}
private List<FullTrack> GetSavedTracks()
{
Paging<SavedTrack> savedTracks = _spotify.GetSavedTracks();
List<FullTrack> list = savedTracks.Items.Select(track => track.Track).ToList();
while (savedTracks.Next != null)
{
savedTracks = _spotify.GetSavedTracks(20, savedTracks.Offset + savedTracks.Limit);
list.AddRange(savedTracks.Items.Select(track => track.Track));
}
return list;
}
private List<SimplePlaylist> GetPlaylists()
{
Paging<SimplePlaylist> playlists = _spotify.GetUserPlaylists(_profile.Id);
List<SimplePlaylist> list = playlists.Items.ToList();
while (playlists.Next != null)
{
playlists = _spotify.GetUserPlaylists(_profile.Id, 20, playlists.Offset + playlists.Limit);
list.AddRange(playlists.Items);
}
return list;
}
private void authButton_Click(object sender, EventArgs e)
{
Task.Run(() => RunAuthentication());
}
private async void RunAuthentication()
{
WebAPIFactory webApiFactory = new WebAPIFactory(
"http://localhost",
8000,
"26d287105e31491889f3cd293d85bfea",
Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibraryRead |
Scope.UserReadPrivate | Scope.UserFollowRead | Scope.UserReadBirthdate | Scope.UserTopRead | Scope.PlaylistReadCollaborative |
Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState | Scope.UserModifyPlaybackState,
_proxyConfig);
try
{
_spotify = await webApiFactory.GetWebApi();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
if (_spotify == null)
return;
InitialSetup();
}
private void applyProxyBtn_Click(object sender, EventArgs e)
{
_proxyConfig.Host = proxyHostTextBox.Text;
_proxyConfig.Port = (int)proxyPortUpDown.Value;
_proxyConfig.Username = proxyUsernameTextBox.Text;
_proxyConfig.Password = proxyPasswordTextBox.Text;
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("SpotifyAPI.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HEAVEN KILLERS RELEASE GROUP")]
[assembly: AssemblyProduct("SpotifyAPI.Tests")]
[assembly: AssemblyCopyright("Copyright © HEAVEN KILLERS RELEASE GROUP 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("015955d9-d411-4fcc-afc9-bc785216b9b2")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,86 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A06CE1BA-B2C4-4C3C-9E79-D2E8D36DDF0B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SpotifyAPI.Tests</RootNamespace>
<AssemblyName>SpotifyAPI.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\packages\Castle.Core.4.2.1\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.7.145.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.7.145\lib\net45\Moq.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.8.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ProxyConfigTest.cs" />
<Compile Include="SpotifyUriTest.cs" />
<Compile Include="SpotifyWebAPITest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UtilTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SpotifyAPI\SpotifyAPI.csproj">
<Project>{ebbe35e2-7b91-4d7d-b8fc-3a0472f5119d}</Project>
<Name>SpotifyAPI</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="fixtures\private-user.json" />
<None Include="fixtures\public-user.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,54 +0,0 @@
using NUnit.Framework;
using SpotifyAPI.Local.Models;
using SpotifyAPI.Local.Enums;
using System;
namespace SpotifyAPI.Tests
{
[TestFixture]
public class SpotifyUriTest
{
[Test]
public void ShouldThrowArgumentExceptionForInvalidUri()
{
Assert.Throws<ArgumentException>(() => SpotifyUri.Parse("asdafadfgsrsegqejfa"));
}
[Test]
public void ShouldCorrectlyParseTrackUri()
{
string testUri = "spotify:track:3QOruXa2lvqIFvOOa2rYyJ";
SpotifyUri uri = SpotifyUri.Parse(testUri);
Assert.AreEqual(uri.Base, "spotify");
Assert.AreEqual(uri.Type, UriType.track);
Assert.AreEqual(uri.Id, "3QOruXa2lvqIFvOOa2rYyJ");
Assert.AreEqual(uri.ToString(), testUri);
}
[Test]
public void ShouldCorrectlyParsePlaylistUri()
{
string testUri = "spotify:user:spotifycharts:playlist:37i9dQZEVXbMDoHDwVN2tF";
SpotifyUri uri = SpotifyUri.Parse(testUri);
Assert.AreEqual(uri.Base, "spotify");
Assert.AreEqual(uri.Type, UriType.playlist);
Assert.AreEqual(uri.Id, "37i9dQZEVXbMDoHDwVN2tF");
Assert.AreEqual(uri.GetUriPropValue(UriType.user), "spotifycharts");
Assert.AreEqual(uri.ToString(), testUri);
}
[Test]
public void ShouldHandleNotExistingUriProperty()
{
string testUri = "spotify:track:3QOruXa2lvqIFvOOa2rYyJ";
SpotifyUri uri = SpotifyUri.Parse(testUri);
Assert.DoesNotThrow(() => uri.GetUriPropValue(UriType.user));
Assert.IsNull(uri.GetUriPropValue(UriType.user));
}
}
}

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="4.2.1" targetFramework="net45" />
<package id="Moq" version="4.7.145" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
<package id="NUnit" version="3.8.1" targetFramework="net45" />
</packages>

View File

@ -0,0 +1,29 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace SpotifyAPI.Web.Auth
{
internal static class AuthUtil
{
public static void OpenBrowser(string url)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
url = url.Replace("&", "^&");
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Process.Start("xdg-open", url);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", url);
}
else
{
// throw
}
}
}
}

View File

@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using SpotifyAPI.Web.Enums;
using SpotifyAPI.Web.Models;
using Unosquare.Labs.EmbedIO;
using Unosquare.Labs.EmbedIO.Constants;
using Unosquare.Labs.EmbedIO.Modules;
namespace SpotifyAPI.Web.Auth
{
public class AuthorizationCodeAuth : SpotifyAuthServer<AuthorizationCode>
{
public string SecretId { get; set; }
public AuthorizationCodeAuth(string redirectUri, string serverUri, Scope scope = Scope.None, string state = "")
: base("code", "AuthorizationCodeAuth", redirectUri, serverUri, scope, state)
{
}
public AuthorizationCodeAuth(string clientId, string secretId, string redirectUri, string serverUri, Scope scope = Scope.None, string state = "")
: this(redirectUri, serverUri, scope, state)
{
ClientId = clientId;
SecretId = secretId;
}
private bool ShouldRegisterNewApp()
{
return string.IsNullOrEmpty(SecretId) || string.IsNullOrEmpty(ClientId);
}
public override string GetUri()
{
return ShouldRegisterNewApp() ? $"{RedirectUri}/start.html#{State}" : base.GetUri();
}
protected override WebServer AdaptWebServer(WebServer webServer) => webServer.WithWebApiController<AuthorizationCodeAuthController>();
public async Task<Token> ExchangeCode(string code)
{
string auth = Convert.ToBase64String(Encoding.UTF8.GetBytes(ClientId + ":" + SecretId));
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("grant_type", "authorization_code"),
new KeyValuePair<string, string>("code", code),
new KeyValuePair<string, string>("redirect_uri", RedirectUri)
};
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Basic {auth}");
HttpContent content = new FormUrlEncodedContent(args);
HttpResponseMessage resp = await client.PostAsync("https://accounts.spotify.com/api/token", content);
string msg = await resp.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<Token>(msg);
}
}
public class AuthorizationCode
{
public string Code { get; set; }
public string Error { get; set; }
}
internal class AuthorizationCodeAuthController : WebApiController
{
[WebApiHandler(HttpVerbs.Get, "/")]
public Task<bool> GetEmpty(WebServer server, HttpListenerContext context)
{
string state = context.Request.QueryString["state"];
AuthorizationCodeAuth.Instances.TryGetValue(state, out SpotifyAuthServer<AuthorizationCode> auth);
string code = null;
string error = context.Request.QueryString["error"];
if (error == null)
code = context.Request.QueryString["code"];
Task.Factory.StartNew(() => auth?.TriggerAuth(new AuthorizationCode
{
Code = code,
Error = error
}));
return context.StringResponseAsync("OK - This window can be closed now");
}
[WebApiHandler(HttpVerbs.Post, "/")]
public bool PostValues(WebServer server, HttpListenerContext context)
{
Dictionary<string, object> formParams = context.RequestFormDataDictionary();
string state = (string) formParams["state"];
AuthorizationCodeAuth.Instances.TryGetValue(state, out SpotifyAuthServer<AuthorizationCode> authServer);
AuthorizationCodeAuth auth = (AuthorizationCodeAuth) authServer;
auth.ClientId = (string) formParams["clientId"];
auth.SecretId = (string) formParams["secretId"];
string uri = auth.GetUri();
context.Response.Redirect(uri);
return true;
}
}
}

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using SpotifyAPI.Web.Models;
namespace SpotifyAPI.Web.Auth
{
public class CredentialsAuth
{
public string ClientSecret { get; set; }
public string ClientId { get; set; }
public CredentialsAuth(string clientId, string clientSecret)
{
ClientId = clientId;
ClientSecret = clientSecret;
}
public async Task<Token> GetToken()
{
string auth = Convert.ToBase64String(Encoding.UTF8.GetBytes(ClientId + ":" + ClientSecret));
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("grant_type", "client_credentials")
};
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Basic {auth}");
HttpContent content = new FormUrlEncodedContent(args);
HttpResponseMessage resp = await client.PostAsync("https://accounts.spotify.com/api/token", content);
string msg = await resp.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<Token>(msg);
}
}
}

View File

@ -0,0 +1,62 @@
using System.Net;
using System.Threading.Tasks;
using SpotifyAPI.Web.Enums;
using SpotifyAPI.Web.Models;
using Unosquare.Labs.EmbedIO;
using Unosquare.Labs.EmbedIO.Constants;
using Unosquare.Labs.EmbedIO.Modules;
namespace SpotifyAPI.Web.Auth
{
public class ImplictGrantAuth : SpotifyAuthServer<Token>
{
public ImplictGrantAuth(string clientId, string redirectUri, string serverUri, Scope scope = Scope.None, string state = "") :
base("token", "ImplicitGrantAuth", redirectUri, serverUri, scope, state)
{
ClientId = clientId;
}
protected override WebServer AdaptWebServer(WebServer webServer)
{
return webServer.WithWebApiController<ImplictGrantAuthController>();
}
}
public class ImplictGrantAuthController : WebApiController
{
[WebApiHandler(HttpVerbs.Get, "/auth")]
public Task<bool> GetAuth(WebServer server, HttpListenerContext context)
{
string state = context.Request.QueryString["state"];
SpotifyAuthServer<Token> auth = ImplictGrantAuth.GetByState(state);
if (auth == null)
return context.StringResponseAsync(
$"Failed - Unable to find auth request with state \"{state}\" - Please retry");
Token token;
string error = context.Request.QueryString["error"];
if (error == null)
{
string accessToken = context.Request.QueryString["access_token"];
string tokenType = context.Request.QueryString["token_type"];
string expiresIn = context.Request.QueryString["expires_in"];
token = new Token
{
AccessToken = accessToken,
ExpiresIn = double.Parse(expiresIn),
TokenType = tokenType
};
}
else
{
token = new Token()
{
Error = error
};
}
Task.Factory.StartNew(() => auth?.TriggerAuth(token));
return context.StringResponseAsync("OK - This window can be closed now");
}
}
}

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,77 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="css/bulma.min.css"/>
<style>
p {
font-size: 1.0rem;
}
.demo-image {
margin: 30px;
border: 20px solid #31BD5B;
}
</style>
</head>
<body>
<div class="container">
<div class="notification has-text-centered">
<h1 class="title is-1">Spotify Authentication</h1>
</div>
<div class="content">
<h2 class="title is-2">Introduction</h2>
<!-- <p>
In order to use this app, you will need to follow the steps below.
You will create a Spotify Developer App, which allows applications like this to securely access your spotify data, like playlists or your currently playing track.
<p class="notification is-warning">
If this page looks similar, you may already have a Spotify Developer App created. In this case, you can skip to the bottom and input your <code>client_id</code> and <code>client_secret</code>
</p>
</p>
<h2 class="title is-2">1. Login at your Developer Dashboard</h2>
<p>
Visit <a href="https://developer.spotify.com/dashboard/" rel="nofollow noreferer" target="_blank">https://developer.spotify.com/dashboard/</a> and login with your Spotify Account.
<img class="demo-image" src="images/1.png" width="700" alt=""/>
</p>
<h2 class="title is-2">2. Create a new ClientID</h2>
<p>
Visit <a href="https://developer.spotify.com/dashboard/" rel="nofollow noreferer" target="_blank">https://developer.spotify.com/dashboard/</a> and login with your Spotify Account.
<img class="demo-image" src="images/2.png" width="700" alt=""/>
</p>-->
<form action="/" method="post" style="margin-bottom: 20px">
<div class="field">
<label class="label" for="clientId">Client ID</label>
<div class="control">
<input class="input" type="text" placeholder="Client ID" name="clientId" id="clientId">
</div>
</div>
<div class="field">
<label class="label" for="secretId">Secret ID</label>
<div class="control">
<input class="input" type="password" placeholder="Secret ID" name="secretId" id="secretId">
</div>
</div>
<input class="input is-hidden" hidden name="state" id="state"/>
<div class="field is-grouped">
<div class="control">
<button class="button is-link">Submit</button>
</div>
</div>
</form>
</div>
</div>
<script type="text/javascript">
const hash = window.location.hash.split("#")[1];
document.addEventListener("DOMContentLoaded", () => {
const input = document.getElementById("state");
input.value = hash;
});
</script>
</body>
</html>

View File

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script type="text/javascript">
const serialize = (obj) => {
var str = [];
for (let p in obj)
if (obj.hasOwnProperty(p)) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
}
return str.join("&");
}
document.addEventListener("DOMContentLoaded",
() => {
const hash = window.location.hash.substr(1);
let result;
if (hash === "") {
const params = (new URL(document.location)).searchParams;
result = {
error: params.get("error"),
state: params.get("state")
}
} else {
result = hash.split('&').reduce(function(res, item) {
const parts = item.split('=');
res[parts[0]] = parts[1];
return res;
},
{});
}
window.location = `/auth?${serialize(result)}`;
});
</script>
</body>
</html>

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EmbedIO" Version="1.15.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SpotifyAPI.Web\SpotifyAPI.Web.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\**\*" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using SpotifyAPI.Web.Enums;
using Unosquare.Labs.EmbedIO;
using Unosquare.Labs.EmbedIO.Modules;
namespace SpotifyAPI.Web.Auth
{
public abstract class SpotifyAuthServer<T>
{
public string ClientId { get; set; }
public string ServerUri { get; set; }
public string RedirectUri { get; set; }
public string State { get; set; }
public Scope Scope { get; set; }
public bool ShowDialog { get; set; }
private readonly string _folder;
private readonly string _type;
protected CancellationTokenSource _serverSource;
public delegate void OnAuthReceived(object sender, T payload);
public event OnAuthReceived AuthReceived;
internal static readonly Dictionary<string, SpotifyAuthServer<T>> Instances = new Dictionary<string, SpotifyAuthServer<T>>();
internal SpotifyAuthServer(string type, string folder, string redirectUri, string serverUri, Scope scope = Scope.None, string state = "")
{
_type = type;
_folder = folder;
ServerUri = serverUri;
RedirectUri = redirectUri;
Scope = scope;
State = string.IsNullOrEmpty(state) ? string.Join("", Guid.NewGuid().ToString("n").Take(8)) : state;
}
public void Start()
{
Instances.Add(State, this);
_serverSource = new CancellationTokenSource();
WebServer server = AdaptWebServer(WebServer.Create(ServerUri));
server.RegisterModule(new ResourceFilesModule(typeof(ImplictGrantAuth).Assembly, $"SpotifyAPI.Web.Auth.Resources.{_folder}"));
#pragma warning disable 4014
server.RunAsync(_serverSource.Token);
#pragma warning restore 4014
}
public virtual string GetUri()
{
StringBuilder builder = new StringBuilder("https://accounts.spotify.com/authorize/?");
builder.Append("client_id=" + ClientId);
builder.Append($"&response_type={_type}");
builder.Append("&redirect_uri=" + RedirectUri);
builder.Append("&state=" + State);
builder.Append("&scope=" + Scope.GetStringAttribute(" "));
builder.Append("&show_dialog=" + ShowDialog);
return Uri.EscapeUriString(builder.ToString());
}
public void Stop(int delay = 2000)
{
if (_serverSource == null) return;
_serverSource.CancelAfter(delay);
Instances.Remove(State);
}
public void OpenBrowser()
{
string uri = GetUri();
AuthUtil.OpenBrowser(uri);
}
internal void TriggerAuth(T payload)
{
AuthReceived?.Invoke(this, payload);
}
internal static SpotifyAuthServer<T> GetByState(string state)
{
return Instances.TryGetValue(state, out SpotifyAuthServer<T> auth) ? auth : null;
}
protected abstract WebServer AdaptWebServer(WebServer webServer);
}
}

View File

@ -0,0 +1,74 @@
using System;
using System.Threading.Tasks;
using SpotifyAPI.Web.Auth;
using SpotifyAPI.Web.Enums;
using SpotifyAPI.Web.Models;
namespace SpotifyAPI.Web.Example
{
static class Program
{
private static string _clientId = ""; //"";
private static string _secretId = ""; //"";
static void Main(string[] args)
{
_clientId = string.IsNullOrEmpty(_clientId)
? System.Environment.GetEnvironmentVariable("SPOTIFY_CLIENT_ID")
: _clientId;
_secretId = string.IsNullOrEmpty(_secretId)
? System.Environment.GetEnvironmentVariable("SPOTIFY_SECRET_ID")
: _secretId;
Console.WriteLine("####### Spotify API Example #######");
Console.WriteLine("This example uses AuthorizationCodeAuth.");
Console.WriteLine(
"Tip: If you want to supply your ClientID and SecretId beforehand, use env variables (SPOTIFY_CLIENT_ID and SPOTIFY_SECRET_ID)");
AuthorizationCodeAuth auth =
new AuthorizationCodeAuth(_clientId, _secretId, "http://localhost:4002", "http://localhost:4002",
Scope.PlaylistReadPrivate | Scope.PlaylistReadCollaborative);
auth.AuthReceived += AuthOnAuthReceived;
auth.Start();
auth.OpenBrowser();
Console.ReadLine();
}
private static async void AuthOnAuthReceived(object sender, AuthorizationCode payload)
{
AuthorizationCodeAuth auth = (AuthorizationCodeAuth) sender;
auth.Stop();
Token token = await auth.ExchangeCode(payload.Code);
SpotifyWebAPI api = new SpotifyWebAPI()
{
AccessToken = token.AccessToken,
TokenType = token.TokenType
};
PrintUsefulDate(api);
}
private static async void PrintUsefulDate(SpotifyWebAPI api)
{
PrivateProfile profile = await api.GetPrivateProfileAsync();
string name = string.IsNullOrEmpty(profile.DisplayName) ? profile.Id : profile.DisplayName;
Console.WriteLine($"Hello there, {name}!");
Console.WriteLine("Your playlists:");
Paging<SimplePlaylist> playlists = await api.GetUserPlaylistsAsync(profile.Id);
do
{
playlists.Items.ForEach(playlist =>
{
Console.WriteLine($"- {playlist.Name}");
});
playlists = await api.GetNextPageAsync(playlists);
} while (playlists.HasNextPage());
}
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SpotifyAPI.Web.Auth\SpotifyAPI.Web.Auth.csproj" />
<ProjectReference Include="..\SpotifyAPI.Web\SpotifyAPI.Web.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp71</s:String></wpf:ResourceDictionary>

View File

@ -1,7 +1,7 @@
using System;
using NUnit.Framework;
namespace SpotifyAPI.Tests
namespace SpotifyAPI.Web.Tests
{
[TestFixture]
public class ProxyConfigTest

View File

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Moq" Version="4.9.0" />
<PackageReference Include="NUnit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="NUnit.Console" Version="3.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SpotifyAPI.Web\SpotifyAPI.Web.csproj" />
</ItemGroup>
</Project>

View File

@ -1,19 +1,18 @@
using Moq;
using Newtonsoft.Json;
using NUnit.Framework;
using SpotifyAPI.Web;
using SpotifyAPI.Web.Models;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Moq;
using Newtonsoft.Json;
using NUnit.Framework;
using SpotifyAPI.Web.Models;
namespace SpotifyAPI.Tests
namespace SpotifyAPI.Web.Tests
{
[TestFixture]
public class SpotifyWebAPITest
{
private static readonly string FixtureDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../fixtures/");
private static readonly string FixtureDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../fixtures/");
private Mock<IClient> _mock;
private SpotifyWebAPI _spotify;

View File

@ -1,8 +1,7 @@
using System;
using NUnit.Framework;
using SpotifyAPI.Web;
namespace SpotifyAPI.Tests
namespace SpotifyAPI.Web.Tests
{
[TestFixture]
public class UtilTest

View File

@ -1,7 +1,6 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using SpotifyAPI.Web.Models;

View File

@ -17,7 +17,7 @@ namespace SpotifyAPI.Web.Models
public string TokenType { get; set; }
[JsonProperty("expires_in")]
public int ExpiresIn { get; set; }
public double ExpiresIn { get; set; }
[JsonProperty("refresh_token")]
public string RefreshToken { get; set; }
@ -34,9 +34,14 @@ namespace SpotifyAPI.Web.Models
/// Checks if the token has expired
/// </summary>
/// <returns></returns>
public Boolean IsExpired()
public bool IsExpired()
{
return CreateDate.Add(TimeSpan.FromSeconds(ExpiresIn)) <= DateTime.Now;
}
public bool HasError()
{
return Error != null;
}
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>
</Project>

View File

@ -4,9 +4,7 @@ using SpotifyAPI.Web.Enums;
using SpotifyAPI.Web.Models;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
@ -15,9 +13,6 @@ namespace SpotifyAPI.Web
// ReSharper disable once InconsistentNaming
public sealed class SpotifyWebAPI : IDisposable
{
[Obsolete("This Property will be removed soon. Please use SpotifyWebBuilder.APIBase")]
public const string APIBase = SpotifyWebBuilder.APIBase;
private readonly SpotifyWebBuilder _builder;
public SpotifyWebAPI() : this(null)

View File

@ -1,8 +1,6 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;

View File

@ -1,13 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpotifyAPI", "SpotifyAPI\SpotifyAPI.csproj", "{EBBE35E2-7B91-4D7D-B8FC-3A0472F5119D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpotifyAPI.Web", "SpotifyAPI.Web\SpotifyAPI.Web.csproj", "{EC8A93BA-27C4-4642-B7A0-11B809C35BE4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpotifyAPI.Tests", "SpotifyAPI.Tests\SpotifyAPI.Tests.csproj", "{A06CE1BA-B2C4-4C3C-9E79-D2E8D36DDF0B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpotifyAPI.Web.Tests", "SpotifyAPI.Web.Tests\SpotifyAPI.Web.Tests.csproj", "{47FD780C-47B2-4634-9BB4-83C660101FAE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpotifyAPI.Example", "SpotifyAPI.Example\SpotifyAPI.Example.csproj", "{C8968A03-497E-4BAB-B492-5651AE7E0C06}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpotifyAPI.Web.Example", "SpotifyAPI.Web.Example\SpotifyAPI.Web.Example.csproj", "{8D1CCA36-C7C2-4A70-B194-B23D7E03F00A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpotifyAPI.Web.Auth", "SpotifyAPI.Web.Auth\SpotifyAPI.Web.Auth.csproj", "{400A3787-FDBE-4A4C-9DDD-AAEB3DCE1DF5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,20 +17,27 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EBBE35E2-7B91-4D7D-B8FC-3A0472F5119D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBBE35E2-7B91-4D7D-B8FC-3A0472F5119D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBBE35E2-7B91-4D7D-B8FC-3A0472F5119D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EBBE35E2-7B91-4D7D-B8FC-3A0472F5119D}.Release|Any CPU.Build.0 = Release|Any CPU
{A06CE1BA-B2C4-4C3C-9E79-D2E8D36DDF0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A06CE1BA-B2C4-4C3C-9E79-D2E8D36DDF0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A06CE1BA-B2C4-4C3C-9E79-D2E8D36DDF0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A06CE1BA-B2C4-4C3C-9E79-D2E8D36DDF0B}.Release|Any CPU.Build.0 = Release|Any CPU
{C8968A03-497E-4BAB-B492-5651AE7E0C06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8968A03-497E-4BAB-B492-5651AE7E0C06}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8968A03-497E-4BAB-B492-5651AE7E0C06}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8968A03-497E-4BAB-B492-5651AE7E0C06}.Release|Any CPU.Build.0 = Release|Any CPU
{EC8A93BA-27C4-4642-B7A0-11B809C35BE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC8A93BA-27C4-4642-B7A0-11B809C35BE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC8A93BA-27C4-4642-B7A0-11B809C35BE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC8A93BA-27C4-4642-B7A0-11B809C35BE4}.Release|Any CPU.Build.0 = Release|Any CPU
{47FD780C-47B2-4634-9BB4-83C660101FAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47FD780C-47B2-4634-9BB4-83C660101FAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47FD780C-47B2-4634-9BB4-83C660101FAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47FD780C-47B2-4634-9BB4-83C660101FAE}.Release|Any CPU.Build.0 = Release|Any CPU
{8D1CCA36-C7C2-4A70-B194-B23D7E03F00A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D1CCA36-C7C2-4A70-B194-B23D7E03F00A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D1CCA36-C7C2-4A70-B194-B23D7E03F00A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D1CCA36-C7C2-4A70-B194-B23D7E03F00A}.Release|Any CPU.Build.0 = Release|Any CPU
{400A3787-FDBE-4A4C-9DDD-AAEB3DCE1DF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{400A3787-FDBE-4A4C-9DDD-AAEB3DCE1DF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{400A3787-FDBE-4A4C-9DDD-AAEB3DCE1DF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{400A3787-FDBE-4A4C-9DDD-AAEB3DCE1DF5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {097062B8-0E87-43C8-BD98-61843A68BE6D}
EndGlobalSection
EndGlobal

View File

@ -1,9 +0,0 @@
namespace SpotifyAPI.Local.Enums
{
public enum AlbumArtSize
{
Size160,
Size320,
Size640
}
}

Some files were not shown because too many files have changed in this diff Show More