mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-23 14:46: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.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SpotifyAPIv1
|
||||
{
|
||||
|
@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SpotifyAPIv1
|
||||
{
|
||||
|
@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SpotifyAPIv1
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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,20 +33,14 @@ namespace SpotifyAPIv1
|
||||
public static Boolean IsSpotifyRunning()
|
||||
{
|
||||
if (Process.GetProcessesByName("spotify").Length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
public static Boolean IsSpotifyWebHelperRunning()
|
||||
{
|
||||
if (Process.GetProcessesByName("SpotifyWebHelper").Length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SpotifyAPIv1;
|
||||
|
||||
namespace SpotifyAPIv1
|
||||
|
@ -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);
|
||||
}
|
||||
@ -77,7 +77,7 @@ namespace SpotifyAPIv1
|
||||
public void Pause()
|
||||
{
|
||||
rh.SendPauseRequest();
|
||||
|
||||
|
||||
}
|
||||
public void Play()
|
||||
{
|
||||
@ -87,7 +87,6 @@ namespace SpotifyAPIv1
|
||||
{
|
||||
return sr;
|
||||
}
|
||||
|
||||
internal void Update(StatusResponse sr)
|
||||
{
|
||||
this.sr = sr;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user