Cleaned up Imports and made IsValidSpotifyURL static

This commit is contained in:
Johnny @PC 2014-02-06 13:55:47 +01:00
parent a779063f76
commit 03a18e0bdf
11 changed files with 9 additions and 39 deletions

Binary file not shown.

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SpotifyAPIv1
{

View File

@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SpotifyAPIv1
{

View File

@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SpotifyAPIv1
{

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using Newtonsoft.Json;
@ -49,10 +48,6 @@ namespace SpotifyAPIv1
{
query("remote/play.json?uri=" + url, true, true, -1);
}
public void SendVolumeRequest()
{
String s = query("remote/volume.json?volume=" + 50, false, false, -1);
}
internal StatusResponse Update()
{
String response = query("remote/status.json", true, true, -1);

View File

@ -1,15 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using Newtonsoft.Json;
using System.Text.RegularExpressions;
using System.Windows;
using System.Management;
using System.Diagnostics;
using System.Drawing;
namespace SpotifyAPIv1
{
@ -40,19 +33,13 @@ namespace SpotifyAPIv1
public static Boolean IsSpotifyRunning()
{
if (Process.GetProcessesByName("spotify").Length < 1)
{
return false;
}
else
return true;
}
public static Boolean IsSpotifyWebHelperRunning()
{
if (Process.GetProcessesByName("SpotifyWebHelper").Length < 1)
{
return false;
}
else
return true;
}
public void RunSpotify()
@ -65,7 +52,7 @@ namespace SpotifyAPIv1
if (!IsSpotifyWebHelperRunning())
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Spotify\\Data\\SpotifyWebHelper.exe");
}
public Boolean IsValidSpotifyURL(String url)
public static Boolean IsValidSpotifyURL(String url)
{
String[] types = new String[] { "track","album","local","artist"};
String[] split = url.Split(':');
@ -78,7 +65,6 @@ namespace SpotifyAPIv1
if (!SpotifyAPI.IsSpotifyWebHelperRunning())
return;
mh.Update(rh.Update());
rh.SendVolumeRequest();
}
}
}

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SpotifyAPIv1;
namespace SpotifyAPIv1

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.IO;
@ -18,8 +17,11 @@ namespace SpotifyAPIv1
RemoteHandler rh;
StatusResponse sr;
const byte VK_MEDIA_NEXT_TRACK = 0xb0;
const byte VK_MEDIA_PREV_TRACK = 0xb1;
const int KEYEVENTF_EXTENDEDKEY = 0x1;
const int KEYEVENTF_KEYUP = 0x2;
public SpotifyMusicHandler()
{
@ -27,8 +29,6 @@ namespace SpotifyAPIv1
}
void PressKey(byte keyCode)
{
const int KEYEVENTF_EXTENDEDKEY = 0x1;
const int KEYEVENTF_KEYUP = 0x2;
keybd_event(keyCode, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(keyCode, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
}
@ -87,7 +87,6 @@ namespace SpotifyAPIv1
{
return sr;
}
internal void Update(StatusResponse sr)
{
this.sr = sr;

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
@ -93,7 +92,7 @@ namespace SpotifyAPIv1
{
data = await wc.DownloadDataTaskAsync(url);
}
catch(WebException e)
catch(WebException)
{
throw;
}

View File

@ -106,7 +106,7 @@ namespace SpotifyAPI_Example
private void button5_Click(object sender, EventArgs e)
{
if (spotify.IsValidSpotifyURL(textBox1.Text))
if (SpotifyAPI.IsValidSpotifyURL(textBox1.Text))
mh.PlayURL(textBox1.Text);
}