mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-24 15:06:26 +00:00
Cleaned up Imports and made IsValidSpotifyURL static
This commit is contained in:
parent
a779063f76
commit
03a18e0bdf
BIN
SpotifyAPI.dll
BIN
SpotifyAPI.dll
Binary file not shown.
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SpotifyAPIv1
|
namespace SpotifyAPIv1
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SpotifyAPIv1
|
namespace SpotifyAPIv1
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SpotifyAPIv1
|
namespace SpotifyAPIv1
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
@ -49,10 +48,6 @@ namespace SpotifyAPIv1
|
|||||||
{
|
{
|
||||||
query("remote/play.json?uri=" + url, true, true, -1);
|
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()
|
internal StatusResponse Update()
|
||||||
{
|
{
|
||||||
String response = query("remote/status.json", true, true, -1);
|
String response = query("remote/status.json", true, true, -1);
|
||||||
|
@ -1,15 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Net;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows;
|
|
||||||
using System.Management;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace SpotifyAPIv1
|
namespace SpotifyAPIv1
|
||||||
{
|
{
|
||||||
@ -40,20 +33,14 @@ namespace SpotifyAPIv1
|
|||||||
public static Boolean IsSpotifyRunning()
|
public static Boolean IsSpotifyRunning()
|
||||||
{
|
{
|
||||||
if (Process.GetProcessesByName("spotify").Length < 1)
|
if (Process.GetProcessesByName("spotify").Length < 1)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
return true;
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
public static Boolean IsSpotifyWebHelperRunning()
|
public static Boolean IsSpotifyWebHelperRunning()
|
||||||
{
|
{
|
||||||
if (Process.GetProcessesByName("SpotifyWebHelper").Length < 1)
|
if (Process.GetProcessesByName("SpotifyWebHelper").Length < 1)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
return true;
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
public void RunSpotify()
|
public void RunSpotify()
|
||||||
{
|
{
|
||||||
@ -65,7 +52,7 @@ namespace SpotifyAPIv1
|
|||||||
if (!IsSpotifyWebHelperRunning())
|
if (!IsSpotifyWebHelperRunning())
|
||||||
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Spotify\\Data\\SpotifyWebHelper.exe");
|
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[] types = new String[] { "track","album","local","artist"};
|
||||||
String[] split = url.Split(':');
|
String[] split = url.Split(':');
|
||||||
@ -78,7 +65,6 @@ namespace SpotifyAPIv1
|
|||||||
if (!SpotifyAPI.IsSpotifyWebHelperRunning())
|
if (!SpotifyAPI.IsSpotifyWebHelperRunning())
|
||||||
return;
|
return;
|
||||||
mh.Update(rh.Update());
|
mh.Update(rh.Update());
|
||||||
rh.SendVolumeRequest();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using SpotifyAPIv1;
|
using SpotifyAPIv1;
|
||||||
|
|
||||||
namespace SpotifyAPIv1
|
namespace SpotifyAPIv1
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -18,8 +17,11 @@ namespace SpotifyAPIv1
|
|||||||
|
|
||||||
RemoteHandler rh;
|
RemoteHandler rh;
|
||||||
StatusResponse sr;
|
StatusResponse sr;
|
||||||
|
|
||||||
const byte VK_MEDIA_NEXT_TRACK = 0xb0;
|
const byte VK_MEDIA_NEXT_TRACK = 0xb0;
|
||||||
const byte VK_MEDIA_PREV_TRACK = 0xb1;
|
const byte VK_MEDIA_PREV_TRACK = 0xb1;
|
||||||
|
const int KEYEVENTF_EXTENDEDKEY = 0x1;
|
||||||
|
const int KEYEVENTF_KEYUP = 0x2;
|
||||||
|
|
||||||
public SpotifyMusicHandler()
|
public SpotifyMusicHandler()
|
||||||
{
|
{
|
||||||
@ -27,8 +29,6 @@ namespace SpotifyAPIv1
|
|||||||
}
|
}
|
||||||
void PressKey(byte keyCode)
|
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, 0);
|
||||||
keybd_event(keyCode, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
|
keybd_event(keyCode, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
|
||||||
}
|
}
|
||||||
@ -87,7 +87,6 @@ namespace SpotifyAPIv1
|
|||||||
{
|
{
|
||||||
return sr;
|
return sr;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Update(StatusResponse sr)
|
internal void Update(StatusResponse sr)
|
||||||
{
|
{
|
||||||
this.sr = sr;
|
this.sr = sr;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
@ -93,7 +92,7 @@ namespace SpotifyAPIv1
|
|||||||
{
|
{
|
||||||
data = await wc.DownloadDataTaskAsync(url);
|
data = await wc.DownloadDataTaskAsync(url);
|
||||||
}
|
}
|
||||||
catch(WebException e)
|
catch(WebException)
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ namespace SpotifyAPI_Example
|
|||||||
|
|
||||||
private void button5_Click(object sender, EventArgs e)
|
private void button5_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (spotify.IsValidSpotifyURL(textBox1.Text))
|
if (SpotifyAPI.IsValidSpotifyURL(textBox1.Text))
|
||||||
mh.PlayURL(textBox1.Text);
|
mh.PlayURL(textBox1.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user