using System using System Collections Generic using System ComponentMo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Net;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
DateTime date;
public Form1()
{
InitializeComponent();
}
private void buttonStart_Click(object sender, EventArgs e)
{
date = DateTime.Now;
Timer timer = new Timer();
timer.Interval = 10;
timer.Tick += new EventHandler(tickTimer);
timer.Start();
}
private void tickTimer(object sender, EventArgs e)
{
long tick = DateTime.Now.Ticks - date.Ticks;
DateTime stopWatch = new DateTime();
stopWatch = stopWatch.AddTicks(tick);
labelTime.Text = "Stream Time: " + String.Format("{0:HH:mm:ss}", stopWatch);
File.WriteAllText("timer.txt", labelTime.Text);
}
private void songPlay(object sender, EventArgs e)
{
HttpWebRequest songRequest = (HttpWebRequest)WebRequest.Create("http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=dockgg&api_key=e28039161acc777b14cfb09eb41ef896&limit=1");
HttpWebResponse songResponse = (HttpWebResponse)songRequest.GetResponse();
string name = String.Empty;
string songResult = new StreamReader(songResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd();
for (int i = songResult.IndexOf("<name>") + 7; i < songResult.IndexOf("</name>"); i++)
{
name += songResult[i];
}
songName.Text = name;
}
}
}