Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35ded0f592 | ||
|
|
e1de890f33 | ||
|
|
dc7f8905ae | ||
|
|
57229fc8b9 | ||
|
|
05bf1bce21 | ||
|
|
740264099d | ||
|
|
70bed9b661 | ||
|
|
aa769cfad9 | ||
|
|
2f0b1915a3 | ||
|
|
cbf8588855 | ||
|
|
d665d0466d | ||
|
|
e6683f0478 | ||
|
|
46410149b1 | ||
|
|
34771e43c8 | ||
|
|
918bfd8871 | ||
|
|
68ca3af5ff | ||
|
|
bc75eb9d34 | ||
|
|
a8b618cd46 | ||
|
|
00dfd2a78b | ||
|
|
29eb193aea | ||
|
|
78cb6ccee7 | ||
|
|
88681a04e6 | ||
|
|
5af3b29a84 | ||
|
|
2a699353d2 | ||
|
|
6a9b2956de | ||
|
|
3ccfdbe282 | ||
|
|
60f7d41279 | ||
|
|
c99d3955d3 | ||
|
|
87404b0f85 | ||
|
|
f9d92de0ab | ||
|
|
6190a6f0da | ||
|
|
a902b8c370 | ||
|
|
c20a20534b | ||
|
|
9d56e2e3b4 | ||
|
|
006bba7980 | ||
|
|
d5bc7df7e1 | ||
|
|
d31519aeca | ||
|
|
b3e397d0bf | ||
|
|
c7db59a8ab | ||
|
|
a0f52a636c | ||
|
|
ff706d1bf5 | ||
|
|
daf9f6d1ac | ||
|
|
3763e4fb22 | ||
|
|
e2be560a21 | ||
|
|
aaa9382e23 | ||
|
|
9d78ac8b4b | ||
|
|
5f1093dd1c | ||
|
|
e80f9107c0 | ||
|
|
77a6951021 | ||
|
|
08e485d6d4 | ||
|
|
769f153e26 | ||
|
|
d4f6869736 | ||
|
|
c86b48da5f | ||
|
|
bb60d94996 | ||
|
|
ad6ee2f6ed | ||
|
|
b6c90e97bd | ||
|
|
fe2f02a16d | ||
|
|
362a37f0eb | ||
|
|
7b763bac46 | ||
|
|
91893e45e4 | ||
|
|
870c67595b | ||
|
|
c0d5932f09 | ||
|
|
86d96515c0 | ||
|
|
9bec1974f5 | ||
|
|
9a01b9e870 | ||
|
|
41dd995175 | ||
|
|
e6d4eacd1c | ||
|
|
8c988dd475 | ||
|
|
5ad0fd72c2 | ||
|
|
c1f29f76c4 | ||
|
|
52903849f2 | ||
|
|
2d0b38e2d1 | ||
|
|
35097e88b9 | ||
|
|
6090937072 | ||
|
|
23452531f9 | ||
|
|
1c8bde4f1e | ||
|
|
76f5753a6e | ||
|
|
c2afd44654 | ||
|
|
4f5aaee125 | ||
|
|
da378f5fbf | ||
|
|
2ddbe6e9c8 | ||
|
|
85028d04a9 | ||
|
|
1f2983d712 | ||
|
|
615934557c |
Regular → Executable
Regular → Executable
Regular → Executable
@@ -5,16 +5,19 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MusicPlayer;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
public class APIHandler
|
||||
{
|
||||
private NetworkHandler nw;
|
||||
|
||||
private Image defaultCover;
|
||||
public APIHandler(NetworkHandler nw)
|
||||
{
|
||||
this.nw = nw;
|
||||
defaultCover = Image.FromStream(nw.downloadArtwork("default-cover.png"));
|
||||
}
|
||||
|
||||
public string GetSongURLByID(string id)
|
||||
@@ -46,6 +49,22 @@ namespace MusicPlayer
|
||||
return GetSongsByArgs("album=" + year);
|
||||
}
|
||||
|
||||
public List<Song> GetAllSongs()
|
||||
{
|
||||
List<Song> allsongslist = new List<Song>();
|
||||
JObject o = nw.SendString("getallsongs?");
|
||||
if (o["result"].ToString() == "OK")
|
||||
{
|
||||
dynamic songs = o["songs"];
|
||||
for (int i = 0; i < songs.Count; i++)
|
||||
{
|
||||
allsongslist.Add(new Song(songs[i][0].ToString(), songs[i][3].ToString(), songs[i][5].ToString(), songs[i][4].ToString(), songs[i][1].ToString(), (int)songs[i][9], this));
|
||||
}
|
||||
}
|
||||
return allsongslist;
|
||||
|
||||
}
|
||||
|
||||
public List<Song> GetSongsByArgs(string args)
|
||||
{
|
||||
List<Song> songslist = new List<Song>();
|
||||
@@ -55,7 +74,8 @@ namespace MusicPlayer
|
||||
dynamic songs = o["songs"];
|
||||
for (int i = 0; i < songs.Count; i++)
|
||||
{
|
||||
songslist.Add(new Song(songs[i][0].ToString(), songs[i][3].ToString(), songs[i][5].ToString(), songs[i][4].ToString(), this));
|
||||
if(songs[i][2].ToString().EndsWith(".mp3"))
|
||||
songslist.Add(new Song(songs[i][0].ToString(), songs[i][3].ToString(), songs[i][5].ToString(), songs[i][4].ToString(), songs[i][1].ToString(), (int)songs[i][9], this));
|
||||
}
|
||||
}
|
||||
return songslist;
|
||||
@@ -75,6 +95,16 @@ namespace MusicPlayer
|
||||
return artistlist;
|
||||
}
|
||||
|
||||
public Image getAlbumCover(string album)
|
||||
{
|
||||
MemoryStream stream = nw.downloadArtwork(album + ".jpg");
|
||||
if(stream != null)
|
||||
{
|
||||
return Image.FromStream(stream);
|
||||
}
|
||||
return defaultCover;
|
||||
}
|
||||
|
||||
public List<Album> GetAlbums()
|
||||
{
|
||||
List<Album> albumlist = new List<Album>();
|
||||
@@ -104,5 +134,19 @@ namespace MusicPlayer
|
||||
}
|
||||
return yearlist;
|
||||
}
|
||||
|
||||
public List<Genre> GetGenres()
|
||||
{
|
||||
List<Genre> genreslist = new List<Genre>();
|
||||
JObject o = nw.SendString("getgenres?id=hallo");
|
||||
if (o["result"].ToString() == "OK")
|
||||
{
|
||||
for (int i = 0; i < o["genres"].Count(); i++)
|
||||
{
|
||||
genreslist.Add(new Genre(o["genres"][i][0].ToString()));
|
||||
}
|
||||
}
|
||||
return genreslist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace MusicPlayer
|
||||
|
||||
using System.Drawing;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
public class Album
|
||||
{
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
+223
-39
@@ -12,47 +12,231 @@ namespace MusicPlayer
|
||||
{
|
||||
public class AudioHandler
|
||||
{
|
||||
public static Stream ms = new MemoryStream();
|
||||
public enum AudioState { PLAYING, WAITING, STOPPED, PAUSED, SEEKING }
|
||||
public enum BufferState { EMPTY, BUFFERING, DONE }
|
||||
public AudioState AState { get; set; }
|
||||
public BufferState BState { get; set; }
|
||||
|
||||
public static void PlayMp3FromUrl(string url)
|
||||
public int Buffered { get { return Math.Min((int)((bufpos / (double)LengthBuffer) * 1000), 1000); } }
|
||||
private long LengthBuffer { get; set; }
|
||||
private long bufpos = 0;
|
||||
|
||||
|
||||
public int Position { get { return Math.Min((int)((playpos / (double)Length) * 1000), 1000); } }
|
||||
private long Length { get; set; }
|
||||
private long playpos = 0;
|
||||
|
||||
|
||||
public int CurrentTime { get; set; }
|
||||
|
||||
public int TotalTime { get { return CurrentSong != null ? CurrentSong.Seconds : 0; } }
|
||||
|
||||
private long seek = 0;
|
||||
|
||||
private Stream ms;
|
||||
|
||||
private Thread network;
|
||||
private Thread audio;
|
||||
|
||||
public Song CurrentSong;
|
||||
|
||||
private Main main;
|
||||
|
||||
public AudioHandler(Main main)
|
||||
{
|
||||
new Thread(delegate (object o)
|
||||
{
|
||||
var response = WebRequest.Create(url).GetResponse();
|
||||
using (var stream = response.GetResponseStream())
|
||||
{
|
||||
byte[] buffer = new byte[65536]; // 64KB chunks
|
||||
int read;
|
||||
while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
var pos = ms.Position;
|
||||
ms.Position = ms.Length;
|
||||
ms.Write(buffer, 0, read);
|
||||
ms.Position = pos;
|
||||
}
|
||||
}
|
||||
}).Start();
|
||||
|
||||
new Thread(delegate (object o)
|
||||
{
|
||||
// Pre-buffering some data to allow NAudio to start playing
|
||||
while (ms.Length < 65536 * 10)
|
||||
Thread.Sleep(1000);
|
||||
|
||||
ms.Position = 0;
|
||||
using (WaveStream blockAlignedStream = new BlockAlignReductionStream(WaveFormatConversionStream.CreatePcmStream(new Mp3FileReader(ms))))
|
||||
{
|
||||
using (WaveOut waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()))
|
||||
{
|
||||
waveOut.Init(blockAlignedStream);
|
||||
waveOut.Play();
|
||||
while (waveOut.PlaybackState == PlaybackState.Playing)
|
||||
{
|
||||
System.Threading.Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).Start();
|
||||
this.main = main;
|
||||
CreateThreads();
|
||||
}
|
||||
|
||||
private void CreateThreads()
|
||||
{
|
||||
AState = AudioState.STOPPED;
|
||||
BState = BufferState.EMPTY;
|
||||
|
||||
CurrentSong = null;
|
||||
|
||||
Thread.Sleep(11);
|
||||
|
||||
ms = new MemoryStream();
|
||||
|
||||
network = new Thread(LoadAudio);
|
||||
audio = new Thread(PlayAudio);
|
||||
|
||||
network.IsBackground = true;
|
||||
audio.IsBackground = true;
|
||||
|
||||
Length = 1;
|
||||
LengthBuffer = 1;
|
||||
bufpos = 0;
|
||||
playpos = 0;
|
||||
CurrentTime = 0;
|
||||
}
|
||||
|
||||
public void Play(Song s)
|
||||
{
|
||||
if (CurrentSong == s && AState == AudioState.PAUSED)
|
||||
AState = AudioState.PLAYING;
|
||||
else
|
||||
{
|
||||
Stop();
|
||||
|
||||
CurrentSong = s;
|
||||
network.Start(s);
|
||||
audio.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public void Seek(int position)
|
||||
{
|
||||
if (position >= Buffered-1)
|
||||
return;
|
||||
|
||||
seek = Length / 1000 * position;
|
||||
AState = AudioState.SEEKING;
|
||||
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
CreateThreads();
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
if(CurrentSong == null)
|
||||
AState = AudioState.STOPPED;
|
||||
else
|
||||
AState = AudioState.PAUSED;
|
||||
}
|
||||
|
||||
private void StreamFromMP3(Stream s, long pos, bool firstrun)
|
||||
{
|
||||
long position = 0;
|
||||
ms.Position = position;
|
||||
Mp3FileReader mp3fr = null;
|
||||
|
||||
try
|
||||
{
|
||||
mp3fr = new Mp3FileReader(ms);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
AState = AudioState.STOPPED;
|
||||
main.form.SongFinished();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
using (WaveStream blockAlignedStream = new BlockAlignReductionStream(WaveFormatConversionStream.CreatePcmStream(mp3fr)))
|
||||
{
|
||||
blockAlignedStream.Position = pos;
|
||||
using (WaveOut waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()))
|
||||
{
|
||||
waveOut.Init(blockAlignedStream);
|
||||
waveOut.Play();
|
||||
|
||||
Length = CurrentSong.Seconds * waveOut.OutputWaveFormat.AverageBytesPerSecond;
|
||||
CurrentTime = (int)(ms.Position / waveOut.OutputWaveFormat.AverageBytesPerSecond);
|
||||
|
||||
while (waveOut.PlaybackState != PlaybackState.Stopped)
|
||||
{
|
||||
System.Threading.Thread.Sleep(10);
|
||||
|
||||
if (AState == AudioState.PLAYING && waveOut.PlaybackState == PlaybackState.Paused)
|
||||
{
|
||||
blockAlignedStream.Position = position;
|
||||
waveOut.Play();
|
||||
}
|
||||
if (AState == AudioState.PAUSED && waveOut.PlaybackState == PlaybackState.Playing)
|
||||
{
|
||||
position = blockAlignedStream.Position;
|
||||
waveOut.Pause();
|
||||
}
|
||||
if (AState == AudioState.SEEKING)
|
||||
{
|
||||
blockAlignedStream.Seek(seek - (seek % blockAlignedStream.WaveFormat.BlockAlign), SeekOrigin.Begin);
|
||||
AState = AudioState.PLAYING;
|
||||
waveOut.Play();
|
||||
}
|
||||
if (AState == AudioState.STOPPED)
|
||||
{
|
||||
waveOut.Stop();
|
||||
}
|
||||
if (BState == BufferState.DONE && firstrun )
|
||||
{
|
||||
position = mp3fr.Position;
|
||||
mp3fr.Close();
|
||||
StreamFromMP3(ms,position, false);
|
||||
break;
|
||||
}
|
||||
|
||||
playpos = blockAlignedStream.Position;
|
||||
CurrentTime = (int)(playpos / waveOut.OutputWaveFormat.AverageBytesPerSecond);
|
||||
|
||||
}
|
||||
|
||||
if(AState == AudioState.PLAYING)
|
||||
main.form.SongFinished();
|
||||
AState = AudioState.STOPPED;
|
||||
playpos = 0;
|
||||
CurrentTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayAudio()
|
||||
{
|
||||
AState = AudioState.WAITING;
|
||||
while (ms.Length < 65536 * 10 && BState != BufferState.DONE)
|
||||
Thread.Sleep(1000);
|
||||
AState = AudioState.PLAYING;
|
||||
|
||||
StreamFromMP3(ms,0, true);
|
||||
|
||||
}
|
||||
|
||||
private void LoadAudio(object o)
|
||||
{
|
||||
Song s = (Song) o;
|
||||
WebResponse response = null;
|
||||
|
||||
try
|
||||
{
|
||||
response = WebRequest.Create(s.Url).GetResponse();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
BState = BufferState.EMPTY;
|
||||
AState = AudioState.STOPPED;
|
||||
main.form.SongFinished();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
BState = BufferState.EMPTY;
|
||||
LengthBuffer = response.ContentLength;
|
||||
using (var stream = response.GetResponseStream())
|
||||
{
|
||||
byte[] buffer = new byte[65536]; // 64KB chunks
|
||||
//byte[] buffer = new byte[65536*4]; // 256KB chunks
|
||||
int read;
|
||||
BState = BufferState.BUFFERING;
|
||||
AState = AudioState.WAITING;
|
||||
|
||||
while ((read = stream.Read(buffer, 0, buffer.Length)) > 0 && AState != AudioState.STOPPED)
|
||||
{
|
||||
var pos = ms.Position;
|
||||
ms.Position = ms.Length;
|
||||
ms.Write(buffer, 0, read);
|
||||
ms.Position = pos;
|
||||
|
||||
|
||||
this.bufpos = ms.Length;
|
||||
}
|
||||
}
|
||||
|
||||
BState = BufferState.DONE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Regular → Executable
@@ -0,0 +1,11 @@
|
||||
namespace MusicPlayer
|
||||
{
|
||||
public class Genre
|
||||
{
|
||||
public string name { get; set; }
|
||||
public Genre(string name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
+184
-14
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
@@ -11,41 +13,209 @@ namespace MusicPlayer
|
||||
public APIHandler api;
|
||||
public MainForm form;
|
||||
public NetworkHandler nw;
|
||||
public PlaylistHandler pl;
|
||||
public AudioHandler audio;
|
||||
|
||||
private SongsTable table;
|
||||
public SongsTable table;
|
||||
|
||||
private List<string> genres;
|
||||
private List<string> artists;
|
||||
|
||||
public Main(NetworkHandler nw, APIHandler api, MainForm form)
|
||||
public List<Song> currentPlayingList;
|
||||
|
||||
public Main(NetworkHandler nw, APIHandler api, MainForm form, PlaylistHandler pl)
|
||||
{
|
||||
this.nw = nw;
|
||||
this.api = api;
|
||||
this.form = form;
|
||||
form.main = this;
|
||||
this.pl = pl;
|
||||
|
||||
audio = new AudioHandler();
|
||||
audio = new AudioHandler(this);
|
||||
table = new SongsTable();
|
||||
form.SongsTableView.DataSource = table;
|
||||
form.SongsTableView.Columns[5].Visible = false;
|
||||
|
||||
genres = new List<string>();
|
||||
artists = new List<string>();
|
||||
|
||||
currentPlayingList = new List<Song>();
|
||||
|
||||
Populate();
|
||||
}
|
||||
|
||||
public void SwitchServer(string server)
|
||||
{
|
||||
Clear();
|
||||
nw.ip = server;
|
||||
Populate();
|
||||
}
|
||||
|
||||
private void Clear()
|
||||
{
|
||||
form.GenreListBox.Items.Clear();
|
||||
form.ArtistListBox.Items.Clear();
|
||||
form.AlbumListView.Items.Clear();
|
||||
form.PlaylistBox.Items.Clear();
|
||||
table.Clear();
|
||||
|
||||
genres = new List<string>();
|
||||
artists = new List<string>();
|
||||
|
||||
currentPlayingList = new List<Song>();
|
||||
}
|
||||
|
||||
private void Populate()
|
||||
{
|
||||
table.Add(new Song("102", "Test Song 1", "Test Album 1", "Test Artist 1", api));
|
||||
this.api.GetAlbums().ForEach(a => { form.AlbumListView.Items.Add(a.albumnaam);});
|
||||
this.api.GetArtists().ForEach(a => { artists.Add(a.naam); form.ArtistListBox.Items.Add(a.naam); });
|
||||
this.api.GetGenres().ForEach(g => { genres.Add(g.name); form.GenreListBox.Items.Add(g.name); });
|
||||
this.pl.GetPlaylists().ForEach(p => form.PlaylistBox.Items.Add(p.name));
|
||||
BackgroundWorker bw = new BackgroundWorker();
|
||||
bw.DoWork += new DoWorkEventHandler(
|
||||
delegate (object o, DoWorkEventArgs args)
|
||||
{
|
||||
BackgroundWorker b = o as BackgroundWorker;
|
||||
ImageList imagelist = new ImageList();
|
||||
foreach (ListViewItem item in form.AlbumListView.Items)
|
||||
{
|
||||
imagelist.Images.Add(item.ToString(), api.getAlbumCover(item.Text));
|
||||
}
|
||||
Action action = () => {
|
||||
form.AlbumListView.LargeImageList = imagelist;
|
||||
foreach (ListViewItem item in form.AlbumListView.Items)
|
||||
{
|
||||
item.ImageKey = item.ToString();
|
||||
}
|
||||
};
|
||||
form.Invoke(action);
|
||||
});
|
||||
bw.RunWorkerAsync();
|
||||
}
|
||||
|
||||
form.GenreListBox.Items.Add("Hardcore");
|
||||
form.GenreListBox.Items.Add("Hardstyle");
|
||||
form.GenreListBox.Items.Add("Pop");
|
||||
public void Repopulate()
|
||||
{
|
||||
form.AlbumListView.Items.Clear();
|
||||
form.ArtistListBox.Items.Clear();
|
||||
form.GenreListBox.Items.Clear();
|
||||
form.PlaylistBox.Items.Clear();
|
||||
this.api.GetAlbums().ForEach(a => form.AlbumListView.Items.Add(a.albumnaam));
|
||||
this.api.GetArtists().ForEach(a => form.ArtistListBox.Items.Add(a.naam));
|
||||
this.api.GetGenres().ForEach(g => form.GenreListBox.Items.Add(g.name));
|
||||
this.pl.GetPlaylists().ForEach(p => form.PlaylistBox.Items.Add(p.name));
|
||||
}
|
||||
|
||||
form.ArtistListBox.Items.Add("Kygo");
|
||||
form.ArtistListBox.Items.Add("Monstercat");
|
||||
form.ArtistListBox.Items.Add("Mozart");
|
||||
public void ArtistFilter(string artist)
|
||||
{
|
||||
table.Clear();
|
||||
api.GetSongsByArtist(artist).ForEach(s =>
|
||||
{
|
||||
table.Add(s);
|
||||
});
|
||||
}
|
||||
|
||||
form.AlbumListView.Items.Add("Album 1");
|
||||
form.AlbumListView.Items.Add("Album 2");
|
||||
form.AlbumListView.Items.Add("Album 3");
|
||||
public void FilterCurrentPlaying()
|
||||
{
|
||||
table.Clear();
|
||||
currentPlayingList.ForEach(s =>
|
||||
{
|
||||
table.Add(s);
|
||||
});
|
||||
|
||||
table.Add(new Song("104", "Test Song 2", "Test Album 2", "Test Artist 2", api));
|
||||
form.GenreListBox.ClearSelected();
|
||||
form.ArtistListBox.ClearSelected();
|
||||
form.PlaylistBox.ClearSelected();
|
||||
form.AlbumListView.SelectedIndices.Clear();
|
||||
}
|
||||
|
||||
public void SearchArtist(string search)
|
||||
{
|
||||
form.ArtistListBox.Items.Clear();
|
||||
|
||||
if (search.Length > 1)
|
||||
{
|
||||
string sPattern = search;
|
||||
|
||||
foreach (string s in artists)
|
||||
{
|
||||
if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
|
||||
{
|
||||
form.ArtistListBox.Items.Add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
artists.ForEach(a => form.ArtistListBox.Items.Add(a));
|
||||
}
|
||||
}
|
||||
|
||||
public void SearchGenre(string search)
|
||||
{
|
||||
form.GenreListBox.Items.Clear();
|
||||
|
||||
if (search.Length > 1)
|
||||
{
|
||||
string sPattern = search;
|
||||
|
||||
foreach (string s in genres)
|
||||
{
|
||||
if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
|
||||
{
|
||||
form.GenreListBox.Items.Add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
genres.ForEach(g => form.GenreListBox.Items.Add(g));
|
||||
}
|
||||
}
|
||||
|
||||
public void GenreFilter(string genre)
|
||||
{
|
||||
table.Clear();
|
||||
api.GetSongsByGenre(genre).ForEach(s =>
|
||||
{
|
||||
table.Add(s);
|
||||
});
|
||||
}
|
||||
|
||||
public void PlaylistFilter(string name)
|
||||
{
|
||||
table.Clear();
|
||||
pl.GetPlaylistByName(name).GetSongs().ForEach(s => table.Add(s));
|
||||
|
||||
}
|
||||
|
||||
public void AlbumFilter(string album)
|
||||
{
|
||||
table.Clear();
|
||||
api.GetSongsByAlbum(album).ForEach(s =>
|
||||
{
|
||||
table.Add(s);
|
||||
});
|
||||
}
|
||||
|
||||
public static string SecondsToTimestamp(int seconds)
|
||||
{
|
||||
string str = "";
|
||||
|
||||
//Hours
|
||||
str += (seconds / 3600).ToString("D2") + ":";
|
||||
seconds %= 3600;
|
||||
|
||||
//Minutes
|
||||
str += (seconds / 60).ToString("D2") + ":";
|
||||
seconds %= 60;
|
||||
|
||||
//Seconds
|
||||
str += seconds.ToString("D2");
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+616
-41
@@ -1,4 +1,6 @@
|
||||
namespace MusicPlayer
|
||||
using System;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
@@ -21,30 +23,86 @@
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
bool clicked = false;
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
this.SongsTableView = new System.Windows.Forms.DataGridView();
|
||||
this.GenreListBox = new System.Windows.Forms.ListBox();
|
||||
this.AlbumListView = new System.Windows.Forms.ListView();
|
||||
this.ArtistListBox = new System.Windows.Forms.ListBox();
|
||||
this.MainPanel = new System.Windows.Forms.Panel();
|
||||
this.SplitContainer = new System.Windows.Forms.SplitContainer();
|
||||
this.PlaylistBox = new System.Windows.Forms.ListBox();
|
||||
this.AlbumListLabel = new System.Windows.Forms.Label();
|
||||
this.ArtistListLabel = new System.Windows.Forms.Label();
|
||||
this.GenreListLabel = new System.Windows.Forms.Label();
|
||||
this.PlaylistListLabel = new System.Windows.Forms.Label();
|
||||
this.MenuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.overviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.playlistsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.ViewCurrentPlaylistButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.playbackToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.PlayNextSongButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.LoopSongButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ShuffleSongButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.playlistToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.makeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.searchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SearchGenresToolStripLabel = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SearchGenresTextBox = new System.Windows.Forms.ToolStripTextBox();
|
||||
this.ClearGenreSearchButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SearchArtistToolStripLabel = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SearchArtistsTextBox = new System.Windows.Forms.ToolStripTextBox();
|
||||
this.ClearArtistSearchButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.serverToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SelectServerJancoButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SelectServerYorickButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ControlsPanel = new System.Windows.Forms.Panel();
|
||||
this.NextButton = new System.Windows.Forms.Button();
|
||||
this.PreviousButton = new System.Windows.Forms.Button();
|
||||
this.CurrentSongLabel = new System.Windows.Forms.Label();
|
||||
this.LabelTotalTime = new System.Windows.Forms.Label();
|
||||
this.LabelCurrentTime = new System.Windows.Forms.Label();
|
||||
this.PositionTrackBar = new System.Windows.Forms.TrackBar();
|
||||
this.BufferLabel = new System.Windows.Forms.Label();
|
||||
this.BufferBar = new System.Windows.Forms.ProgressBar();
|
||||
this.StopButton = new System.Windows.Forms.Button();
|
||||
this.PauseButton = new System.Windows.Forms.Button();
|
||||
this.PlayButton = new System.Windows.Forms.Button();
|
||||
this.UpdateTimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.NotifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
|
||||
this.NotifyMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.NotifyMenuStripPlayingLabel = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.NotifyMenuStripPlayingSongLabel = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.NotifyMenuStripPlayButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.NotifyMenuStripPauseButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.NotifyMenuStripStopButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.NotifyMenuStripNextButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.NotifyMenuStripPreviousButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).BeginInit();
|
||||
this.MainPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SplitContainer)).BeginInit();
|
||||
this.SplitContainer.Panel1.SuspendLayout();
|
||||
this.SplitContainer.Panel2.SuspendLayout();
|
||||
this.SplitContainer.SuspendLayout();
|
||||
this.MenuStrip.SuspendLayout();
|
||||
this.ControlsPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PositionTrackBar)).BeginInit();
|
||||
this.NotifyMenuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// SongsTableView
|
||||
@@ -52,54 +110,74 @@
|
||||
this.SongsTableView.AllowUserToAddRows = false;
|
||||
this.SongsTableView.AllowUserToDeleteRows = false;
|
||||
this.SongsTableView.AllowUserToResizeRows = false;
|
||||
this.SongsTableView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.SongsTableView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.SongsTableView.BackgroundColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.ControlLight;
|
||||
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.SongsTableView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
|
||||
this.SongsTableView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.SongsTableView.Location = new System.Drawing.Point(12, 153);
|
||||
this.SongsTableView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.SongsTableView.Location = new System.Drawing.Point(0, 0);
|
||||
this.SongsTableView.MultiSelect = false;
|
||||
this.SongsTableView.Name = "SongsTableView";
|
||||
this.SongsTableView.ReadOnly = true;
|
||||
this.SongsTableView.RowHeadersVisible = false;
|
||||
this.SongsTableView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.SongsTableView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.SongsTableView.Size = new System.Drawing.Size(760, 148);
|
||||
this.SongsTableView.Size = new System.Drawing.Size(760, 174);
|
||||
this.SongsTableView.TabIndex = 0;
|
||||
this.SongsTableView.SelectionChanged += new System.EventHandler(this.SongsTableView_SelectionChanged);
|
||||
this.SongsTableView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.SongsTableView_CellDoubleClick);
|
||||
this.SongsTableView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.SongsTableView_MouseDown);
|
||||
this.SongsTableView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.SongsTableView_MouseMove);
|
||||
this.SongsTableView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.SongsTableView_MouseUp);
|
||||
//
|
||||
// GenreListBox
|
||||
//
|
||||
this.GenreListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.GenreListBox.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.GenreListBox.FormattingEnabled = true;
|
||||
this.GenreListBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.GenreListBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.GenreListBox.Name = "GenreListBox";
|
||||
this.GenreListBox.Size = new System.Drawing.Size(124, 134);
|
||||
this.GenreListBox.Size = new System.Drawing.Size(150, 121);
|
||||
this.GenreListBox.Sorted = true;
|
||||
this.GenreListBox.TabIndex = 1;
|
||||
this.GenreListBox.SelectedIndexChanged += new System.EventHandler(this.GenreListBox_SelectedIndexChanged);
|
||||
//
|
||||
// AlbumListView
|
||||
//
|
||||
this.AlbumListView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.AlbumListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.AlbumListView.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.AlbumListView.Location = new System.Drawing.Point(272, 12);
|
||||
this.AlbumListView.Location = new System.Drawing.Point(312, 0);
|
||||
this.AlbumListView.MultiSelect = false;
|
||||
this.AlbumListView.Name = "AlbumListView";
|
||||
this.AlbumListView.Size = new System.Drawing.Size(500, 134);
|
||||
this.AlbumListView.Size = new System.Drawing.Size(448, 121);
|
||||
this.AlbumListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
||||
this.AlbumListView.TabIndex = 2;
|
||||
this.AlbumListView.TileSize = new System.Drawing.Size(140, 30);
|
||||
this.AlbumListView.UseCompatibleStateImageBehavior = false;
|
||||
this.AlbumListView.View = System.Windows.Forms.View.Tile;
|
||||
this.AlbumListView.SelectedIndexChanged += new System.EventHandler(this.AlbumListView_SelectedIndexChanged);
|
||||
//
|
||||
// ArtistListBox
|
||||
//
|
||||
this.ArtistListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.ArtistListBox.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.ArtistListBox.FormattingEnabled = true;
|
||||
this.ArtistListBox.Location = new System.Drawing.Point(142, 12);
|
||||
this.ArtistListBox.Location = new System.Drawing.Point(156, 0);
|
||||
this.ArtistListBox.Name = "ArtistListBox";
|
||||
this.ArtistListBox.Size = new System.Drawing.Size(124, 134);
|
||||
this.ArtistListBox.Size = new System.Drawing.Size(150, 121);
|
||||
this.ArtistListBox.Sorted = true;
|
||||
this.ArtistListBox.TabIndex = 3;
|
||||
this.ArtistListBox.SelectedIndexChanged += new System.EventHandler(this.ArtistListBox_SelectedIndexChanged);
|
||||
//
|
||||
// MainPanel
|
||||
//
|
||||
@@ -107,21 +185,99 @@
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.MainPanel.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.MainPanel.Controls.Add(this.GenreListBox);
|
||||
this.MainPanel.Controls.Add(this.ArtistListBox);
|
||||
this.MainPanel.Controls.Add(this.AlbumListView);
|
||||
this.MainPanel.Controls.Add(this.SongsTableView);
|
||||
this.MainPanel.Controls.Add(this.SplitContainer);
|
||||
this.MainPanel.Controls.Add(this.AlbumListLabel);
|
||||
this.MainPanel.Controls.Add(this.ArtistListLabel);
|
||||
this.MainPanel.Controls.Add(this.GenreListLabel);
|
||||
this.MainPanel.Controls.Add(this.PlaylistListLabel);
|
||||
this.MainPanel.Location = new System.Drawing.Point(0, 24);
|
||||
this.MainPanel.Name = "MainPanel";
|
||||
this.MainPanel.Size = new System.Drawing.Size(784, 313);
|
||||
this.MainPanel.Size = new System.Drawing.Size(784, 351);
|
||||
this.MainPanel.TabIndex = 5;
|
||||
//
|
||||
// SplitContainer
|
||||
//
|
||||
this.SplitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.SplitContainer.Location = new System.Drawing.Point(12, 25);
|
||||
this.SplitContainer.Name = "SplitContainer";
|
||||
this.SplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
//
|
||||
// SplitContainer.Panel1
|
||||
//
|
||||
this.SplitContainer.Panel1.Controls.Add(this.AlbumListView);
|
||||
this.SplitContainer.Panel1.Controls.Add(this.ArtistListBox);
|
||||
this.SplitContainer.Panel1.Controls.Add(this.GenreListBox);
|
||||
this.SplitContainer.Panel1.Controls.Add(this.PlaylistBox);
|
||||
//
|
||||
// SplitContainer.Panel2
|
||||
//
|
||||
this.SplitContainer.Panel2.Controls.Add(this.SongsTableView);
|
||||
this.SplitContainer.Size = new System.Drawing.Size(760, 313);
|
||||
this.SplitContainer.SplitterDistance = 131;
|
||||
this.SplitContainer.SplitterWidth = 8;
|
||||
this.SplitContainer.TabIndex = 9;
|
||||
//
|
||||
// PlaylistBox
|
||||
//
|
||||
this.PlaylistBox.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.PlaylistBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.PlaylistBox.FormattingEnabled = true;
|
||||
this.PlaylistBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.PlaylistBox.Name = "PlaylistBox";
|
||||
this.PlaylistBox.Size = new System.Drawing.Size(760, 131);
|
||||
this.PlaylistBox.TabIndex = 4;
|
||||
this.PlaylistBox.Visible = false;
|
||||
this.PlaylistBox.SelectedIndexChanged += new System.EventHandler(this.PlaylistBox_SelectedIndexChanged);
|
||||
//
|
||||
// AlbumListLabel
|
||||
//
|
||||
this.AlbumListLabel.AutoSize = true;
|
||||
this.AlbumListLabel.Location = new System.Drawing.Point(321, 8);
|
||||
this.AlbumListLabel.Name = "AlbumListLabel";
|
||||
this.AlbumListLabel.Size = new System.Drawing.Size(36, 13);
|
||||
this.AlbumListLabel.TabIndex = 6;
|
||||
this.AlbumListLabel.Text = "Album";
|
||||
//
|
||||
// ArtistListLabel
|
||||
//
|
||||
this.ArtistListLabel.AutoSize = true;
|
||||
this.ArtistListLabel.Location = new System.Drawing.Point(165, 8);
|
||||
this.ArtistListLabel.Name = "ArtistListLabel";
|
||||
this.ArtistListLabel.Size = new System.Drawing.Size(30, 13);
|
||||
this.ArtistListLabel.TabIndex = 5;
|
||||
this.ArtistListLabel.Text = "Artist";
|
||||
//
|
||||
// GenreListLabel
|
||||
//
|
||||
this.GenreListLabel.AutoSize = true;
|
||||
this.GenreListLabel.Location = new System.Drawing.Point(9, 8);
|
||||
this.GenreListLabel.Name = "GenreListLabel";
|
||||
this.GenreListLabel.Size = new System.Drawing.Size(36, 13);
|
||||
this.GenreListLabel.TabIndex = 4;
|
||||
this.GenreListLabel.Text = "Genre";
|
||||
//
|
||||
// PlaylistListLabel
|
||||
//
|
||||
this.PlaylistListLabel.AutoSize = true;
|
||||
this.PlaylistListLabel.Location = new System.Drawing.Point(12, 9);
|
||||
this.PlaylistListLabel.Name = "PlaylistListLabel";
|
||||
this.PlaylistListLabel.Size = new System.Drawing.Size(39, 13);
|
||||
this.PlaylistListLabel.TabIndex = 7;
|
||||
this.PlaylistListLabel.Text = "Playlist";
|
||||
this.PlaylistListLabel.Visible = false;
|
||||
//
|
||||
// MenuStrip
|
||||
//
|
||||
this.MenuStrip.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.MenuStrip.BackColor = System.Drawing.SystemColors.WindowFrame;
|
||||
this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.viewToolStripMenuItem});
|
||||
this.viewToolStripMenuItem,
|
||||
this.playbackToolStripMenuItem,
|
||||
this.playlistToolStripMenuItem,
|
||||
this.searchToolStripMenuItem,
|
||||
this.serverToolStripMenuItem});
|
||||
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.MenuStrip.Name = "MenuStrip";
|
||||
this.MenuStrip.Size = new System.Drawing.Size(784, 24);
|
||||
@@ -131,55 +287,417 @@
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.openToolStripMenuItem,
|
||||
this.saveToolStripMenuItem});
|
||||
this.toolStripSeparator1,
|
||||
this.exitToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// openToolStripMenuItem
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.openToolStripMenuItem.Text = "Open";
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(89, 6);
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
// exitToolStripMenuItem
|
||||
//
|
||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.saveToolStripMenuItem.Text = "Save";
|
||||
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||
this.exitToolStripMenuItem.Size = new System.Drawing.Size(92, 22);
|
||||
this.exitToolStripMenuItem.Text = "Exit";
|
||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
//
|
||||
// viewToolStripMenuItem
|
||||
//
|
||||
this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.overviewToolStripMenuItem,
|
||||
this.playlistsToolStripMenuItem,
|
||||
this.toolStripSeparator4,
|
||||
this.ViewCurrentPlaylistButton});
|
||||
this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
|
||||
this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
|
||||
this.viewToolStripMenuItem.Text = "View";
|
||||
//
|
||||
// overviewToolStripMenuItem
|
||||
//
|
||||
this.overviewToolStripMenuItem.Name = "overviewToolStripMenuItem";
|
||||
this.overviewToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
|
||||
this.overviewToolStripMenuItem.Text = "Overview";
|
||||
this.overviewToolStripMenuItem.Click += new System.EventHandler(this.overviewToolStripMenuItem_Click);
|
||||
//
|
||||
// playlistsToolStripMenuItem
|
||||
//
|
||||
this.playlistsToolStripMenuItem.Name = "playlistsToolStripMenuItem";
|
||||
this.playlistsToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
|
||||
this.playlistsToolStripMenuItem.Text = "Playlists";
|
||||
this.playlistsToolStripMenuItem.Click += new System.EventHandler(this.playlistsToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator4
|
||||
//
|
||||
this.toolStripSeparator4.Name = "toolStripSeparator4";
|
||||
this.toolStripSeparator4.Size = new System.Drawing.Size(151, 6);
|
||||
//
|
||||
// ViewCurrentPlaylistButton
|
||||
//
|
||||
this.ViewCurrentPlaylistButton.Name = "ViewCurrentPlaylistButton";
|
||||
this.ViewCurrentPlaylistButton.Size = new System.Drawing.Size(154, 22);
|
||||
this.ViewCurrentPlaylistButton.Text = "Current Playlist";
|
||||
this.ViewCurrentPlaylistButton.Click += new System.EventHandler(this.ViewCurrentPlaylistButton_Click);
|
||||
//
|
||||
// playbackToolStripMenuItem
|
||||
//
|
||||
this.playbackToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.PlayNextSongButton,
|
||||
this.LoopSongButton,
|
||||
this.ShuffleSongButton});
|
||||
this.playbackToolStripMenuItem.Name = "playbackToolStripMenuItem";
|
||||
this.playbackToolStripMenuItem.Size = new System.Drawing.Size(66, 20);
|
||||
this.playbackToolStripMenuItem.Text = "Playback";
|
||||
//
|
||||
// PlayNextSongButton
|
||||
//
|
||||
this.PlayNextSongButton.Checked = true;
|
||||
this.PlayNextSongButton.CheckOnClick = true;
|
||||
this.PlayNextSongButton.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.PlayNextSongButton.Name = "PlayNextSongButton";
|
||||
this.PlayNextSongButton.Size = new System.Drawing.Size(123, 22);
|
||||
this.PlayNextSongButton.Text = "Play Next";
|
||||
//
|
||||
// LoopSongButton
|
||||
//
|
||||
this.LoopSongButton.Checked = true;
|
||||
this.LoopSongButton.CheckOnClick = true;
|
||||
this.LoopSongButton.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.LoopSongButton.Name = "LoopSongButton";
|
||||
this.LoopSongButton.Size = new System.Drawing.Size(123, 22);
|
||||
this.LoopSongButton.Text = "Loop";
|
||||
//
|
||||
// ShuffleSongButton
|
||||
//
|
||||
this.ShuffleSongButton.CheckOnClick = true;
|
||||
this.ShuffleSongButton.Enabled = false;
|
||||
this.ShuffleSongButton.Name = "ShuffleSongButton";
|
||||
this.ShuffleSongButton.Size = new System.Drawing.Size(123, 22);
|
||||
this.ShuffleSongButton.Text = "Shuffle";
|
||||
//
|
||||
// playlistToolStripMenuItem
|
||||
//
|
||||
this.playlistToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.makeToolStripMenuItem});
|
||||
this.playlistToolStripMenuItem.Name = "playlistToolStripMenuItem";
|
||||
this.playlistToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
|
||||
this.playlistToolStripMenuItem.Text = "Playlist";
|
||||
//
|
||||
// makeToolStripMenuItem
|
||||
//
|
||||
this.makeToolStripMenuItem.Name = "makeToolStripMenuItem";
|
||||
this.makeToolStripMenuItem.Size = new System.Drawing.Size(139, 22);
|
||||
this.makeToolStripMenuItem.Text = "Create / Edit";
|
||||
this.makeToolStripMenuItem.Click += new System.EventHandler(this.makeToolStripMenuItem_Click);
|
||||
//
|
||||
// searchToolStripMenuItem
|
||||
//
|
||||
this.searchToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SearchGenresToolStripLabel,
|
||||
this.SearchArtistToolStripLabel});
|
||||
this.searchToolStripMenuItem.Name = "searchToolStripMenuItem";
|
||||
this.searchToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
|
||||
this.searchToolStripMenuItem.Text = "Search";
|
||||
//
|
||||
// SearchGenresToolStripLabel
|
||||
//
|
||||
this.SearchGenresToolStripLabel.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SearchGenresTextBox,
|
||||
this.ClearGenreSearchButton});
|
||||
this.SearchGenresToolStripLabel.Name = "SearchGenresToolStripLabel";
|
||||
this.SearchGenresToolStripLabel.Size = new System.Drawing.Size(110, 22);
|
||||
this.SearchGenresToolStripLabel.Text = "Genres";
|
||||
//
|
||||
// SearchGenresTextBox
|
||||
//
|
||||
this.SearchGenresTextBox.Name = "SearchGenresTextBox";
|
||||
this.SearchGenresTextBox.Size = new System.Drawing.Size(100, 23);
|
||||
this.SearchGenresTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.SearchGenresTextBox_KeyUp);
|
||||
//
|
||||
// ClearGenreSearchButton
|
||||
//
|
||||
this.ClearGenreSearchButton.Enabled = false;
|
||||
this.ClearGenreSearchButton.Name = "ClearGenreSearchButton";
|
||||
this.ClearGenreSearchButton.Size = new System.Drawing.Size(160, 22);
|
||||
this.ClearGenreSearchButton.Text = "Clear Search";
|
||||
this.ClearGenreSearchButton.Click += new System.EventHandler(this.ClearGenreSearchButton_Click);
|
||||
//
|
||||
// SearchArtistToolStripLabel
|
||||
//
|
||||
this.SearchArtistToolStripLabel.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SearchArtistsTextBox,
|
||||
this.ClearArtistSearchButton});
|
||||
this.SearchArtistToolStripLabel.Name = "SearchArtistToolStripLabel";
|
||||
this.SearchArtistToolStripLabel.Size = new System.Drawing.Size(110, 22);
|
||||
this.SearchArtistToolStripLabel.Text = "Artists";
|
||||
//
|
||||
// SearchArtistsTextBox
|
||||
//
|
||||
this.SearchArtistsTextBox.Name = "SearchArtistsTextBox";
|
||||
this.SearchArtistsTextBox.Size = new System.Drawing.Size(100, 23);
|
||||
this.SearchArtistsTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.SearchArtistsTextBox_KeyUp);
|
||||
//
|
||||
// ClearArtistSearchButton
|
||||
//
|
||||
this.ClearArtistSearchButton.Enabled = false;
|
||||
this.ClearArtistSearchButton.Name = "ClearArtistSearchButton";
|
||||
this.ClearArtistSearchButton.Size = new System.Drawing.Size(160, 22);
|
||||
this.ClearArtistSearchButton.Text = "Clear Search";
|
||||
this.ClearArtistSearchButton.Click += new System.EventHandler(this.ClearArtistSearchButton_Click);
|
||||
//
|
||||
// serverToolStripMenuItem
|
||||
//
|
||||
this.serverToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SelectServerJancoButton,
|
||||
this.SelectServerYorickButton});
|
||||
this.serverToolStripMenuItem.Name = "serverToolStripMenuItem";
|
||||
this.serverToolStripMenuItem.Size = new System.Drawing.Size(51, 20);
|
||||
this.serverToolStripMenuItem.Text = "Server";
|
||||
//
|
||||
// SelectServerJancoButton
|
||||
//
|
||||
this.SelectServerJancoButton.Name = "SelectServerJancoButton";
|
||||
this.SelectServerJancoButton.Size = new System.Drawing.Size(148, 22);
|
||||
this.SelectServerJancoButton.Text = "jancokock.me";
|
||||
this.SelectServerJancoButton.Click += new System.EventHandler(this.SelectServerJancoButton_Click);
|
||||
//
|
||||
// SelectServerYorickButton
|
||||
//
|
||||
this.SelectServerYorickButton.Name = "SelectServerYorickButton";
|
||||
this.SelectServerYorickButton.Size = new System.Drawing.Size(148, 22);
|
||||
this.SelectServerYorickButton.Text = "imegumii.nl";
|
||||
this.SelectServerYorickButton.Click += new System.EventHandler(this.SelectServerYorickButton_Click);
|
||||
//
|
||||
// ControlsPanel
|
||||
//
|
||||
this.ControlsPanel.BackColor = System.Drawing.SystemColors.WindowFrame;
|
||||
this.ControlsPanel.Controls.Add(this.NextButton);
|
||||
this.ControlsPanel.Controls.Add(this.PreviousButton);
|
||||
this.ControlsPanel.Controls.Add(this.CurrentSongLabel);
|
||||
this.ControlsPanel.Controls.Add(this.LabelTotalTime);
|
||||
this.ControlsPanel.Controls.Add(this.LabelCurrentTime);
|
||||
this.ControlsPanel.Controls.Add(this.PositionTrackBar);
|
||||
this.ControlsPanel.Controls.Add(this.BufferLabel);
|
||||
this.ControlsPanel.Controls.Add(this.BufferBar);
|
||||
this.ControlsPanel.Controls.Add(this.StopButton);
|
||||
this.ControlsPanel.Controls.Add(this.PauseButton);
|
||||
this.ControlsPanel.Controls.Add(this.PlayButton);
|
||||
this.ControlsPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.ControlsPanel.Location = new System.Drawing.Point(0, 343);
|
||||
this.ControlsPanel.Location = new System.Drawing.Point(0, 378);
|
||||
this.ControlsPanel.Name = "ControlsPanel";
|
||||
this.ControlsPanel.Size = new System.Drawing.Size(784, 119);
|
||||
this.ControlsPanel.Size = new System.Drawing.Size(784, 83);
|
||||
this.ControlsPanel.TabIndex = 4;
|
||||
//
|
||||
// NextButton
|
||||
//
|
||||
this.NextButton.Location = new System.Drawing.Point(214, 51);
|
||||
this.NextButton.Name = "NextButton";
|
||||
this.NextButton.Size = new System.Drawing.Size(31, 23);
|
||||
this.NextButton.TabIndex = 13;
|
||||
this.NextButton.Text = ">";
|
||||
this.NextButton.UseVisualStyleBackColor = true;
|
||||
this.NextButton.Click += new System.EventHandler(this.NextButton_Click);
|
||||
//
|
||||
// PreviousButton
|
||||
//
|
||||
this.PreviousButton.Location = new System.Drawing.Point(177, 51);
|
||||
this.PreviousButton.Name = "PreviousButton";
|
||||
this.PreviousButton.Size = new System.Drawing.Size(31, 23);
|
||||
this.PreviousButton.TabIndex = 12;
|
||||
this.PreviousButton.Text = "<";
|
||||
this.PreviousButton.UseVisualStyleBackColor = true;
|
||||
this.PreviousButton.Click += new System.EventHandler(this.PreviousButton_Click);
|
||||
//
|
||||
// CurrentSongLabel
|
||||
//
|
||||
this.CurrentSongLabel.AutoSize = true;
|
||||
this.CurrentSongLabel.Location = new System.Drawing.Point(256, 56);
|
||||
this.CurrentSongLabel.Name = "CurrentSongLabel";
|
||||
this.CurrentSongLabel.Size = new System.Drawing.Size(111, 13);
|
||||
this.CurrentSongLabel.TabIndex = 11;
|
||||
this.CurrentSongLabel.Text = "Not playing any songs";
|
||||
//
|
||||
// LabelTotalTime
|
||||
//
|
||||
this.LabelTotalTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.LabelTotalTime.AutoSize = true;
|
||||
this.LabelTotalTime.Location = new System.Drawing.Point(723, 26);
|
||||
this.LabelTotalTime.Name = "LabelTotalTime";
|
||||
this.LabelTotalTime.Size = new System.Drawing.Size(49, 13);
|
||||
this.LabelTotalTime.TabIndex = 9;
|
||||
this.LabelTotalTime.Text = "00:00:00";
|
||||
//
|
||||
// LabelCurrentTime
|
||||
//
|
||||
this.LabelCurrentTime.AutoSize = true;
|
||||
this.LabelCurrentTime.Location = new System.Drawing.Point(12, 26);
|
||||
this.LabelCurrentTime.Name = "LabelCurrentTime";
|
||||
this.LabelCurrentTime.Size = new System.Drawing.Size(49, 13);
|
||||
this.LabelCurrentTime.TabIndex = 8;
|
||||
this.LabelCurrentTime.Text = "00:00:00";
|
||||
//
|
||||
// PositionTrackBar
|
||||
//
|
||||
this.PositionTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PositionTrackBar.Enabled = false;
|
||||
this.PositionTrackBar.Location = new System.Drawing.Point(3, 3);
|
||||
this.PositionTrackBar.Maximum = 1000;
|
||||
this.PositionTrackBar.Name = "PositionTrackBar";
|
||||
this.PositionTrackBar.Size = new System.Drawing.Size(778, 45);
|
||||
this.PositionTrackBar.TabIndex = 7;
|
||||
this.PositionTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
|
||||
this.PositionTrackBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PositionTrackBar_MouseDown);
|
||||
//
|
||||
// BufferLabel
|
||||
//
|
||||
this.BufferLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.BufferLabel.AutoSize = true;
|
||||
this.BufferLabel.Location = new System.Drawing.Point(601, 56);
|
||||
this.BufferLabel.Name = "BufferLabel";
|
||||
this.BufferLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.BufferLabel.TabIndex = 5;
|
||||
this.BufferLabel.Text = "Buffer";
|
||||
//
|
||||
// BufferBar
|
||||
//
|
||||
this.BufferBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.BufferBar.Location = new System.Drawing.Point(642, 51);
|
||||
this.BufferBar.Name = "BufferBar";
|
||||
this.BufferBar.Size = new System.Drawing.Size(130, 23);
|
||||
this.BufferBar.TabIndex = 3;
|
||||
//
|
||||
// StopButton
|
||||
//
|
||||
this.StopButton.Enabled = false;
|
||||
this.StopButton.Location = new System.Drawing.Point(122, 51);
|
||||
this.StopButton.Name = "StopButton";
|
||||
this.StopButton.Size = new System.Drawing.Size(49, 23);
|
||||
this.StopButton.TabIndex = 2;
|
||||
this.StopButton.Text = "Stop";
|
||||
this.StopButton.UseVisualStyleBackColor = true;
|
||||
this.StopButton.Click += new System.EventHandler(this.StopButton_Click);
|
||||
//
|
||||
// PauseButton
|
||||
//
|
||||
this.PauseButton.Enabled = false;
|
||||
this.PauseButton.Location = new System.Drawing.Point(67, 51);
|
||||
this.PauseButton.Name = "PauseButton";
|
||||
this.PauseButton.Size = new System.Drawing.Size(49, 23);
|
||||
this.PauseButton.TabIndex = 1;
|
||||
this.PauseButton.Text = "Pause";
|
||||
this.PauseButton.UseVisualStyleBackColor = true;
|
||||
this.PauseButton.Click += new System.EventHandler(this.PauseButton_Click);
|
||||
//
|
||||
// PlayButton
|
||||
//
|
||||
this.PlayButton.Location = new System.Drawing.Point(12, 13);
|
||||
this.PlayButton.Location = new System.Drawing.Point(12, 51);
|
||||
this.PlayButton.Name = "PlayButton";
|
||||
this.PlayButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.PlayButton.Size = new System.Drawing.Size(49, 23);
|
||||
this.PlayButton.TabIndex = 0;
|
||||
this.PlayButton.Text = "Play";
|
||||
this.PlayButton.UseVisualStyleBackColor = true;
|
||||
this.PlayButton.Click += new System.EventHandler(this.PlayButton_Click);
|
||||
//
|
||||
// UpdateTimer
|
||||
//
|
||||
this.UpdateTimer.Interval = 200;
|
||||
this.UpdateTimer.Tick += new System.EventHandler(this.UpdateTimer_Tick);
|
||||
//
|
||||
// NotifyIcon
|
||||
//
|
||||
this.NotifyIcon.ContextMenuStrip = this.NotifyMenuStrip;
|
||||
this.NotifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("NotifyIcon.Icon")));
|
||||
this.NotifyIcon.Text = "NotifyIcon";
|
||||
this.NotifyIcon.Visible = true;
|
||||
this.NotifyIcon.MouseUp += new System.Windows.Forms.MouseEventHandler(this.NotifyIcon_Click);
|
||||
//
|
||||
// NotifyMenuStrip
|
||||
//
|
||||
this.NotifyMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.NotifyMenuStripPlayingLabel,
|
||||
this.toolStripSeparator2,
|
||||
this.NotifyMenuStripPlayButton,
|
||||
this.NotifyMenuStripPauseButton,
|
||||
this.NotifyMenuStripStopButton,
|
||||
this.toolStripSeparator3,
|
||||
this.NotifyMenuStripNextButton,
|
||||
this.NotifyMenuStripPreviousButton});
|
||||
this.NotifyMenuStrip.Name = "NotifyMenuStrip";
|
||||
this.NotifyMenuStrip.Size = new System.Drawing.Size(120, 148);
|
||||
//
|
||||
// NotifyMenuStripPlayingLabel
|
||||
//
|
||||
this.NotifyMenuStripPlayingLabel.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.NotifyMenuStripPlayingSongLabel});
|
||||
this.NotifyMenuStripPlayingLabel.Enabled = false;
|
||||
this.NotifyMenuStripPlayingLabel.Name = "NotifyMenuStripPlayingLabel";
|
||||
this.NotifyMenuStripPlayingLabel.Size = new System.Drawing.Size(119, 22);
|
||||
this.NotifyMenuStripPlayingLabel.Text = "Stopped";
|
||||
//
|
||||
// NotifyMenuStripPlayingSongLabel
|
||||
//
|
||||
this.NotifyMenuStripPlayingSongLabel.Enabled = false;
|
||||
this.NotifyMenuStripPlayingSongLabel.Name = "NotifyMenuStripPlayingSongLabel";
|
||||
this.NotifyMenuStripPlayingSongLabel.Size = new System.Drawing.Size(118, 22);
|
||||
this.NotifyMenuStripPlayingSongLabel.Text = "Stopped";
|
||||
this.NotifyMenuStripPlayingSongLabel.Visible = false;
|
||||
//
|
||||
// toolStripSeparator2
|
||||
//
|
||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
this.toolStripSeparator2.Size = new System.Drawing.Size(116, 6);
|
||||
//
|
||||
// NotifyMenuStripPlayButton
|
||||
//
|
||||
this.NotifyMenuStripPlayButton.Name = "NotifyMenuStripPlayButton";
|
||||
this.NotifyMenuStripPlayButton.Size = new System.Drawing.Size(119, 22);
|
||||
this.NotifyMenuStripPlayButton.Text = "Play";
|
||||
this.NotifyMenuStripPlayButton.Click += new System.EventHandler(this.NotifyMenuStripPlayButton_Click);
|
||||
//
|
||||
// NotifyMenuStripPauseButton
|
||||
//
|
||||
this.NotifyMenuStripPauseButton.Enabled = false;
|
||||
this.NotifyMenuStripPauseButton.Name = "NotifyMenuStripPauseButton";
|
||||
this.NotifyMenuStripPauseButton.Size = new System.Drawing.Size(119, 22);
|
||||
this.NotifyMenuStripPauseButton.Text = "Pause";
|
||||
this.NotifyMenuStripPauseButton.Click += new System.EventHandler(this.NotifyMenuStripPauseButton_Click);
|
||||
//
|
||||
// NotifyMenuStripStopButton
|
||||
//
|
||||
this.NotifyMenuStripStopButton.Enabled = false;
|
||||
this.NotifyMenuStripStopButton.Name = "NotifyMenuStripStopButton";
|
||||
this.NotifyMenuStripStopButton.Size = new System.Drawing.Size(119, 22);
|
||||
this.NotifyMenuStripStopButton.Text = "Stop";
|
||||
this.NotifyMenuStripStopButton.Click += new System.EventHandler(this.NotifyMenuStripStopButton_Click);
|
||||
//
|
||||
// toolStripSeparator3
|
||||
//
|
||||
this.toolStripSeparator3.Name = "toolStripSeparator3";
|
||||
this.toolStripSeparator3.Size = new System.Drawing.Size(116, 6);
|
||||
//
|
||||
// NotifyMenuStripNextButton
|
||||
//
|
||||
this.NotifyMenuStripNextButton.Name = "NotifyMenuStripNextButton";
|
||||
this.NotifyMenuStripNextButton.Size = new System.Drawing.Size(119, 22);
|
||||
this.NotifyMenuStripNextButton.Text = "Next";
|
||||
this.NotifyMenuStripNextButton.Click += new System.EventHandler(this.NotifyMenuStripNextButton_Click);
|
||||
//
|
||||
// NotifyMenuStripPreviousButton
|
||||
//
|
||||
this.NotifyMenuStripPreviousButton.Name = "NotifyMenuStripPreviousButton";
|
||||
this.NotifyMenuStripPreviousButton.Size = new System.Drawing.Size(119, 22);
|
||||
this.NotifyMenuStripPreviousButton.Text = "Previous";
|
||||
this.NotifyMenuStripPreviousButton.Click += new System.EventHandler(this.NotifyMenuStripPreviousButton_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(784, 462);
|
||||
this.ClientSize = new System.Drawing.Size(784, 461);
|
||||
this.Controls.Add(this.ControlsPanel);
|
||||
this.Controls.Add(this.MainPanel);
|
||||
this.Controls.Add(this.MenuStrip);
|
||||
@@ -188,12 +706,21 @@
|
||||
this.MinimumSize = new System.Drawing.Size(800, 500);
|
||||
this.Name = "MainForm";
|
||||
this.Text = "YJMPD Music Player";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
||||
this.Load += new System.EventHandler(this.MainForm_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).EndInit();
|
||||
this.MainPanel.ResumeLayout(false);
|
||||
this.MainPanel.PerformLayout();
|
||||
this.SplitContainer.Panel1.ResumeLayout(false);
|
||||
this.SplitContainer.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.SplitContainer)).EndInit();
|
||||
this.SplitContainer.ResumeLayout(false);
|
||||
this.MenuStrip.ResumeLayout(false);
|
||||
this.MenuStrip.PerformLayout();
|
||||
this.ControlsPanel.ResumeLayout(false);
|
||||
this.ControlsPanel.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PositionTrackBar)).EndInit();
|
||||
this.NotifyMenuStrip.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -208,11 +735,59 @@
|
||||
private System.Windows.Forms.Panel MainPanel;
|
||||
private System.Windows.Forms.MenuStrip MenuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
|
||||
private System.Windows.Forms.Panel ControlsPanel;
|
||||
private System.Windows.Forms.Button PlayButton;
|
||||
private System.Windows.Forms.Button StopButton;
|
||||
private System.Windows.Forms.Button PauseButton;
|
||||
private System.Windows.Forms.Label BufferLabel;
|
||||
private System.Windows.Forms.ProgressBar BufferBar;
|
||||
private System.Windows.Forms.Timer UpdateTimer;
|
||||
private System.Windows.Forms.TrackBar PositionTrackBar;
|
||||
private System.Windows.Forms.Label LabelTotalTime;
|
||||
private System.Windows.Forms.Label LabelCurrentTime;
|
||||
private System.Windows.Forms.NotifyIcon NotifyIcon;
|
||||
private System.Windows.Forms.Label CurrentSongLabel;
|
||||
private System.Windows.Forms.Label AlbumListLabel;
|
||||
private System.Windows.Forms.Label ArtistListLabel;
|
||||
private System.Windows.Forms.Label GenreListLabel;
|
||||
private System.Windows.Forms.ToolStripMenuItem playlistsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem overviewToolStripMenuItem;
|
||||
public System.Windows.Forms.ListBox PlaylistBox;
|
||||
private System.Windows.Forms.Label PlaylistListLabel;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem playlistToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ContextMenuStrip NotifyMenuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem NotifyMenuStripPlayButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem NotifyMenuStripPauseButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem NotifyMenuStripStopButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem NotifyMenuStripPlayingLabel;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||
private System.Windows.Forms.ToolStripMenuItem NotifyMenuStripPlayingSongLabel;
|
||||
private System.Windows.Forms.SplitContainer SplitContainer;
|
||||
private System.Windows.Forms.ToolStripMenuItem makeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem SearchArtistToolStripLabel;
|
||||
private System.Windows.Forms.ToolStripTextBox SearchArtistsTextBox;
|
||||
private System.Windows.Forms.ToolStripMenuItem SearchGenresToolStripLabel;
|
||||
private System.Windows.Forms.ToolStripTextBox SearchGenresTextBox;
|
||||
private System.Windows.Forms.ToolStripMenuItem ClearArtistSearchButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem ClearGenreSearchButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem playbackToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ShuffleSongButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem LoopSongButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem PlayNextSongButton;
|
||||
private System.Windows.Forms.Button NextButton;
|
||||
private System.Windows.Forms.Button PreviousButton;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
|
||||
private System.Windows.Forms.ToolStripMenuItem NotifyMenuStripNextButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem NotifyMenuStripPreviousButton;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
||||
private System.Windows.Forms.ToolStripMenuItem ViewCurrentPlaylistButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem serverToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem SelectServerJancoButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem SelectServerYorickButton;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -17,6 +18,12 @@ namespace MusicPlayer
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
bool songFinished;
|
||||
bool draggedstarted = false;
|
||||
bool draggedcompleted = false;
|
||||
int startx = 0;
|
||||
int starty = 0;
|
||||
|
||||
public Main main
|
||||
{
|
||||
get; set;
|
||||
@@ -25,21 +32,495 @@ namespace MusicPlayer
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
PositionTrackBar.Scroll += (s, e) =>
|
||||
{
|
||||
this.PositionTrackBar_ValueChanged();
|
||||
};
|
||||
PositionTrackBar.MouseDown += (s, e) =>
|
||||
{
|
||||
clicked = true;
|
||||
};
|
||||
PositionTrackBar.MouseUp += (s, e) =>
|
||||
{
|
||||
if (!clicked)
|
||||
return;
|
||||
|
||||
clicked = false;
|
||||
this.PositionTrackBar_ValueChanged();
|
||||
};
|
||||
|
||||
songFinished = false;
|
||||
}
|
||||
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
UpdateTimer.Start();
|
||||
}
|
||||
|
||||
private void PlayButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
AudioHandler.PlayMp3FromUrl("http://imegumii.nl/music/English/Monstercat/Direct%20-%20Eternity.mp3");
|
||||
if (main.audio.AState == AudioHandler.AudioState.PAUSED)
|
||||
main.audio.Play(main.audio.CurrentSong);
|
||||
else
|
||||
SongsTableView_CellDoubleClick(sender, new DataGridViewCellEventArgs(0, 0));
|
||||
}
|
||||
|
||||
private void SongsTableView_SelectionChanged(object sender, EventArgs e)
|
||||
private void PauseButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DataGridViewSelectedRowCollection col = SongsTableView.SelectedRows;
|
||||
main.audio.Pause();
|
||||
}
|
||||
|
||||
private void StopButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
main.audio.Stop();
|
||||
}
|
||||
|
||||
public void SongFinished()
|
||||
{
|
||||
songFinished = true;
|
||||
}
|
||||
|
||||
private void UpdateTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
//Trackbar
|
||||
if (main.audio.BState == AudioHandler.BufferState.DONE)
|
||||
PositionTrackBar.Enabled = true;
|
||||
else
|
||||
PositionTrackBar.Enabled = false;
|
||||
if (!clicked)
|
||||
PositionTrackBar.Value = Math.Max(main.audio.Position, 0);
|
||||
|
||||
//Buffer display
|
||||
BufferBar.Value = main.audio.Buffered / 10;
|
||||
|
||||
//Time labels
|
||||
if (!clicked)
|
||||
LabelCurrentTime.Text = Main.SecondsToTimestamp(main.audio.CurrentTime);
|
||||
LabelTotalTime.Text = Main.SecondsToTimestamp(main.audio.TotalTime);
|
||||
|
||||
//Current song label
|
||||
if (main.audio.CurrentSong == null)
|
||||
CurrentSongLabel.Text = "Not playing any songs";
|
||||
else
|
||||
{
|
||||
if (main.audio.CurrentSong.Seconds < 1)
|
||||
PositionTrackBar.Enabled = false;
|
||||
CurrentSongLabel.Text = "Currently playing: " + main.audio.CurrentSong.Name;
|
||||
}
|
||||
|
||||
//Buttons and context menu
|
||||
if (main.audio.AState == AudioHandler.AudioState.PLAYING)
|
||||
{
|
||||
PlayButton.Enabled = false;
|
||||
NotifyMenuStripPlayButton.Enabled = false;
|
||||
NotifyMenuStripPlayingLabel.Text = "Playing";
|
||||
NotifyMenuStripPlayingLabel.Enabled = true;
|
||||
NotifyMenuStripPlayingSongLabel.Visible = true;
|
||||
NotifyMenuStripPlayingSongLabel.Text = main.audio.CurrentSong.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayButton.Enabled = true;
|
||||
NotifyMenuStripPlayButton.Enabled = true;
|
||||
NotifyMenuStripPlayingSongLabel.Visible = false;
|
||||
}
|
||||
|
||||
if (main.nw.ip == "http://jancokock.me")
|
||||
SelectServerJancoButton.Enabled = false;
|
||||
else
|
||||
SelectServerJancoButton.Enabled = true;
|
||||
|
||||
if (main.nw.ip == "http://imegumii.nl")
|
||||
SelectServerYorickButton.Enabled = false;
|
||||
else
|
||||
SelectServerYorickButton.Enabled = true;
|
||||
|
||||
if (main.audio.AState == AudioHandler.AudioState.PAUSED)
|
||||
{
|
||||
PauseButton.Enabled = false;
|
||||
NotifyMenuStripPauseButton.Enabled = false;
|
||||
NotifyMenuStripPlayingLabel.Text = "Paused";
|
||||
NotifyMenuStripPlayingLabel.Enabled = true;
|
||||
NotifyMenuStripPlayingSongLabel.Visible = true;
|
||||
NotifyMenuStripPlayingSongLabel.Text = main.audio.CurrentSong.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
PauseButton.Enabled = true;
|
||||
NotifyMenuStripPauseButton.Enabled = true;
|
||||
}
|
||||
|
||||
if (main.audio.AState == AudioHandler.AudioState.STOPPED)
|
||||
{
|
||||
StopButton.Enabled = false;
|
||||
NotifyMenuStripStopButton.Enabled = false;
|
||||
NotifyMenuStripPlayingLabel.Text = "Stopped";
|
||||
NotifyMenuStripPlayingLabel.Enabled = false;
|
||||
NotifyMenuStripPlayingSongLabel.Visible = false;
|
||||
NotifyMenuStripPlayingSongLabel.Text = "Stopped";
|
||||
}
|
||||
else
|
||||
{
|
||||
StopButton.Enabled = true;
|
||||
NotifyMenuStripStopButton.Enabled = true;
|
||||
}
|
||||
|
||||
if(PlayNextSongButton.Checked)
|
||||
{
|
||||
ShuffleSongButton.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ShuffleSongButton.Enabled = false;
|
||||
ShuffleSongButton.Checked = false;
|
||||
}
|
||||
|
||||
if (main.currentPlayingList.Count <= 1)
|
||||
{
|
||||
PreviousButton.Enabled = false;
|
||||
NextButton.Enabled = false;
|
||||
NotifyMenuStripPreviousButton.Enabled = false;
|
||||
NotifyMenuStripNextButton.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
NextButton.Enabled = true;
|
||||
NotifyMenuStripNextButton.Enabled = true;
|
||||
|
||||
if (ShuffleSongButton.Checked)
|
||||
{
|
||||
PreviousButton.Enabled = false;
|
||||
NotifyMenuStripPreviousButton.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
PreviousButton.Enabled = true;
|
||||
NotifyMenuStripPreviousButton.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (songFinished)
|
||||
{
|
||||
Thread.Sleep(20);
|
||||
|
||||
if (PlayNextSongButton.Checked)
|
||||
{
|
||||
NextButton_Click(this, new EventArgs());
|
||||
}
|
||||
else if (LoopSongButton.Checked)
|
||||
{
|
||||
main.audio.Play(main.audio.CurrentSong);
|
||||
}
|
||||
|
||||
songFinished = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void GenreListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (GenreListBox.SelectedItems.Count != 0)
|
||||
{
|
||||
main.GenreFilter(GenreListBox.SelectedItems[0].ToString());
|
||||
ArtistListBox.ClearSelected();
|
||||
PlaylistBox.ClearSelected();
|
||||
AlbumListView.SelectedIndices.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaylistBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (PlaylistBox.SelectedItems.Count != 0)
|
||||
{
|
||||
main.PlaylistFilter(PlaylistBox.SelectedItems[0].ToString());
|
||||
GenreListBox.ClearSelected();
|
||||
ArtistListBox.ClearSelected();
|
||||
AlbumListView.SelectedIndices.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void ArtistListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (ArtistListBox.SelectedItems.Count != 0)
|
||||
{
|
||||
main.ArtistFilter(ArtistListBox.SelectedItems[0].ToString());
|
||||
GenreListBox.ClearSelected();
|
||||
PlaylistBox.ClearSelected();
|
||||
AlbumListView.SelectedIndices.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void AlbumListView_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (AlbumListView.SelectedItems.Count != 0)
|
||||
{
|
||||
main.AlbumFilter(AlbumListView.SelectedItems[0].Text);
|
||||
PlaylistBox.ClearSelected();
|
||||
ArtistListBox.ClearSelected();
|
||||
GenreListBox.ClearSelected();
|
||||
}
|
||||
}
|
||||
|
||||
private void SongsTableView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex != -1)
|
||||
{
|
||||
SongsTable s = new SongsTable();
|
||||
if (SongsTableView.SelectedRows.Count > 0)
|
||||
{
|
||||
main.currentPlayingList = main.table.AsEnumerable().Select(x => x[5] as Song).ToList();
|
||||
|
||||
var drv = SongsTableView.SelectedRows[0].DataBoundItem as DataRowView;
|
||||
var row = drv.Row as DataRow;
|
||||
s.ImportRow(row);
|
||||
main.audio.Play((s.Rows[0][5] as Song));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PositionTrackBar_ValueChanged()
|
||||
{
|
||||
if (!clicked)
|
||||
main.audio.Seek(PositionTrackBar.Value);
|
||||
|
||||
LabelCurrentTime.Text = Main.SecondsToTimestamp((int)(((double)PositionTrackBar.Value / 1000) * main.audio.CurrentSong.Seconds));
|
||||
}
|
||||
|
||||
private void NotifyIcon_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
MethodInfo mi = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
mi.Invoke(NotifyIcon, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void overviewToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.PlaylistBox.Visible = false;
|
||||
this.GenreListBox.Visible = true;
|
||||
this.ArtistListBox.Visible = true;
|
||||
this.AlbumListView.Visible = true;
|
||||
this.GenreListLabel.Visible = true;
|
||||
this.AlbumListLabel.Visible = true;
|
||||
this.ArtistListLabel.Visible = true;
|
||||
this.PlaylistListLabel.Visible = false;
|
||||
}
|
||||
|
||||
private void playlistsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.PlaylistBox.Visible = true;
|
||||
this.GenreListBox.Visible = false;
|
||||
this.ArtistListBox.Visible = false;
|
||||
this.AlbumListView.Visible = false;
|
||||
this.GenreListLabel.Visible = false;
|
||||
this.AlbumListLabel.Visible = false;
|
||||
this.ArtistListLabel.Visible = false;
|
||||
this.PlaylistListLabel.Visible = true;
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ExitProgram();
|
||||
}
|
||||
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
ExitProgram();
|
||||
}
|
||||
|
||||
private void ExitProgram()
|
||||
{
|
||||
main.audio.AState = AudioHandler.AudioState.STOPPED;
|
||||
NotifyIcon.Visible = false;
|
||||
NotifyIcon.Icon = null;
|
||||
System.Windows.Forms.Application.Exit();
|
||||
}
|
||||
|
||||
private void NotifyMenuStripPlayButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
PlayButton_Click(sender, e);
|
||||
}
|
||||
|
||||
private void NotifyMenuStripPauseButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
PauseButton_Click(sender, e);
|
||||
}
|
||||
|
||||
private void NotifyMenuStripStopButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
StopButton_Click(sender, e);
|
||||
}
|
||||
|
||||
private void makeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
PlaylistMaker p = new PlaylistMaker(main.pl, main.api);
|
||||
p.ShowDialog();
|
||||
main.Repopulate();
|
||||
}
|
||||
|
||||
private void SearchArtistsTextBox_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
main.SearchArtist(SearchArtistsTextBox.Text);
|
||||
if (SearchArtistsTextBox.Text.Length < 1)
|
||||
ClearArtistSearchButton.Enabled = false;
|
||||
else
|
||||
ClearArtistSearchButton.Enabled = true;
|
||||
}
|
||||
|
||||
private void SearchGenresTextBox_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
main.SearchGenre(SearchGenresTextBox.Text);
|
||||
if (SearchGenresTextBox.Text.Length < 1)
|
||||
ClearGenreSearchButton.Enabled = false;
|
||||
else
|
||||
ClearGenreSearchButton.Enabled = true;
|
||||
}
|
||||
|
||||
private void ClearArtistSearchButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
main.SearchArtist("");
|
||||
SearchArtistsTextBox.Text = "";
|
||||
ClearArtistSearchButton.Enabled = false;
|
||||
}
|
||||
|
||||
private void ClearGenreSearchButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
main.SearchGenre("");
|
||||
SearchGenresTextBox.Text = "";
|
||||
ClearGenreSearchButton.Enabled = false;
|
||||
}
|
||||
|
||||
private void PositionTrackBar_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
double dblValue;
|
||||
dblValue = ((double)(e.X+PositionTrackBar.Location.X) / (double)(PositionTrackBar.Width + PositionTrackBar.Location.X)) * (PositionTrackBar.Maximum - PositionTrackBar.Minimum);
|
||||
PositionTrackBar.Value = Convert.ToInt32(dblValue);
|
||||
}
|
||||
|
||||
private void PreviousButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
int selected = 0;
|
||||
selected = main.currentPlayingList.IndexOf(main.audio.CurrentSong) - 1;
|
||||
|
||||
if (selected < 0)
|
||||
{
|
||||
if (LoopSongButton.Checked)
|
||||
selected = main.currentPlayingList.Count-1;
|
||||
}
|
||||
|
||||
main.FilterCurrentPlaying();
|
||||
SongsTableView.CurrentCell = SongsTableView.Rows[selected].Cells[0];
|
||||
main.audio.Play(main.currentPlayingList[selected]);
|
||||
}
|
||||
|
||||
private void NextButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
int selected = 0;
|
||||
|
||||
if (ShuffleSongButton.Checked)
|
||||
{
|
||||
Random r = new Random();
|
||||
selected = r.Next(0, main.currentPlayingList.Count);
|
||||
while (selected == main.currentPlayingList.IndexOf(main.audio.CurrentSong) && main.currentPlayingList.Count > 1)
|
||||
selected = r.Next(0, main.currentPlayingList.Count);
|
||||
}
|
||||
else
|
||||
selected = main.currentPlayingList.IndexOf(main.audio.CurrentSong) + 1;
|
||||
|
||||
if (selected >= main.currentPlayingList.Count)
|
||||
{
|
||||
if (LoopSongButton.Checked)
|
||||
selected = 0;
|
||||
else
|
||||
{
|
||||
songFinished = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
main.FilterCurrentPlaying();
|
||||
SongsTableView.CurrentCell = SongsTableView.Rows[selected].Cells[0];
|
||||
main.audio.Play(main.currentPlayingList[selected]);
|
||||
}
|
||||
|
||||
private void NotifyMenuStripNextButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
NextButton_Click(sender, e);
|
||||
}
|
||||
|
||||
private void NotifyMenuStripPreviousButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
PreviousButton_Click(sender, e);
|
||||
}
|
||||
|
||||
private void ViewCurrentPlaylistButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
main.FilterCurrentPlaying();
|
||||
int selected = main.currentPlayingList.IndexOf(main.audio.CurrentSong);
|
||||
if(main.currentPlayingList.Count >= 1)
|
||||
SongsTableView.CurrentCell = SongsTableView.Rows[selected].Cells[0];
|
||||
}
|
||||
|
||||
|
||||
private void SongsTableView_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
draggedstarted = true;
|
||||
draggedcompleted = false;
|
||||
startx = e.X;
|
||||
starty = e.Y;
|
||||
}
|
||||
|
||||
private void SongsTableView_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (draggedcompleted)
|
||||
{
|
||||
Cursor.Current = Cursors.Default;
|
||||
Point point = PlaylistBox.PointToClient(Cursor.Position);
|
||||
int index = PlaylistBox.IndexFromPoint(point);
|
||||
if (index < 0) //nope, niet op een playlist gesleept
|
||||
{
|
||||
draggedstarted = false;
|
||||
draggedcompleted = false;
|
||||
return;
|
||||
}
|
||||
Playlist currentPlaylist = main.pl.GetPlaylistByName(PlaylistBox.Items[index].ToString());
|
||||
SongsTable s = new SongsTable();
|
||||
if (SongsTableView.SelectedRows.Count > 0)
|
||||
{
|
||||
var drv = SongsTableView.SelectedRows[0].DataBoundItem as DataRowView;
|
||||
var row = drv.Row as DataRow;
|
||||
s.ImportRow(row);
|
||||
currentPlaylist.AddSong((s.Rows[0][5] as Song));
|
||||
currentPlaylist.WriteToFile();
|
||||
}
|
||||
}
|
||||
|
||||
draggedcompleted = false;
|
||||
draggedstarted = false;
|
||||
}
|
||||
|
||||
private void SongsTableView_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
int deltax = Math.Abs(startx - e.X);
|
||||
int deltay = Math.Abs(starty - e.Y);
|
||||
|
||||
if ((deltax > 5 || deltay > 5) && draggedstarted && !draggedcompleted)
|
||||
{
|
||||
draggedcompleted = true;
|
||||
playlistsToolStripMenuItem_Click(this, new EventArgs());
|
||||
Cursor.Current = Cursors.Hand;
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectServerJancoButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
main.SwitchServer("http://jancokock.me");
|
||||
}
|
||||
|
||||
private void SelectServerYorickButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
main.SwitchServer("http://imegumii.nl");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Regular → Executable
+19
-5
@@ -33,6 +33,14 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AntiXssLibrary, Version=4.3.0.0, Culture=neutral, PublicKeyToken=d127efab8a9c114f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AntiXSS.4.3.0\lib\net40\AntiXssLibrary.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="HtmlSanitizationLibrary, Version=4.3.0.0, Culture=neutral, PublicKeyToken=d127efab8a9c114f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AntiXSS.4.3.0\lib\net40\HtmlSanitizationLibrary.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@@ -55,6 +63,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AudioHandler.cs" />
|
||||
<Compile Include="Genre.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
@@ -66,11 +75,13 @@
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="NetworkHandler.cs" />
|
||||
<Compile Include="NotificationPopup.cs">
|
||||
<Compile Include="Playlist.cs" />
|
||||
<Compile Include="PlaylistHandler.cs" />
|
||||
<Compile Include="PlaylistMaker.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NotificationPopup.Designer.cs">
|
||||
<DependentUpon>NotificationPopup.cs</DependentUpon>
|
||||
<Compile Include="PlaylistMaker.Designer.cs">
|
||||
<DependentUpon>PlaylistMaker.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -82,8 +93,8 @@
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="NotificationPopup.resx">
|
||||
<DependentUpon>NotificationPopup.cs</DependentUpon>
|
||||
<EmbeddedResource Include="PlaylistMaker.resx">
|
||||
<DependentUpon>PlaylistMaker.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
@@ -108,6 +119,9 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
using System.Text;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using Microsoft.Security.Application;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
|
||||
@@ -12,7 +14,7 @@ namespace MusicPlayer
|
||||
public class NetworkHandler
|
||||
{
|
||||
private int port = 8585;
|
||||
private string ip;
|
||||
public string ip { get; set; }
|
||||
|
||||
public NetworkHandler(string ip)
|
||||
{
|
||||
@@ -21,7 +23,9 @@ namespace MusicPlayer
|
||||
|
||||
public JObject SendString(string m)
|
||||
{
|
||||
HttpWebRequest server = (HttpWebRequest)WebRequest.Create(ip+":"+port+"/"+m);
|
||||
string encodedstring = Microsoft.Security.Application.Encoder.HtmlEncode(m);
|
||||
Console.WriteLine(encodedstring);
|
||||
HttpWebRequest server = (HttpWebRequest)WebRequest.Create(ip+":"+port+"/"+encodedstring);
|
||||
server.KeepAlive = false;
|
||||
HttpWebResponse respond = (HttpWebResponse)server.GetResponse();
|
||||
Stream streamResponse = respond.GetResponseStream();
|
||||
@@ -41,5 +45,44 @@ namespace MusicPlayer
|
||||
streamRead.Close();
|
||||
return o;
|
||||
}
|
||||
|
||||
public MemoryStream downloadArtwork(string album)
|
||||
{
|
||||
try
|
||||
{
|
||||
WebRequest req = WebRequest.Create((ip + "/music/artwork/"+album).Replace(" ", "%20"));
|
||||
WebResponse response = req.GetResponse();
|
||||
Stream stream = response.GetResponseStream();
|
||||
|
||||
//Download in chuncks
|
||||
byte[] buffer = new byte[1024];
|
||||
//Get Total Size
|
||||
int dataLength = (int)response.ContentLength;
|
||||
//Download to memory
|
||||
MemoryStream memStream = new MemoryStream();
|
||||
while (true)
|
||||
{
|
||||
//Try to read the data
|
||||
int bytesRead = stream.Read(buffer, 0, buffer.Length);
|
||||
if (bytesRead == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
memStream.Write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
//Clean up
|
||||
stream.Close();
|
||||
|
||||
//Convert the downloaded stream to a byte array
|
||||
return memStream;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
namespace MusicPlayer
|
||||
{
|
||||
partial class NotificationPopup
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NotificationPopup));
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.pictureBox2 = new System.Windows.Forms.PictureBox();
|
||||
this.pictureBox3 = new System.Windows.Forms.PictureBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.BackColor = System.Drawing.Color.White;
|
||||
this.groupBox1.Controls.Add(this.pictureBox3);
|
||||
this.groupBox1.Controls.Add(this.pictureBox2);
|
||||
this.groupBox1.Controls.Add(this.pictureBox1);
|
||||
resources.ApplyResources(this.groupBox1, "groupBox1");
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.TabStop = false;
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
resources.ApplyResources(this.pictureBox1, "pictureBox1");
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// pictureBox2
|
||||
//
|
||||
resources.ApplyResources(this.pictureBox2, "pictureBox2");
|
||||
this.pictureBox2.Name = "pictureBox2";
|
||||
this.pictureBox2.TabStop = false;
|
||||
//
|
||||
// pictureBox3
|
||||
//
|
||||
resources.ApplyResources(this.pictureBox3, "pictureBox3");
|
||||
this.pictureBox3.Name = "pictureBox3";
|
||||
this.pictureBox3.TabStop = false;
|
||||
//
|
||||
// NotificationPopup
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "NotificationPopup";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.PictureBox pictureBox3;
|
||||
private System.Windows.Forms.PictureBox pictureBox2;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
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;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
public partial class NotificationPopup : Form
|
||||
{
|
||||
public NotificationPopup()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,276 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="pictureBox3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQffCh0UITh4zTVoAAABr0lEQVRYR8WXQW7CMBRE
|
||||
wxVY9AA9D0k4QXqCrqqqaqtKPQOVWHOgcgyWHIHCjPmmcRjiOInISE8B/+/xF9ixnaWoKJYVWINfsAcH
|
||||
g5/Zxlhl6eMIhnOwAcdE2GduNmlCR/9cmdkQVnXPqJA4Aw9gB5RhH+hFz5kNo8UE8AiUyRjQWxeBAGGV
|
||||
quOYcAwbtSEExvzZb7Gz4UIh0HfC/Ym2GG5iXoQGLjWVGONJtHXlf4niS/I6z/Pli/WV8Q5s3OCUCMZ4
|
||||
ta5DCjh6A75eZcIN3lxHk4inUNGA728VVLzbuBeJnBTWNOAmooINyk8bM5DODWhbJVsacCdTwTpfNl4g
|
||||
tLe/WqGGT5M9E7idqqDn6mdPkfCrc4gWkOflh3n1kvKs4QqI/gUo4tv8AiE2yl/QaRK2FCHza0QnYedl
|
||||
qIpQeQm4ZZj0ImoWoXISOJ8fRaCVehEq3hWzcCY9NqNzESrWkWAz6rkdl8+6Pc5iUYQnZjTe80DyY8OG
|
||||
QmDSIxmZ/FA63bHciwmAVd7/YuKFRP8c42rmJhyezjNZ6Nj7cnq11IYKpv56vgXN6znbEq/nWXYCplmG
|
||||
3mQZHZoAAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="pictureBox3.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="pictureBox3.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>75, 158</value>
|
||||
</data>
|
||||
<data name="pictureBox3.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>33, 32</value>
|
||||
</data>
|
||||
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="pictureBox3.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name=">>pictureBox3.Name" xml:space="preserve">
|
||||
<value>pictureBox3</value>
|
||||
</data>
|
||||
<data name=">>pictureBox3.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>pictureBox3.Parent" xml:space="preserve">
|
||||
<value>groupBox1</value>
|
||||
</data>
|
||||
<data name=">>pictureBox3.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="pictureBox2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQffCh0UIRU9EmkdAAABx0lEQVRYR81XS26DMBDl
|
||||
EJGSdaXeoLkG0C7KtZIDZJWTdNlK6S2yzA2atu8NM9S4JnyMS5/0NMYzfjOAMXbWh6IotcX2YwUewHfw
|
||||
Al6VbLOPvkrDGa+tCbDBsBvwCH6NJMdsqJHnPzcxCBhodqdiMdy7mr1gILgCz2BIcAqptSrLJ83SAQSR
|
||||
dyDfa0gohtSEdkcRcNqdp0hupDZzaFZFnjfvfM7H3sVzndObmHDcmnCfgb4Y7jRt8+j5qYUCXd6Db15f
|
||||
DNfNU8BF73deR0rsFpyjkKNKimgooEUNlSemloW8mn8KTYjLazDApQQ7QJ/ZmEIqCnD9DjlblGwBwGd2
|
||||
SiEHDuRPJORsUbLcAGLMjinkxAH8k4WcLYr6ACDW7APYV8iFgYNWPlEdAYwxyyfyYjoer/+igFSvYMhc
|
||||
kFew+CRc/DNcciF6NpGQs0UJBNA2G5NYKEIELpb7GaFBLvI7BqUGAS72jtNnug0JYRsDOP5sS1YUheRs
|
||||
AAeZelP6Af7elBq4ZYYz1bacyamt2TqgRSQ5mICapQcWCDvH0UwmHKxoDoZzVuDnMvVwuq41vAk3Bu4B
|
||||
AoJ2PD+B/vGcffTVyyuAtra6kGXfchVyMfY7IlMAAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="pictureBox2.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="pictureBox2.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>114, 158</value>
|
||||
</data>
|
||||
<data name="pictureBox2.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>33, 32</value>
|
||||
</data>
|
||||
<data name="pictureBox2.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name=">>pictureBox2.Name" xml:space="preserve">
|
||||
<value>pictureBox2</value>
|
||||
</data>
|
||||
<data name=">>pictureBox2.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>pictureBox2.Parent" xml:space="preserve">
|
||||
<value>groupBox1</value>
|
||||
</data>
|
||||
<data name=">>pictureBox2.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQffCh0UHx1yDPpSAAABo0lEQVRYR8WXTW7CMBCF
|
||||
wxVY9AA9D4ScID1BV1VVFVSpZ6ASaw5Ej8GSI1D63nRME2si/8SQJ30ieMbPI7Bju0pRXTct2IFvcAJn
|
||||
hc9sY6zV9DJaLOo5TPfgkgj7zNUmTejoPr/UbAzbrmdQSJyBB3AElmEO9KLnTIexxQTwCCyTEtDbLgIB
|
||||
wiqtjiXhGDqqJwRK/uxDHHW4vhDImXA/RlsMMjGv0qVmJUawerbbg/wvUXzJWecC+y+Xq08rFmAvg1NG
|
||||
MBq1yCpCOuKBr1czIQYxUWUU0bIAvr+tYBQ69lWJRexYADcRK0iCs1zH7SmhiAML4E5mBQX1HBRyzDdb
|
||||
ZBEnGnA7tYKC+mUJRawtzw7nmxaA/u++n4cUcJO/AO0fXZ8B5C8oPgnxdtxYuQYyCYsuQ7SFfvYusgyL
|
||||
vYjw/c2PB/g7PxqBaMQAwvOrHwuhXaXzyM2oebFiAXqb0YjtuHky2mLon5jRsPUSYihzIHFCYNIjGZn8
|
||||
UDrdsdyJCYBV3v9i4oRE95kzMX3Srma+0PH+l9MhwdBdzw/Av56zLfF6XlW/G66G3g3Cfq0AAAAASUVO
|
||||
RK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="pictureBox1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>153, 158</value>
|
||||
</data>
|
||||
<data name="pictureBox1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>33, 32</value>
|
||||
</data>
|
||||
<data name="pictureBox1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name=">>pictureBox1.Name" xml:space="preserve">
|
||||
<value>pictureBox1</value>
|
||||
</data>
|
||||
<data name=">>pictureBox1.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>pictureBox1.Parent" xml:space="preserve">
|
||||
<value>groupBox1</value>
|
||||
</data>
|
||||
<data name=">>pictureBox1.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="groupBox1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>12, 12</value>
|
||||
</data>
|
||||
<data name="groupBox1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>266, 196</value>
|
||||
</data>
|
||||
<data name="groupBox1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name=">>groupBox1.Name" xml:space="preserve">
|
||||
<value>groupBox1</value>
|
||||
</data>
|
||||
<data name=">>groupBox1.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>groupBox1.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>groupBox1.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
|
||||
<value>6, 13</value>
|
||||
</data>
|
||||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>290, 220</value>
|
||||
</data>
|
||||
<data name="$this.Text" xml:space="preserve">
|
||||
<value>NotificationPopup</value>
|
||||
</data>
|
||||
<data name=">>$this.Name" xml:space="preserve">
|
||||
<value>NotificationPopup</value>
|
||||
</data>
|
||||
<data name=">>$this.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
public class Playlist
|
||||
{
|
||||
public string name { get; }
|
||||
private string basedir;
|
||||
public List<Song> songs;
|
||||
|
||||
private APIHandler api;
|
||||
public Playlist(string name, string basedir, APIHandler api)
|
||||
{
|
||||
this.songs = new List<Song>();
|
||||
this.name = name;
|
||||
this.api = api;
|
||||
this.basedir = basedir;
|
||||
this.ReadFromFile();
|
||||
}
|
||||
|
||||
public void AddSong(Song s)
|
||||
{
|
||||
this.songs.Add(s);
|
||||
}
|
||||
|
||||
public List<Song> GetSongs()
|
||||
{
|
||||
return songs;
|
||||
}
|
||||
|
||||
public void ReadFromFile()
|
||||
{
|
||||
try {
|
||||
using (StreamReader str = new StreamReader(basedir + name + ".txt"))
|
||||
{
|
||||
string readline;
|
||||
while ((readline = str.ReadLine()) != null)
|
||||
{
|
||||
string[] songsvalues = readline.Split('|');
|
||||
|
||||
songs.Add(new Song(songsvalues[0], songsvalues[1], songsvalues[2], songsvalues[3], songsvalues[4], Int32.Parse(songsvalues[5]), api));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
FileStream fs = new FileStream(basedir + name + ".txt", FileMode.CreateNew);
|
||||
fs.Close();
|
||||
ReadFromFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void WriteToFile()
|
||||
{
|
||||
using (StreamWriter stw = new StreamWriter(basedir + name + ".txt"))
|
||||
{
|
||||
this.songs.ForEach(s =>
|
||||
{
|
||||
stw.WriteLine(s.ToString());
|
||||
});
|
||||
stw.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
public class PlaylistHandler
|
||||
{
|
||||
private List<Playlist> playlists;
|
||||
private APIHandler api;
|
||||
private readonly string basedir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\.mpplaylists\\";
|
||||
public PlaylistHandler(APIHandler api)
|
||||
{
|
||||
this.playlists = new List<Playlist>();
|
||||
this.api = api;
|
||||
Populate();
|
||||
}
|
||||
|
||||
private void Populate()
|
||||
{
|
||||
try {
|
||||
Directory.GetFiles(basedir).ToList().ForEach(f =>
|
||||
{
|
||||
if (f.EndsWith(".txt"))
|
||||
{
|
||||
playlists.Add(new Playlist(Path.GetFileName(f.Replace(".txt","")) ,basedir, api));
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
Directory.CreateDirectory(basedir);
|
||||
Populate();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void MakeNewPlaylistByName(string name)
|
||||
{
|
||||
playlists.Add(new Playlist(name, basedir, api));
|
||||
}
|
||||
|
||||
public Playlist GetPlaylistByName(string name)
|
||||
{
|
||||
Playlist toFind = null;
|
||||
playlists.ForEach(p =>
|
||||
{
|
||||
if (p.name == name) { toFind = p; }
|
||||
});
|
||||
return toFind;
|
||||
}
|
||||
|
||||
public List<Playlist> GetPlaylists()
|
||||
{
|
||||
return playlists;
|
||||
}
|
||||
}
|
||||
}
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
partial class PlaylistMaker
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PlaylistMaker));
|
||||
this.PlaylistSelectBox = new System.Windows.Forms.ComboBox();
|
||||
this.PlaylistSongSelector = new System.Windows.Forms.ListBox();
|
||||
this.PlaylistAddSongsButton = new System.Windows.Forms.Button();
|
||||
this.PlaylistSongContainer = new System.Windows.Forms.ListBox();
|
||||
this.PlaylistNewButton = new System.Windows.Forms.Button();
|
||||
this.PlaylistNewInputfield = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.FilterTextBox = new System.Windows.Forms.TextBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// PlaylistSelectBox
|
||||
//
|
||||
this.PlaylistSelectBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PlaylistSelectBox.FormattingEnabled = true;
|
||||
this.PlaylistSelectBox.Location = new System.Drawing.Point(10, 96);
|
||||
this.PlaylistSelectBox.Name = "PlaylistSelectBox";
|
||||
this.PlaylistSelectBox.Size = new System.Drawing.Size(306, 21);
|
||||
this.PlaylistSelectBox.TabIndex = 0;
|
||||
this.PlaylistSelectBox.SelectedIndexChanged += new System.EventHandler(this.PlaylistSelectBox_SelectedIndexChanged);
|
||||
//
|
||||
// PlaylistSongSelector
|
||||
//
|
||||
this.PlaylistSongSelector.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PlaylistSongSelector.FormattingEnabled = true;
|
||||
this.PlaylistSongSelector.Location = new System.Drawing.Point(11, 149);
|
||||
this.PlaylistSongSelector.Name = "PlaylistSongSelector";
|
||||
this.PlaylistSongSelector.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
|
||||
this.PlaylistSongSelector.Size = new System.Drawing.Size(305, 108);
|
||||
this.PlaylistSongSelector.TabIndex = 1;
|
||||
//
|
||||
// PlaylistAddSongsButton
|
||||
//
|
||||
this.PlaylistAddSongsButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PlaylistAddSongsButton.Location = new System.Drawing.Point(10, 263);
|
||||
this.PlaylistAddSongsButton.Name = "PlaylistAddSongsButton";
|
||||
this.PlaylistAddSongsButton.Size = new System.Drawing.Size(306, 23);
|
||||
this.PlaylistAddSongsButton.TabIndex = 2;
|
||||
this.PlaylistAddSongsButton.Text = "Add selected to playlist";
|
||||
this.PlaylistAddSongsButton.UseVisualStyleBackColor = true;
|
||||
this.PlaylistAddSongsButton.Click += new System.EventHandler(this.PlaylistAddSongsButton_Click);
|
||||
//
|
||||
// PlaylistSongContainer
|
||||
//
|
||||
this.PlaylistSongContainer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PlaylistSongContainer.FormattingEnabled = true;
|
||||
this.PlaylistSongContainer.Location = new System.Drawing.Point(10, 319);
|
||||
this.PlaylistSongContainer.Name = "PlaylistSongContainer";
|
||||
this.PlaylistSongContainer.Size = new System.Drawing.Size(306, 82);
|
||||
this.PlaylistSongContainer.TabIndex = 3;
|
||||
//
|
||||
// PlaylistNewButton
|
||||
//
|
||||
this.PlaylistNewButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PlaylistNewButton.Location = new System.Drawing.Point(242, 23);
|
||||
this.PlaylistNewButton.Name = "PlaylistNewButton";
|
||||
this.PlaylistNewButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.PlaylistNewButton.TabIndex = 4;
|
||||
this.PlaylistNewButton.Text = "New";
|
||||
this.PlaylistNewButton.UseVisualStyleBackColor = true;
|
||||
this.PlaylistNewButton.Click += new System.EventHandler(this.PlaylistNewButton_Click);
|
||||
//
|
||||
// PlaylistNewInputfield
|
||||
//
|
||||
this.PlaylistNewInputfield.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PlaylistNewInputfield.Location = new System.Drawing.Point(11, 25);
|
||||
this.PlaylistNewInputfield.Name = "PlaylistNewInputfield";
|
||||
this.PlaylistNewInputfield.Size = new System.Drawing.Size(225, 20);
|
||||
this.PlaylistNewInputfield.TabIndex = 5;
|
||||
this.PlaylistNewInputfield.KeyUp += new System.Windows.Forms.KeyEventHandler(this.PlaylistNewInputfield_KeyUp);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(95, 13);
|
||||
this.label1.TabIndex = 6;
|
||||
this.label1.Text = "Create new playlist";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(10, 80);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(97, 13);
|
||||
this.label2.TabIndex = 7;
|
||||
this.label2.Text = "Edit existing playlist";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(7, 303);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(82, 13);
|
||||
this.label3.TabIndex = 8;
|
||||
this.label3.Text = "Songs in playlist";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(11, 130);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(49, 13);
|
||||
this.label4.TabIndex = 9;
|
||||
this.label4.Text = "All songs";
|
||||
//
|
||||
// FilterTextBox
|
||||
//
|
||||
this.FilterTextBox.Location = new System.Drawing.Point(172, 127);
|
||||
this.FilterTextBox.Name = "FilterTextBox";
|
||||
this.FilterTextBox.Size = new System.Drawing.Size(144, 20);
|
||||
this.FilterTextBox.TabIndex = 10;
|
||||
this.FilterTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.FilterTextBox_KeyUp);
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(137, 130);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(29, 13);
|
||||
this.label5.TabIndex = 11;
|
||||
this.label5.Text = "Filter";
|
||||
//
|
||||
// PlaylistMaker
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(334, 411);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.FilterTextBox);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.PlaylistNewInputfield);
|
||||
this.Controls.Add(this.PlaylistNewButton);
|
||||
this.Controls.Add(this.PlaylistSongContainer);
|
||||
this.Controls.Add(this.PlaylistAddSongsButton);
|
||||
this.Controls.Add(this.PlaylistSongSelector);
|
||||
this.Controls.Add(this.PlaylistSelectBox);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MinimumSize = new System.Drawing.Size(300, 425);
|
||||
this.Name = "PlaylistMaker";
|
||||
this.Text = "Create / Edit playlists";
|
||||
this.Shown += new System.EventHandler(this.PlaylistMaker_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ComboBox PlaylistSelectBox;
|
||||
private System.Windows.Forms.ListBox PlaylistSongSelector;
|
||||
private System.Windows.Forms.Button PlaylistAddSongsButton;
|
||||
private System.Windows.Forms.ListBox PlaylistSongContainer;
|
||||
private Button PlaylistNewButton;
|
||||
private TextBox PlaylistNewInputfield;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private TextBox FilterTextBox;
|
||||
private Label label5;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
public partial class PlaylistMaker : Form
|
||||
{
|
||||
private PlaylistHandler pl;
|
||||
private APIHandler api;
|
||||
|
||||
private List<Song> allPlaylistSongs;
|
||||
private List<Song> allsongs;
|
||||
|
||||
public PlaylistMaker(PlaylistHandler pl, APIHandler api)
|
||||
{
|
||||
this.pl = pl;
|
||||
this.api = api;
|
||||
this.allPlaylistSongs = new List<Song>();
|
||||
this.allsongs = new List<Song>();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void PlaylistSelectBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (PlaylistSelectBox.SelectedItem != null)
|
||||
{
|
||||
PlaylistSongContainer.Items.Clear();
|
||||
allPlaylistSongs = pl.GetPlaylistByName(PlaylistSelectBox.SelectedItem.ToString()).GetSongs();
|
||||
allPlaylistSongs.ForEach(s => PlaylistSongContainer.Items.Add(s.Name));
|
||||
}
|
||||
}
|
||||
|
||||
public void Repopulate(bool lastIndex)
|
||||
{
|
||||
int selection = PlaylistSelectBox.SelectedIndex;
|
||||
PlaylistSelectBox.Items.Clear();
|
||||
pl.GetPlaylists().ForEach(p => PlaylistSelectBox.Items.Add(p.name));
|
||||
if (lastIndex)
|
||||
PlaylistSelectBox.SelectedIndex = PlaylistSelectBox.Items.Count - 1;
|
||||
else
|
||||
PlaylistSelectBox.SelectedIndex = selection;
|
||||
if (PlaylistSelectBox.SelectedItem != null)
|
||||
{
|
||||
PlaylistSongContainer.Items.Clear();
|
||||
allPlaylistSongs = pl.GetPlaylistByName(PlaylistSelectBox.SelectedItem.ToString()).GetSongs();
|
||||
allPlaylistSongs.ForEach(s => PlaylistSongContainer.Items.Add(s.Name));
|
||||
}
|
||||
}
|
||||
|
||||
public void Repopulate()
|
||||
{
|
||||
Repopulate(false);
|
||||
}
|
||||
|
||||
public void Populate()
|
||||
{
|
||||
pl.GetPlaylists().ForEach(p => PlaylistSelectBox.Items.Add(p.name));
|
||||
if (PlaylistSelectBox.Items.Count > 0)
|
||||
PlaylistSelectBox.SelectedIndex = 0;
|
||||
allsongs = api.GetAllSongs();
|
||||
allsongs.ForEach(s => PlaylistSongSelector.Items.Add(s.Name));
|
||||
|
||||
if (PlaylistSelectBox.SelectedItem != null)
|
||||
{
|
||||
allPlaylistSongs = pl.GetPlaylistByName(PlaylistSelectBox.SelectedItem.ToString()).GetSongs();
|
||||
allPlaylistSongs.ForEach(s => PlaylistSongContainer.Items.Add(s.Name));
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaylistAddSongsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (PlaylistSelectBox.SelectedItem!=null)
|
||||
{
|
||||
Playlist currentPlaylist = pl.GetPlaylistByName(PlaylistSelectBox.SelectedItem.ToString());
|
||||
foreach (string song in PlaylistSongSelector.SelectedItems)
|
||||
{
|
||||
foreach (Song s in allsongs) {
|
||||
if (s.Name == song)
|
||||
{
|
||||
currentPlaylist.AddSong(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
currentPlaylist.WriteToFile();
|
||||
}
|
||||
Thread.Sleep(10);
|
||||
Repopulate();
|
||||
}
|
||||
|
||||
public void SearchAllSongs(string search)
|
||||
{
|
||||
PlaylistSongSelector.Items.Clear();
|
||||
|
||||
if (search.Length > 1)
|
||||
{
|
||||
string sPattern = search;
|
||||
|
||||
foreach (Song s in allsongs)
|
||||
{
|
||||
if (System.Text.RegularExpressions.Regex.IsMatch(s.Name, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
|
||||
{
|
||||
PlaylistSongSelector.Items.Add(s.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
allsongs.ForEach(s => PlaylistSongSelector.Items.Add(s.Name));
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaylistNewButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
string name = PlaylistNewInputfield.Text;
|
||||
PlaylistNewInputfield.Text = "";
|
||||
name = name.Replace('/', '-');
|
||||
name = name.Replace('\\', '-');
|
||||
pl.MakeNewPlaylistByName(name);
|
||||
Repopulate(true);
|
||||
}
|
||||
|
||||
private void PlaylistMaker_Load(object sender, EventArgs e)
|
||||
{
|
||||
Populate();
|
||||
}
|
||||
|
||||
private void FilterTextBox_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
SearchAllSongs(FilterTextBox.Text);
|
||||
}
|
||||
|
||||
private void PlaylistNewInputfield_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if(e.KeyCode == Keys.Enter)
|
||||
{
|
||||
PlaylistNewButton_Click(sender, new EventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,26 +17,12 @@ namespace MusicPlayer
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
NetworkHandler nw = new NetworkHandler("http://www.imegumii.nl");
|
||||
NetworkHandler nw = new NetworkHandler("http://jancokock.me");
|
||||
//NetworkHandler nw = new NetworkHandler("http://imegumii.nl");
|
||||
APIHandler api = new APIHandler(nw);
|
||||
// api.GetSongsByArtist("Amon Amarth").ForEach(s =>
|
||||
// {
|
||||
// Console.WriteLine(s.SongID);
|
||||
// });
|
||||
// api.GetSongsByYear("2009").ForEach(s =>
|
||||
// {
|
||||
// Console.WriteLine(s.Name);
|
||||
// });
|
||||
api.GetSongsByGenre("Melodic Death Metal").ForEach(s =>
|
||||
{
|
||||
Console.WriteLine(s.Name);
|
||||
});
|
||||
// api.GetSongsByAlbum("Stronger").ForEach(s =>
|
||||
// {
|
||||
// Console.WriteLine(s.Name);
|
||||
// });
|
||||
MainForm form = new MainForm();
|
||||
new Main(nw, api, form);
|
||||
PlaylistHandler pl = new PlaylistHandler(api);
|
||||
new Main(nw, api, form,pl);
|
||||
|
||||
Application.Run(form);
|
||||
}
|
||||
|
||||
Regular → Executable
+17
-25
@@ -8,10 +8,10 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace MusicPlayer.Properties
|
||||
{
|
||||
|
||||
|
||||
namespace MusicPlayer.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
@@ -22,48 +22,40 @@ namespace MusicPlayer.Properties
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MusicPlayer.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
@@ -60,6 +60,7 @@
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
@@ -68,9 +69,10 @@
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
@@ -85,9 +87,10 @@
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
@@ -109,9 +112,9 @@
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Regular → Executable
Regular → Executable
+10
-1
@@ -12,18 +12,22 @@ namespace MusicPlayer
|
||||
public string Name { get; set; }
|
||||
public string Album { get; set; }
|
||||
public string Artist { get; set; }
|
||||
public string Genre { get; set; }
|
||||
public string Url { get { return GetURL(); } set { SetURL(value); } }
|
||||
public int Seconds { get; set; }
|
||||
|
||||
private APIHandler api;
|
||||
|
||||
private string url;
|
||||
|
||||
public Song(string songid, string name, string album, string artist, APIHandler api)
|
||||
public Song(string songid, string name, string album, string artist, string genre, int seconds, APIHandler api)
|
||||
{
|
||||
SongID = songid;
|
||||
Name = name;
|
||||
Album = album;
|
||||
Artist = artist;
|
||||
Seconds = seconds;
|
||||
Genre = genre;
|
||||
|
||||
this.api = api;
|
||||
|
||||
@@ -44,5 +48,10 @@ namespace MusicPlayer
|
||||
{
|
||||
url = str;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.SongID}|{this.Name}|{this.Album}|{this.Artist}|{this.Genre}|{this.Seconds}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Regular → Executable
+5
-2
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
class SongsTable : DataTable
|
||||
public class SongsTable : DataTable
|
||||
{
|
||||
public SongsTable() : base()
|
||||
{
|
||||
@@ -15,11 +15,14 @@ namespace MusicPlayer
|
||||
this.Columns.Add("Naam", typeof(string));
|
||||
this.Columns.Add("Album", typeof(string));
|
||||
this.Columns.Add("Artiest", typeof(string));
|
||||
this.Columns.Add("Genre", typeof(string));
|
||||
this.Columns.Add("Duration", typeof(string));
|
||||
this.Columns.Add("song", typeof(Song));
|
||||
}
|
||||
|
||||
public void Add(Song s)
|
||||
{
|
||||
this.Rows.Add(s.Name, s.Album, s.Artist);
|
||||
this.Rows.Add(s.Name, s.Album, s.Artist, s.Genre, Main.SecondsToTimestamp(s.Seconds), s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Regular → Executable
Regular → Executable
+1
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AntiXSS" version="4.3.0" targetFramework="net452" />
|
||||
<package id="NAudio" version="1.7.3" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
|
||||
</packages>
|
||||
@@ -1,12 +1,10 @@
|
||||
# musicplayer
|
||||
|
||||
##Onderdelen
|
||||
- Server/Client
|
||||
- Threading/Threadpools
|
||||
- File IO
|
||||
- Socket communicatie
|
||||
- Klasse Structuur
|
||||
- Forms Applicatie
|
||||
- Specifieke C# - Delegates/Lambda...
|
||||
|
||||
|
||||
## todo
|
||||
- afvangen server niet online
|
||||
- server opslaan bij playlist
|
||||
- doorzoeken van alle liedjes via API
|
||||
- doorzoeken van albums
|
||||
- playlist verwijderen
|
||||
- liedjes uit playlist verwijderen
|
||||
- presentatie
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
[HTTP]
|
||||
port = 8585
|
||||
|
||||
[Daemon]
|
||||
port = 17170
|
||||
|
||||
[Library]
|
||||
musicdir = /media/USBHDD/shares/Music/English
|
||||
jancodir = /mnt/Muziek/
|
||||
|
||||
[Database]
|
||||
username = yjmpd
|
||||
password = qLjStxr6xncrfcna
|
||||
host = imegumii.nl
|
||||
database = yjmpd
|
||||
port = 3306
|
||||
@@ -0,0 +1,3 @@
|
||||
configparser
|
||||
mutagen
|
||||
PyMySQL
|
||||
@@ -0,0 +1,72 @@
|
||||
import sys
|
||||
import os
|
||||
import configparser
|
||||
|
||||
from yjdaemon.yjmpd import YJMPD
|
||||
from yjdaemon.HTTPServer import HTTPServerThread
|
||||
from yjdaemon.Database import Database
|
||||
from yjdaemon.libraryscanner import LibraryScanner
|
||||
|
||||
debug = True
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
try:
|
||||
config.read("config.cfg")
|
||||
HTTP_PORT = int(config.get("HTTP", "port"))
|
||||
DAEMON_PORT = int(config.get("Daemon","port"))
|
||||
MUSIC_DIR = str(config.get("Library", "musicdir"))
|
||||
DB_USERNAME = config.get("Database", "username")
|
||||
DB_PASSWORD = config.get("Database", "password")
|
||||
DB_HOST = config.get("Database", "host")
|
||||
DB_DATABASE = config.get("Database", "database")
|
||||
DB_PORT = config.getint("Database", "port")
|
||||
except Exception as e:
|
||||
print(e.with_traceback())
|
||||
sys.exit(1)
|
||||
|
||||
class MainDaemon(YJMPD):
|
||||
def run(self):
|
||||
HTTP_thread = HTTPServerThread(HTTP_PORT)
|
||||
HTTP_thread.start()
|
||||
|
||||
|
||||
def Test():
|
||||
print("Test")
|
||||
|
||||
# socket_thread = ServiceSocket(DAEMON_PORT)
|
||||
# socket_thread.start()
|
||||
#HTTP_thread = HTTPServerThread(HTTP_PORT)
|
||||
#HTTP_thread.start()
|
||||
db = Database(DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE)
|
||||
LibraryScanner(db, MUSIC_DIR)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if debug:
|
||||
Test()
|
||||
else:
|
||||
if __name__ == "__main__":
|
||||
username = os.getenv('USER')
|
||||
if None == username:
|
||||
dir = "/tmp/.pydaemon.pid"
|
||||
else:
|
||||
dir = "/home/" + username + "/.pydaemon.pid"
|
||||
daemon = MainDaemon(dir, MUSIC_DIR)
|
||||
if len(sys.argv) == 2:
|
||||
if 'start' == sys.argv[1]:
|
||||
daemon.start()
|
||||
elif 'stop' == sys.argv[1]:
|
||||
daemon.stop()
|
||||
elif 'restart' == sys.argv[1]:
|
||||
daemon.restart()
|
||||
elif 'status' == sys.argv[1]:
|
||||
daemon.status()
|
||||
else:
|
||||
print("Unknown command")
|
||||
sys.exit(2)
|
||||
sys.exit(0)
|
||||
else:
|
||||
print("usage: %s start|stop|status|restart" % sys.argv[0])
|
||||
sys.exit(2)
|
||||
@@ -0,0 +1,72 @@
|
||||
import sys
|
||||
import os
|
||||
import configparser
|
||||
|
||||
from yjdaemon.yjmpd import YJMPD
|
||||
from yjdaemon.HTTPServer import HTTPServerThread
|
||||
from yjdaemon.Database import Database
|
||||
from yjdaemon.libraryscanner import LibraryScanner
|
||||
|
||||
debug = True
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
try:
|
||||
config.read("config.cfg")
|
||||
HTTP_PORT = int(config.get("HTTP", "port"))
|
||||
DAEMON_PORT = int(config.get("Daemon","port"))
|
||||
MUSIC_DIR = str(config.get("Library", "musicdir"))
|
||||
DB_USERNAME = config.get("Database", "username")
|
||||
DB_PASSWORD = config.get("Database", "password")
|
||||
DB_HOST = config.get("Database", "host")
|
||||
DB_DATABASE = config.get("Database", "database")
|
||||
DB_PORT = config.getint("Database", "port")
|
||||
except Exception as e:
|
||||
print(e.with_traceback())
|
||||
sys.exit(1)
|
||||
|
||||
class MainDaemon(YJMPD):
|
||||
def run(self):
|
||||
HTTP_thread = HTTPServerThread(HTTP_PORT)
|
||||
HTTP_thread.start()
|
||||
|
||||
|
||||
def Test():
|
||||
print("Test")
|
||||
|
||||
# socket_thread = ServiceSocket(DAEMON_PORT)
|
||||
# socket_thread.start()
|
||||
HTTP_thread = HTTPServerThread(HTTP_PORT)
|
||||
HTTP_thread.start()
|
||||
#db = Database(DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE)
|
||||
#LibraryScanner(db, MUSIC_DIR)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if debug:
|
||||
Test()
|
||||
else:
|
||||
if __name__ == "__main__":
|
||||
username = os.getenv('USER')
|
||||
if None == username:
|
||||
dir = "/tmp/.pydaemon.pid"
|
||||
else:
|
||||
dir = "/home/" + username + "/.pydaemon.pid"
|
||||
daemon = MainDaemon(dir, MUSIC_DIR)
|
||||
if len(sys.argv) == 2:
|
||||
if 'start' == sys.argv[1]:
|
||||
daemon.start()
|
||||
elif 'stop' == sys.argv[1]:
|
||||
daemon.stop()
|
||||
elif 'restart' == sys.argv[1]:
|
||||
daemon.restart()
|
||||
elif 'status' == sys.argv[1]:
|
||||
daemon.status()
|
||||
else:
|
||||
print("Unknown command")
|
||||
sys.exit(2)
|
||||
sys.exit(0)
|
||||
else:
|
||||
print("usage: %s start|stop|status|restart" % sys.argv[0])
|
||||
sys.exit(2)
|
||||
@@ -0,0 +1,169 @@
|
||||
import json
|
||||
|
||||
from yjdaemon.Database import Database as db
|
||||
import configparser
|
||||
import string
|
||||
"""
|
||||
Add a key to the validAPIcalls dictionary, with a corresponding function
|
||||
Function should return jsonified data, so that it can then be passed on to the client.
|
||||
example:
|
||||
|
||||
Add this to the dictionary
|
||||
"getsongs": calls.getsongs
|
||||
|
||||
then implement this function
|
||||
@staticmethod
|
||||
def getsongs():
|
||||
return calls.jsonify({"song": song})
|
||||
|
||||
And the jsonified data will be returned to the client.
|
||||
|
||||
Every function MUST return jsonified data!
|
||||
|
||||
"""
|
||||
|
||||
|
||||
class calls:
|
||||
@staticmethod
|
||||
def APIcall(sanitizedpath):
|
||||
if sanitizedpath in validAPIcalls:
|
||||
return validAPIcalls[sanitizedpath]
|
||||
else:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def getfromrawjson(data, param):
|
||||
return calls.dejsonify(data)[param]
|
||||
|
||||
@staticmethod
|
||||
def jsonify(data):
|
||||
return json.dumps(data, sort_keys=True, indent=4).encode("utf-8")
|
||||
|
||||
@staticmethod
|
||||
def dejsonify(rawdata):
|
||||
return json.loads(rawdata.decode("utf-8"))
|
||||
|
||||
@staticmethod
|
||||
def getallsongs(args):
|
||||
return calls.jsonify({"songs": db.executequerystatic("SELECT * FROM tracks;"), "args": args , "result": "OK"})
|
||||
|
||||
@staticmethod
|
||||
def getartists(args):
|
||||
return calls.jsonify({"artists": db.executequerystatic("SELECT artistName FROM tracks GROUP BY artistName;"), "args": args, "result" : "OK"})
|
||||
|
||||
@staticmethod
|
||||
def getalbums(args):
|
||||
return calls.jsonify({"albums": db.executequerystatic("SELECT albumName FROM tracks GROUP BY albumName;"), "args": args, "result":"OK"})
|
||||
|
||||
@staticmethod
|
||||
def getgenres(args):
|
||||
return calls.jsonify({"genres": db.executequerystatic("SELECT genre FROM tracks GROUP BY genre;"), "args": args, "result":"OK"})
|
||||
|
||||
@staticmethod
|
||||
def getyears(args):
|
||||
return calls.jsonify({"years": db.executequerystatic("SELECT year FROM tracks GROUP BY year;"), "args": args, "result":"OK"})
|
||||
|
||||
@staticmethod
|
||||
def getalbumnames(args):
|
||||
return calls.jsonify({"albumnames": db.executequerystatic("SELECT albumName FROM tracks GROUP BY albumName;"), "args": args})
|
||||
|
||||
@staticmethod
|
||||
def search(args):
|
||||
data = args.split("&")
|
||||
genquery="""
|
||||
SELECT $ident FROM tracks WHERE LCASE(trackName) LIKE LCASE(\"%$trackname%\") $orgenre LCASE(genre) LIKE LCASE(\"%$genre%\") $oralbum LCASE(albumName) LIKE LCASE(\"%$album%\") $orartist LCASE(artistName) LIKE LCASE(\"%$artistname%\") $end;
|
||||
"""
|
||||
query="""
|
||||
SELECT $ident FROM tracks WHERE ($or1 OR $or2 OR $or3 ) $and1 $and2 $and3 $end;
|
||||
"""
|
||||
test = string.Template(query)
|
||||
genqueryres = ""
|
||||
arguments = []
|
||||
general = ""
|
||||
for entry in data:
|
||||
values = entry.split("=")
|
||||
values[1] = values[1].replace("%20"," ")
|
||||
if values[0] == "q":
|
||||
general = values[1]
|
||||
continue
|
||||
if values[1]:
|
||||
arguments.append(values)
|
||||
print(arguments)
|
||||
finalstring = "" + genquery
|
||||
for arg in arguments:
|
||||
if arg[0] == "artist":
|
||||
finalstring = string.Template(finalstring).safe_substitute(artistname=arg[1], orartist="AND")
|
||||
test = string.Template(test.safe_substitute(and1="AND LCASE(artistName) LIKE LCASE(\"%"+ arg[1] +"%\")"))
|
||||
elif arg[0] == "genre":
|
||||
finalstring = string.Template(finalstring).safe_substitute(genre=arg[1],orgenre="AND")
|
||||
test = string.Template(test.safe_substitute(and2="AND LCASE(genre) LIKE LCASE(\"%"+ arg[1] +"%\")"))
|
||||
elif arg[0] == "album":
|
||||
finalstring = string.Template(finalstring).safe_substitute(album=arg[1],oralbum="AND")
|
||||
test = string.Template(test.safe_substitute(and3="AND LCASE(albumName) LIKE LCASE(\"%"+ arg[1] +"%\")"))
|
||||
print(finalstring)
|
||||
finalstring = string.Template(finalstring).safe_substitute(genre=general,artistname=general,album=general,trackname=general)
|
||||
print(finalstring)
|
||||
test = test.safe_substitute( and1="", and2="",and3="",or1="LCASE(artistName) LIKE LCASE(\"%"+general+"%\")",or2="LCASE(genre) LIKE LCASE(\"%"+general+"%\")",or3="LCASE(albumName) LIKE LCASE(\"%"+general+"%\")")
|
||||
print(test)
|
||||
print(string.Template(test).safe_substitute(ident="*",end=""))
|
||||
return calls.jsonify({"result":"OK", "genres": db.executequerystatic(string.Template(test).safe_substitute(ident="genre",end="GROUP BY genre")),"artists": db.executequerystatic(string.Template(test).safe_substitute(ident="artistName",end="GROUP BY artistName")), "albums": db.executequerystatic(string.Template(test).safe_substitute(ident="albumName",end="GROUP BY albumName")), "songs" : db.executequerystatic(string.Template(test).safe_substitute(ident="*",end=""))})
|
||||
|
||||
@staticmethod
|
||||
def getsongs(args):
|
||||
"""Get song by album, genre, year, artist"""
|
||||
data = args.partition("?")
|
||||
splitstring = data[0].partition("=")
|
||||
name= splitstring[0]
|
||||
value = splitstring[2].replace("%20"," ")
|
||||
if name == "album":
|
||||
songs = db.executequerystatic("SELECT * FROM tracks WHERE albumName = \"" + value + "\"")
|
||||
elif name == "genre":
|
||||
songs = db.executequerystatic("SELECT * FROM tracks WHERE genre = \"" + value + "\"")
|
||||
elif name == "year":
|
||||
songs = db.executequerystatic("SELECT * FROM tracks WHERE year = \"" + value + "\"")
|
||||
elif name == "artist":
|
||||
songs = db.executequerystatic("SELECT * FROM tracks WHERE artistName = \"" + value + "\"")
|
||||
elif name == "search":
|
||||
songs = db.executequerystatic("SELECT * FROM tracks WHERE LCASE(trackName) LIKE LCASE(\"%"+ value + "%\") GROUP BY trackName")
|
||||
else:
|
||||
return calls.jsonify({"result":"NOK", "errormsg": "Not a valid argument"})
|
||||
return calls.jsonify({"result":"OK","songs":songs})
|
||||
|
||||
@staticmethod
|
||||
def getsongbyid(args):
|
||||
config = configparser.ConfigParser()
|
||||
try:
|
||||
config.read("config.cfg")
|
||||
musicdir = config.get("Library","musicdir")
|
||||
port = config.get("HTTP","port")
|
||||
except:
|
||||
return calls.jsonify({"result" : "NOK" , "errormsg" : "I/O error while reading config."})
|
||||
data = args.split("&")
|
||||
splitsting = data[0].split("=")
|
||||
id = splitsting[1]
|
||||
file = db.executequerystatic(
|
||||
"SELECT SUBSTRING_INDEX(trackUrl,'" + musicdir + "',-1) as filedir FROM `tracks` WHERE id = " + id)
|
||||
try:
|
||||
url = str(file[0][0])
|
||||
except:
|
||||
return calls.jsonify({"result": "NOK", "errormsg" : "Song ID does not exist in database."})
|
||||
return calls.jsonify({"result": "OK", "songurl": "http://imegumii.nl:"+ "/music/English"+ url})
|
||||
|
||||
@staticmethod
|
||||
def setsong(args, songname):
|
||||
global song
|
||||
song = songname
|
||||
return calls.jsonify({"result": "OK", "args": args})
|
||||
|
||||
|
||||
validAPIcalls = {"getallsongs": calls.getallsongs,
|
||||
"setsong": calls.setsong,
|
||||
"search": calls.search,
|
||||
"getsongs": calls.getsongs,
|
||||
"getsongbyid": calls.getsongbyid,
|
||||
"getartists": calls.getartists,
|
||||
"getalbums": calls.getalbums,
|
||||
"getgenres": calls.getgenres,
|
||||
"getyears": calls.getyears,
|
||||
"getalbumnames": calls.getalbumnames
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import pymysql
|
||||
import configparser
|
||||
from threading import RLock as Lock
|
||||
from warnings import filterwarnings
|
||||
|
||||
filterwarnings('ignore', category = pymysql.Warning)
|
||||
class Database:
|
||||
|
||||
buffer = []
|
||||
cout = 0
|
||||
lock = Lock()
|
||||
def __init__(self, DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE):
|
||||
"""Init class """
|
||||
self.cnx = pymysql.connect(user=DB_USERNAME, password=DB_PASSWORD, host=DB_HOST, database=DB_DATABASE, port=DB_PORT, charset='utf8')
|
||||
self.cursor = self.cnx.cursor()
|
||||
|
||||
def executeQuery(self, query):
|
||||
try:
|
||||
self.cursor.execute(query)
|
||||
self.cnx.commit()
|
||||
return self.cursor.fetchall()
|
||||
except pymysql.ProgrammingError as e:
|
||||
print(e)
|
||||
print(query)
|
||||
|
||||
@staticmethod
|
||||
def executequerystatic(query):
|
||||
config = configparser.ConfigParser()
|
||||
try:
|
||||
config.read("config.cfg")
|
||||
DB_USERNAME = config.get("Database", "username")
|
||||
DB_PASSWORD = config.get("Database", "password")
|
||||
DB_HOST = config.get("Database", "host")
|
||||
DB_DATABASE = config.get("Database", "database")
|
||||
DB_PORT = config.getint("Database", "port")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
cnx = pymysql.connect(user=DB_USERNAME, password=DB_PASSWORD, host=DB_HOST, database=DB_DATABASE, port=DB_PORT)
|
||||
cursor = cnx.cursor()
|
||||
if query != "":
|
||||
cursor.execute(query)
|
||||
cnx.commit()
|
||||
return cursor.fetchall()
|
||||
else:
|
||||
return []
|
||||
|
||||
|
||||
def turnoffautocommit(self):
|
||||
self.cursor.execute("SET autocommit=0;")
|
||||
self.cnx.commit()
|
||||
|
||||
def removeSong(self, path):
|
||||
self.db.executeQuery("DELETE FROM `tracks` WHERE trackUrl = " + path.replace("'", '\\\''))
|
||||
|
||||
def updateInsertSong(self, genre, trackname, artistname, albumname, albumartist, tracknumber, year, duration, path): #notworking
|
||||
self.db.executeQuery("INSERT INTO `tracks` (`genre`, `trackUrl`, `trackName`, `artistName`, `albumName`, `albumArtist`, `trackNumber`, `year`, `duration`) VALUES ('" + genre + b"','" + path.replace("'", '\\\'') + "','" + trackname + "','" + artistname + "','" + albumname + "','" + albumartist + "','" + tracknumber + "','" + year + "','0') " +
|
||||
b" ON DUPLICATE KEY UPDATE `genre`=VALUES(`genre`) , `trackName` = VALUES(`trackName`) , `artistName` = VALUES(`artistName`) ,`albumName` = VALUES(`albumName`) , `albumArtist` = VALUES(`albumArtist`) , `trackNumber` = VALUES(`trackNumber`) , `year` = VALUES(`year`) , `duration` = VALUES(`duration`)")
|
||||
|
||||
def insertMultipleSongs(self, genre, trackname, artistname, albumname, albumartist, tracknumber, year, duration, path):
|
||||
self.buffer.append([genre, trackname, artistname, albumname, albumartist, tracknumber, year, duration, path])
|
||||
# Database.lock.acquire()
|
||||
if len(self.buffer) > 50:
|
||||
self.pushbuffer()
|
||||
# Database.lock.release()
|
||||
|
||||
def pushbuffer(self):
|
||||
query = ('INSERT INTO `tracks` (`genre`, `trackUrl`, `trackName`, `artistName`, `albumName`, `albumArtist`, `trackNumber`, `year`, `duration`) VALUES ')
|
||||
for song in self.buffer:
|
||||
query += "("
|
||||
for field in song:
|
||||
query += "'" + field + "',"
|
||||
query = query[:-1]
|
||||
query += "),"
|
||||
query = query[:-1]
|
||||
query += " ON DUPLICATE KEY UPDATE `genre`=VALUES(`genre`) , `trackName` = VALUES(`trackName`) , `artistName` = VALUES(`artistName`) ,`albumName` = VALUES(`albumName`) , `albumArtist` = VALUES(`albumArtist`) , `trackNumber` = VALUES(`trackNumber`) , `year` = VALUES(`year`) , `duration` = VALUES(`duration`);"
|
||||
self.executeQuery(query)
|
||||
del self.buffer[:]
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
import http.server
|
||||
import socketserver
|
||||
import threading
|
||||
import html
|
||||
|
||||
import yjdaemon.API as API
|
||||
|
||||
"""
|
||||
HTTP request handler.
|
||||
"""
|
||||
|
||||
|
||||
class HTTPServerThread(threading.Thread):
|
||||
def __init__(self, PORT):
|
||||
threading.Thread.__init__(self)
|
||||
self.PORT = PORT
|
||||
|
||||
def run(self):
|
||||
Handler = HTTPHandler
|
||||
socketserver.TCPServer.allow_reuse_address = True
|
||||
httpd = socketserver.TCPServer(("", self.PORT), Handler)
|
||||
httpd.serve_forever()
|
||||
|
||||
|
||||
"""
|
||||
REST API
|
||||
"""
|
||||
|
||||
|
||||
class HTTPHandler(http.server.SimpleHTTPRequestHandler):
|
||||
def send_message(self, status, content_type, data):
|
||||
self.send_response(status)
|
||||
self.send_header("Content-type:", content_type)
|
||||
self.end_headers()
|
||||
self.wfile.write(data)
|
||||
self.wfile.write("\n".encode("utf-8"))
|
||||
|
||||
def do_GET(self):
|
||||
""" Serve a GET request. """
|
||||
path = html.unescape(self.path)
|
||||
path = str(path).lstrip("/").split("?")[0]
|
||||
retval = API.calls.APIcall(path)
|
||||
if retval is not None: # if call is valid API function
|
||||
try:
|
||||
args = str(html.unescape(self.path)).lstrip("/").split("?")[1]
|
||||
except IndexError as e:
|
||||
print(e)
|
||||
self.send_message(403, "application/json", API.calls.jsonify({"error": "Missing parameters."}))
|
||||
return
|
||||
self.send_message(200, "application/json", retval(args))
|
||||
else: # else parse as normal HTTP request
|
||||
f = self.send_head()
|
||||
if f:
|
||||
try:
|
||||
self.copyfile(f, self.wfile)
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
def do_POST(self):
|
||||
""" Serve a POST request. """
|
||||
path = html.unescape(self.path)
|
||||
path = str(path).lstrip("/").split("?")[0]
|
||||
retval = API.calls.APIcall(path)
|
||||
if retval is not None: # if call is valid API function
|
||||
try:
|
||||
args = str(html.unescape(self.path)).lstrip("/").split("?")[1] #if no args
|
||||
except IndexError as e:
|
||||
print(e)
|
||||
self.send_message(403, "application/json", API.calls.jsonify({"error": "Missing parameters."}))
|
||||
return
|
||||
if self.headers["Content-Type"] == 'application/json': # if data is json data
|
||||
length = int(self.headers["Content-Length"])
|
||||
rawdata = self.rfile.read(length)
|
||||
result = retval(args, API.calls.getfromrawjson(rawdata, "data"))
|
||||
self.send_message(200, "application/json", result)
|
||||
else: # if not json data
|
||||
self.send_message(422, "application/json", API.calls.jsonify({"error": "Not JSON data."}))
|
||||
else: # if not API function
|
||||
self.send_message(403, "application/json", API.calls.jsonify({"error": "Not an API function"}))
|
||||
@@ -0,0 +1,36 @@
|
||||
import socket
|
||||
import threading
|
||||
|
||||
endline = "\r\n"
|
||||
|
||||
class ServiceSocket(threading.Thread):
|
||||
def __init__(self, PORT):
|
||||
threading.Thread.__init__(self)
|
||||
self.PORT = PORT
|
||||
|
||||
def run(self):
|
||||
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
self.s.bind(("", self.PORT))
|
||||
self.s.listen(1)
|
||||
while 1:
|
||||
conn, addr = self.s.accept()
|
||||
ClientHandler(conn).start()
|
||||
|
||||
|
||||
|
||||
class ClientHandler(threading.Thread):
|
||||
def __init__(self,conn):
|
||||
threading.Thread.__init__(self)
|
||||
self.conn = conn
|
||||
def run(self):
|
||||
while 1:
|
||||
data = self.conn.recv(1024)
|
||||
if not data:
|
||||
break
|
||||
else:
|
||||
datastring = data.decode('utf-8', "ignore").rstrip(endline).lower()
|
||||
print(datastring)
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable
+78
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
from mutagen.easyid3 import EasyID3
|
||||
from mutagen.mp3 import MP3
|
||||
import mutagen._util
|
||||
import os
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
|
||||
class LibraryScanner:
|
||||
|
||||
def __init__(self, Database, librarypath):
|
||||
"""Init class """
|
||||
self.url = librarypath
|
||||
self.db = Database
|
||||
self.scanRecursif()
|
||||
ob = Observer()
|
||||
ob.schedule(Filehandler(self), self.url, recursive=True)
|
||||
ob.start()
|
||||
|
||||
|
||||
def scanRecursif(self):
|
||||
print("Scanning library "+self.url+" recursively...")
|
||||
# musicdirs = [os.path.join(self.url,o) for o in os.listdir(self.url) if os.path.isdir(os.path.join(self.url,o))]
|
||||
self.db.turnoffautocommit()
|
||||
for root, directories, filenames in os.walk(self.url):
|
||||
self.scandir(filenames,root)
|
||||
|
||||
def scandir(self,filenames, root):
|
||||
for filename in filenames:
|
||||
if filename.lower().endswith(('.mp3')):
|
||||
path = os.path.join(root,filename)
|
||||
try:
|
||||
print(path, end='\r')
|
||||
id3 = EasyID3(path)
|
||||
audio = MP3(path)
|
||||
print(audio.info.length)
|
||||
self.db.insertMultipleSongs(self.getValue(id3, "genre"),path.replace("'", '\\\''),self.getValue(id3, "title"),self.getValue(id3, "artist"),self.getValue(id3, "album"),self.getValue(id3, "performer"),self.getValue(id3, "tracknumber"),self.getValue(id3, "date"),str(audio.info.length))
|
||||
except (mutagen.id3._util.ID3NoHeaderError):
|
||||
print("Error reading ID3 tag", end='\r')
|
||||
|
||||
|
||||
def insertSong(self, path):
|
||||
try:
|
||||
id3 = EasyID3(path)
|
||||
self.db.executeQuery(b"INSERT INTO `tracks` (`genre`, `trackUrl`, `trackName`, `artistName`, `albumName`, `albumArtist`, `trackNumber`, `year`, `duration`) VALUES ('" + self.getValue(id3,"genre") + b"'," + b"'" + path.replace("'", '\\\'').encode('utf8') + b"'," + b"'" + self.getValue(id3, "title") + b"'," + b"'" + self.getValue(id3, "artist") + b"'," + b"'" + self.getValue(id3, "album") + b"'," + b"'" + self.getValue(id3, "performer") + b"'," + b"'" + self.getValue(id3, "tracknumber") + b"'," + b"'" + self.getValue(id3, "date") + b"'," + b"'0') " +
|
||||
b" ON DUPLICATE KEY UPDATE `genre`=VALUES(`genre`) , `trackName` = VALUES(`trackName`) , `artistName` = VALUES(`artistName`) ,`albumName` = VALUES(`albumName`) , `albumArtist` = VALUES(`albumArtist`) , `trackNumber` = VALUES(`trackNumber`) , `year` = VALUES(`year`) , `duration` = VALUES(`duration`)")
|
||||
|
||||
except (mutagen.id3._util.ID3NoHeaderError):
|
||||
pass
|
||||
|
||||
def removeSong(self,path):
|
||||
self.db.removeSong(path)
|
||||
|
||||
def getValue(self, id3, value):
|
||||
try:
|
||||
return id3[value][0].replace("'", "\\'")
|
||||
except (KeyError, IndexError, ValueError):
|
||||
print("Error reading value of ID3 tag", end='\r')
|
||||
return ""
|
||||
|
||||
|
||||
class Filehandler(FileSystemEventHandler):
|
||||
def __init__(self, LibraryScanner):
|
||||
self.libscanner = LibraryScanner
|
||||
|
||||
def process(self, event):
|
||||
if not(event.is_directory):
|
||||
if os.path.isfile(event.src_path) and event.src_path.lower().endswith(('.mp3','.flac', 'm4a')):
|
||||
self.libscanner.insertSong(event.src_path)
|
||||
else:
|
||||
self.libscanner.removeSong(event.src_path)
|
||||
|
||||
def on_modified(self, event):
|
||||
self.process(event)
|
||||
|
||||
def on_created(self, event):
|
||||
self.process(event)
|
||||
@@ -0,0 +1,60 @@
|
||||
import sys
|
||||
import os
|
||||
import configparser
|
||||
from yjdaemon.Database import Database
|
||||
from yjdaemon.libraryscanner import LibraryScanner
|
||||
from yjdaemon.yjmpd import YJMPD
|
||||
from yjdaemon.HTTPServer import HTTPServerThread
|
||||
|
||||
debug = False
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
try:
|
||||
config.read("../config.cfg")
|
||||
HTTP_PORT = int(config.get("HTTP", "port"))
|
||||
DAEMON_PORT = int(config.get("Daemon", "port"))
|
||||
MUSIC_DIR = str(config.get("Library", "jancodir"))
|
||||
|
||||
DB_USERNAME = config.get("Database", "username")
|
||||
DB_PASSWORD = config.get("Database", "password")
|
||||
DB_HOST = config.get("Database", "host")
|
||||
DB_DATABASE = config.get("Database", "database")
|
||||
DB_PORT = config.getint("Database", "port")
|
||||
|
||||
except Exception as e:
|
||||
print(e.with_traceback())
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class MainDaemon(YJMPD):
|
||||
def run(self):
|
||||
HTTP_thread = HTTPServerThread(HTTP_PORT)
|
||||
HTTP_thread.start()
|
||||
db = Database(DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE)
|
||||
LibraryScanner(db, MUSIC_DIR)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
username = os.getenv('USER')
|
||||
if None == username:
|
||||
dir = "/tmp/.pydaemon.pid"
|
||||
else:
|
||||
dir = "/home/" + username + "/.pydaemon.pid"
|
||||
daemon = MainDaemon(dir, MUSIC_DIR)
|
||||
if len(sys.argv) == 2:
|
||||
if 'start' == sys.argv[1]:
|
||||
daemon.start()
|
||||
elif 'stop' == sys.argv[1]:
|
||||
daemon.stop()
|
||||
elif 'restart' == sys.argv[1]:
|
||||
daemon.restart()
|
||||
elif 'status' == sys.argv[1]:
|
||||
daemon.status()
|
||||
else:
|
||||
print("Unknown command")
|
||||
sys.exit(2)
|
||||
sys.exit(0)
|
||||
else:
|
||||
print("usage: %s start|stop|status|restart" % sys.argv[0])
|
||||
sys.exit(2)
|
||||
@@ -0,0 +1,135 @@
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
import atexit
|
||||
import signal
|
||||
|
||||
|
||||
class YJMPD:
|
||||
"""A generic yjdaemon class.
|
||||
|
||||
Usage: subclass the yjdaemon class and override the run() method."""
|
||||
|
||||
def __init__(self, pidfile, root):
|
||||
self.pidfile = pidfile
|
||||
self.root = root
|
||||
|
||||
def daemonize(self):
|
||||
"""Deamonize class. UNIX double fork mechanism."""
|
||||
|
||||
try:
|
||||
pid = os.fork()
|
||||
if pid > 0:
|
||||
# exit first parent
|
||||
sys.exit(0)
|
||||
except OSError as err:
|
||||
sys.stderr.write('fork #1 failed: {0}\n'.format(err))
|
||||
sys.exit(1)
|
||||
|
||||
# decouple from parent environment
|
||||
os.chdir(self.root)
|
||||
os.setsid()
|
||||
os.umask(0)
|
||||
|
||||
# do second fork
|
||||
try:
|
||||
pid = os.fork()
|
||||
if pid > 0:
|
||||
# exit from second parent
|
||||
sys.exit(0)
|
||||
except OSError as err:
|
||||
sys.stderr.write('fork #2 failed: {0}\n'.format(err))
|
||||
sys.exit(1)
|
||||
|
||||
# redirect standard file descriptors
|
||||
sys.stdout.flush()
|
||||
sys.stderr.flush()
|
||||
si = open(os.devnull, 'r')
|
||||
so = open(os.devnull, 'a+')
|
||||
se = open(os.devnull, 'a+')
|
||||
|
||||
os.dup2(si.fileno(), sys.stdin.fileno())
|
||||
os.dup2(so.fileno(), sys.stdout.fileno())
|
||||
os.dup2(se.fileno(), sys.stderr.fileno())
|
||||
|
||||
# write pidfile
|
||||
atexit.register(self.delpid)
|
||||
|
||||
pid = str(os.getpid())
|
||||
with open(self.pidfile, 'w+') as f:
|
||||
f.write(pid + '\n')
|
||||
|
||||
def delpid(self):
|
||||
os.remove(self.pidfile)
|
||||
|
||||
def start(self):
|
||||
"""Start the yjdaemon."""
|
||||
|
||||
# Check for a pidfile to see if the yjdaemon already runs
|
||||
try:
|
||||
with open(self.pidfile, 'r') as pf:
|
||||
|
||||
pid = int(pf.read().strip())
|
||||
except IOError:
|
||||
pid = None
|
||||
|
||||
if pid:
|
||||
message = "pidfile {0} already exist. " + \
|
||||
"Daemon already running?\n"
|
||||
sys.stderr.write(message.format(self.pidfile))
|
||||
sys.exit(1)
|
||||
|
||||
# Start the yjdaemon
|
||||
self.daemonize()
|
||||
self.run()
|
||||
|
||||
def stop(self):
|
||||
"""Stop the yjdaemon."""
|
||||
|
||||
# Get the pid from the pidfile
|
||||
try:
|
||||
with open(self.pidfile, 'r') as pf:
|
||||
pid = int(pf.read().strip())
|
||||
except IOError:
|
||||
pid = None
|
||||
|
||||
if not pid:
|
||||
message = "pidfile {0} does not exist. " + \
|
||||
"Daemon not running?\n"
|
||||
sys.stderr.write(message.format(self.pidfile))
|
||||
return # not an error in a restart
|
||||
|
||||
# Try killing the yjdaemon process
|
||||
try:
|
||||
while 1:
|
||||
os.kill(pid, signal.SIGTERM)
|
||||
time.sleep(0.1)
|
||||
except OSError as err:
|
||||
e = str(err.args)
|
||||
if e.find("No such process") > 0:
|
||||
if os.path.exists(self.pidfile):
|
||||
os.remove(self.pidfile)
|
||||
else:
|
||||
print(str(err.args))
|
||||
sys.exit(1)
|
||||
|
||||
def restart(self):
|
||||
"""Restart the yjdaemon."""
|
||||
self.stop()
|
||||
self.start()
|
||||
|
||||
|
||||
|
||||
def status(self):
|
||||
"""Print out status."""
|
||||
if os.path.exists(self.pidfile):
|
||||
message = "Daemon running.\n"
|
||||
else:
|
||||
message = "Daemon not running.\n"
|
||||
sys.stdout.write(message)
|
||||
|
||||
def run(self):
|
||||
"""You should override this method when you subclass Daemon.
|
||||
|
||||
It will be called after the process has been daemonized by
|
||||
start() or restart()."""
|
||||
@@ -0,0 +1,64 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.3.8deb0.1
|
||||
-- http://www.phpmyadmin.net
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Gegenereerd op: 27 sep 2015 om 22:19
|
||||
-- Serverversie: 5.6.19-0ubuntu0.14.04.1
|
||||
-- PHP-versie: 5.5.9-1ubuntu4.11
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
|
||||
--
|
||||
-- Database: `yjmpd`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Tabelstructuur voor tabel `tracks`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tracks` (
|
||||
`id` int(11) NOT NULL,
|
||||
`genre` varchar(100) DEFAULT NULL,
|
||||
`trackUrl` varchar(200) NOT NULL,
|
||||
`trackName` varchar(100) DEFAULT NULL,
|
||||
`artistName` varchar(100) DEFAULT NULL,
|
||||
`albumName` varchar(100) DEFAULT NULL,
|
||||
`albumArtist` varchar(100) DEFAULT NULL,
|
||||
`trackNumber` int(11) DEFAULT NULL,
|
||||
`year` int(11) DEFAULT NULL,
|
||||
`duration` time DEFAULT NULL,
|
||||
`playCount` int(11) NOT NULL DEFAULT '0'
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=8135 DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Indexen voor geëxporteerde tabellen
|
||||
--
|
||||
|
||||
--
|
||||
-- Indexen voor tabel `tracks`
|
||||
--
|
||||
ALTER TABLE `tracks`
|
||||
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `trackUrl` (`trackUrl`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT voor geëxporteerde tabellen
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT voor een tabel `tracks`
|
||||
--
|
||||
ALTER TABLE `tracks`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=8135;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
Reference in New Issue
Block a user