Updated example (Added linkabels for Track,Album and Artist)

This commit is contained in:
Johnny @PC 2014-04-12 22:46:54 +02:00
parent 58f26827ba
commit 77dadbad3d
2 changed files with 53 additions and 45 deletions

View File

@ -32,11 +32,8 @@
this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.currentName = new System.Windows.Forms.Label(); this.currentName = new System.Windows.Forms.Label();
this.currentAlbumValue = new System.Windows.Forms.Label();
this.currentAlbum = new System.Windows.Forms.Label(); this.currentAlbum = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label6 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label();
@ -54,6 +51,9 @@
this.label9 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label();
this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.linkLabel2 = new System.Windows.Forms.LinkLabel();
this.linkLabel3 = new System.Windows.Forms.LinkLabel();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
@ -62,14 +62,14 @@
// //
// groupBox1 // groupBox1
// //
this.groupBox1.Controls.Add(this.linkLabel3);
this.groupBox1.Controls.Add(this.linkLabel2);
this.groupBox1.Controls.Add(this.linkLabel1);
this.groupBox1.Controls.Add(this.progressBar1); this.groupBox1.Controls.Add(this.progressBar1);
this.groupBox1.Controls.Add(this.label4); this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label5); this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label3); this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.currentName); this.groupBox1.Controls.Add(this.currentName);
this.groupBox1.Controls.Add(this.currentAlbumValue);
this.groupBox1.Controls.Add(this.currentAlbum); this.groupBox1.Controls.Add(this.currentAlbum);
this.groupBox1.Controls.Add(this.pictureBox1); this.groupBox1.Controls.Add(this.pictureBox1);
this.groupBox1.Location = new System.Drawing.Point(12, 209); this.groupBox1.Location = new System.Drawing.Point(12, 209);
@ -104,15 +104,6 @@
this.label5.TabIndex = 7; this.label5.TabIndex = 7;
this.label5.Text = "Time:"; this.label5.Text = "Time:";
// //
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(50, 205);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 13);
this.label2.TabIndex = 6;
this.label2.Text = "Name: ";
//
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
@ -122,15 +113,6 @@
this.label3.TabIndex = 5; this.label3.TabIndex = 5;
this.label3.Text = "Artist: "; this.label3.Text = "Artist: ";
// //
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(50, 182);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 13);
this.label1.TabIndex = 4;
this.label1.Text = "Name: ";
//
// currentName // currentName
// //
this.currentName.AutoSize = true; this.currentName.AutoSize = true;
@ -140,15 +122,6 @@
this.currentName.TabIndex = 3; this.currentName.TabIndex = 3;
this.currentName.Text = "Name: "; this.currentName.Text = "Name: ";
// //
// currentAlbumValue
//
this.currentAlbumValue.AutoSize = true;
this.currentAlbumValue.Location = new System.Drawing.Point(48, 228);
this.currentAlbumValue.Name = "currentAlbumValue";
this.currentAlbumValue.Size = new System.Drawing.Size(62, 13);
this.currentAlbumValue.TabIndex = 2;
this.currentAlbumValue.Text = "albumValue";
//
// currentAlbum // currentAlbum
// //
this.currentAlbum.AutoSize = true; this.currentAlbum.AutoSize = true;
@ -171,7 +144,7 @@
this.label6.AutoSize = true; this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(18, 76); this.label6.Location = new System.Drawing.Point(18, 76);
this.label6.Name = "label6"; this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(54, 13); this.label6.Size = new System.Drawing.Size(41, 13);
this.label6.TabIndex = 9; this.label6.TabIndex = 9;
this.label6.Text = "Advert:"; this.label6.Text = "Advert:";
// //
@ -322,6 +295,36 @@
this.pictureBox2.TabIndex = 12; this.pictureBox2.TabIndex = 12;
this.pictureBox2.TabStop = false; this.pictureBox2.TabStop = false;
// //
// linkLabel1
//
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(50, 182);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(55, 13);
this.linkLabel1.TabIndex = 10;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "linkLabel1";
//
// linkLabel2
//
this.linkLabel2.AutoSize = true;
this.linkLabel2.Location = new System.Drawing.Point(50, 205);
this.linkLabel2.Name = "linkLabel2";
this.linkLabel2.Size = new System.Drawing.Size(55, 13);
this.linkLabel2.TabIndex = 11;
this.linkLabel2.TabStop = true;
this.linkLabel2.Text = "linkLabel2";
//
// linkLabel3
//
this.linkLabel3.AutoSize = true;
this.linkLabel3.Location = new System.Drawing.Point(50, 228);
this.linkLabel3.Name = "linkLabel3";
this.linkLabel3.Size = new System.Drawing.Size(55, 13);
this.linkLabel3.TabIndex = 12;
this.linkLabel3.TabStop = true;
this.linkLabel3.Text = "linkLabel3";
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -348,12 +351,9 @@
#endregion #endregion
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label currentAlbumValue;
private System.Windows.Forms.Label currentAlbum; private System.Windows.Forms.Label currentAlbum;
private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label currentName; private System.Windows.Forms.Label currentName;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label7; private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label6;
@ -373,6 +373,9 @@
private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.PictureBox pictureBox2; private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.ProgressBar progressBar1; private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.LinkLabel linkLabel3;
private System.Windows.Forms.LinkLabel linkLabel2;
private System.Windows.Forms.LinkLabel linkLabel1;
} }
} }

View File

@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Diagnostics;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@ -64,9 +65,12 @@ namespace SpotifyAPI_Example
pictureBox1.Image = await spotify.GetMusicHandler().GetCurrentTrack().GetAlbumArtAsync(AlbumArtSize.SIZE_160); pictureBox1.Image = await spotify.GetMusicHandler().GetCurrentTrack().GetAlbumArtAsync(AlbumArtSize.SIZE_160);
pictureBox2.Image = await spotify.GetMusicHandler().GetCurrentTrack().GetAlbumArtAsync(AlbumArtSize.SIZE_640); pictureBox2.Image = await spotify.GetMusicHandler().GetCurrentTrack().GetAlbumArtAsync(AlbumArtSize.SIZE_640);
label1.Text = mh.GetCurrentTrack().GetTrackName(); linkLabel1.Text = mh.GetCurrentTrack().GetTrackName();
label2.Text = mh.GetCurrentTrack().GetArtistName(); linkLabel1.LinkClicked += (senderTwo, args) => Process.Start(mh.GetCurrentTrack().GetTrackURI());
currentAlbumValue.Text = mh.GetCurrentTrack().GetAlbumName(); linkLabel2.Text = mh.GetCurrentTrack().GetArtistName();
linkLabel2.LinkClicked += (senderTwo, args) => Process.Start(mh.GetCurrentTrack().GetArtistURI());
linkLabel3.Text = mh.GetCurrentTrack().GetAlbumName();
linkLabel3.LinkClicked += (senderTwo, args) => Process.Start(mh.GetCurrentTrack().GetAlbumURI());
label9.Text = mh.IsPlaying().ToString(); label9.Text = mh.IsPlaying().ToString();
label11.Text = ((int)(mh.GetVolume() * 100)).ToString(); label11.Text = ((int)(mh.GetVolume() * 100)).ToString();
@ -90,9 +94,9 @@ namespace SpotifyAPI_Example
private async void trackchange(TrackChangeEventArgs e) private async void trackchange(TrackChangeEventArgs e)
{ {
progressBar1.Maximum = (int)mh.GetCurrentTrack().GetLength()*100; progressBar1.Maximum = (int)mh.GetCurrentTrack().GetLength()*100;
label1.Text = e.new_track.GetTrackName(); linkLabel1.Text = e.new_track.GetTrackName();
label2.Text = e.new_track.GetArtistName(); linkLabel2.Text = e.new_track.GetArtistName();
currentAlbumValue.Text = e.new_track.GetAlbumName(); linkLabel3.Text = e.new_track.GetAlbumName();
pictureBox1.Image = await e.new_track.GetAlbumArtAsync(AlbumArtSize.SIZE_160); pictureBox1.Image = await e.new_track.GetAlbumArtAsync(AlbumArtSize.SIZE_160);
pictureBox2.Image = await e.new_track.GetAlbumArtAsync(AlbumArtSize.SIZE_640); pictureBox2.Image = await e.new_track.GetAlbumArtAsync(AlbumArtSize.SIZE_640);
label7.Text = mh.IsAdRunning().ToString(); label7.Text = mh.IsAdRunning().ToString();
@ -133,7 +137,8 @@ namespace SpotifyAPI_Example
private void button5_Click(object sender, EventArgs e) private void button5_Click(object sender, EventArgs e)
{ {
if (SpotifyAPI.IsValidSpotifyURI(textBox1.Text)) //Not working yet
//if (SpotifyAPI.IsValidSpotifyURI(textBox1.Text))
mh.PlayURL(textBox1.Text); mh.PlayURL(textBox1.Text);
} }