first working play using the polymer data structure.

This commit is contained in:
Don Archer 2016-07-31 21:45:25 -07:00
parent 18fee93f93
commit b5ab01e054
20 changed files with 335 additions and 138 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "herse.models"]
path = herse.models
url = git@bitbucket.org:teamherse/herse.models.git

View File

@ -1,32 +1,77 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using KaraokePlayer.Interfaces;
using KaraokePlayer.Enums; using KaraokePlayer.Enums;
using FireSharp.Interfaces; using FireSharp.Interfaces;
using FireSharp.Config; using FireSharp.Config;
using FireSharp; using FireSharp;
using Newtonsoft.Json;
using System.Configuration;
namespace KaraokePlayer.Classes namespace KaraokePlayer.Classes
{ {
public class FirebaseSong : ISong
public class Singer
{ {
public Guid Id { get; set; } [JsonProperty("name")]
public int Order { get; set; } public string Name { get; set; }
public string Title { get; set; }
public string Artist { get; set; }
public FileType FileType { get; set; }
public string Path { get; set; }
public string Description { get { return Artist + " - " + Title; } }
} }
public class FirebaseController : IController public class Song
{
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("artist")]
public string Artist { get; set; }
[JsonProperty("genre")]
public string Genre { get; set; }
[JsonProperty("year")]
public int Year { get; set; }
[JsonProperty("path")]
public string Path { get; set; }
[JsonIgnore]
public FileType FileType
{
get
{
switch (Path.Substring(Path.Length - 3, 3).ToLower())
{
case "cdg":
case "mp3":
return FileType.CDG;
case "mp4":
return FileType.MP4;
case "zip":
return FileType.ZIP;
default:
throw new Exception("file type not handled");
}
}
}
}
public class QueueItem
{
[JsonProperty("singer")]
public Singer Singer { get; set; }
[JsonProperty("song")]
public Song Song { get; set; }
}
public class FirebaseController
{ {
public static Guid TestGuid = Guid.Parse("f1ec2c8a-6f11-4ac0-8b0e-e576d15f2759");
private IFirebaseConfig config = new FirebaseConfig private IFirebaseConfig config = new FirebaseConfig
{ {
AuthSecret = "wj0ERDFZqNSysTtIXcCgCr8Itahr6pJOBeqCjvDF", AuthSecret = ConfigurationManager.AppSettings["Firebase.Secret"],
BasePath = "https://karaokecontroller.firebaseio.com/" BasePath = ConfigurationManager.AppSettings["Firebase.Path"]
}; };
private string _state = "stop"; private string _state = "stop";
private IFirebaseClient _client; private IFirebaseClient _client;
@ -36,36 +81,36 @@ namespace KaraokePlayer.Classes
private string StatePath private string StatePath
{ {
get { return string.Format("Controllers/{0}/State", this.Id); } get { return string.Format("controllers/{0}/state/", this.Id); }
} }
private string PlayQueuePath private string PlayQueuePath
{ {
get { return string.Format("Controllers/{0}/PlayQueue", this.Id); } get { return string.Format("controllers/{0}/queue/", this.Id); }
} }
private string CurrentSongPath private string CurrentSongPath
{ {
get { return string.Format("Controllers/{0}/CurrentSong", this.Id); } get { return string.Format("controllers/{0}/queue/0/", this.Id); }
} }
public Guid Id { get; set; } public string Id { get; set; }
public ISong CurrentSong { get; set; } public Song CurrentSong { get; set; }
public List<ISong> PlayQueue { get; set; } public List<Song> PlayQueue { get; set; }
public string State { public string State {
get { return State; } get { return State; }
set { set {
_state = value; _state = value;
Update(string.Format("Controllers/{0}", this.Id), new { State = _state }); Update(string.Format("controllers/{0}", this.Id), new { state = _state });
} }
} }
public FirebaseController(Guid clientId, ControllerStateChangedEventHandler stateChanged, ControllerSongChangedEventHandler songChanged, ControllerPlayQueueChangedEventHandler playQueueChanged) public FirebaseController(string clientId, ControllerStateChangedEventHandler stateChanged, ControllerSongChangedEventHandler songChanged, ControllerPlayQueueChangedEventHandler playQueueChanged)
{ {
Id = clientId; Id = clientId;
_stateChanged = stateChanged; _stateChanged = stateChanged;
_songChanged = songChanged; _songChanged = songChanged;
_playQueueChanged = playQueueChanged; _playQueueChanged = playQueueChanged;
PlayQueue = new List<ISong>(); PlayQueue = new List<Song>();
_client = new FirebaseClient(config); _client = new FirebaseClient(config);
Reset(); Reset();
SetupListener(); SetupListener();
@ -73,46 +118,12 @@ namespace KaraokePlayer.Classes
public void NextSong() public void NextSong()
{ {
ISong song = PlayQueue.FirstOrDefault(); Song song = PlayQueue.FirstOrDefault();
Stop(); Stop();
if(song != null) { PlaySong(song); } if(song != null) { PlaySong(song); }
} }
public void PlaySong(ISong song) { Update(string.Format("Controllers/{0}", this.Id), new { CurrentSong = song }); } public void PlaySong(Song song) { Update(string.Format("Controllers/{0}", this.Id), new { CurrentSong = song }); }
public void AddSong(ISong song) { Update(string.Format("Controllers/{0}/PlayQueue/{1}", this.Id, song.Id), song); }
public void RemoveSong(ISong song)
{
ISong found = PlayQueue.FirstOrDefault(s => s.Id == song.Id);
if (found != null)
{
PlayQueue.Remove(found);
Delete(PlayQueuePath + "/" + song.Id);
}
}
public void SkipSong()
{
ISong song = null;
int count = PlayQueue.Count();
int index = PlayQueue.FindIndex(s => s.Id == CurrentSong.Id);
if (index + 1 == count && count > 1)
{
song = PlayQueue.First();
}
else {
if (PlayQueue.Count() > index)
{
song = PlayQueue[index + 1];
}
}
Stop();
if(song != null)
{
PlaySong(song);
}
}
public void Next() { this.State = "Next"; } public void Next() { this.State = "Next"; }
@ -130,7 +141,7 @@ namespace KaraokePlayer.Classes
{ {
Stop(); Stop();
Delete(PlayQueuePath); Delete(PlayQueuePath);
Delete(CurrentSongPath); Delete(CurrentSongPath);
} }
private async void SetupListener() private async void SetupListener()
@ -138,24 +149,26 @@ namespace KaraokePlayer.Classes
await _client.OnAsync(CurrentSongPath, await _client.OnAsync(CurrentSongPath,
added: (s, args, obj) => added: (s, args, obj) =>
{ {
if (args.Path.Contains("Id")) if (args.Path == "/singer/name")
{ {
Console.WriteLine("added " + args.Path + " " + args.Data);
CurrentSongDidChange(); CurrentSongDidChange();
} }
}, },
changed: (s, args, obj) => removed: (s, args, obj) =>
{ {
if (args.Path.Contains("Id")) //TODO: the current song was removed from the queue
if (args.Path == "/singer")
{ {
CurrentSongDidChange(); Console.WriteLine("removed " + args.Path);
} }
}, }
removed: null
); );
/*
await _client.OnAsync(PlayQueuePath, await _client.OnAsync(PlayQueuePath,
added: (s, args, obj) => added: (s, args, obj) =>
{ {
Console.WriteLine(args.Path);
if (args.Path.Contains("Id")) if (args.Path.Contains("Id"))
{ {
PlayQueueDidChange(); PlayQueueDidChange();
@ -185,18 +198,19 @@ namespace KaraokePlayer.Classes
}, },
removed: null removed: null
); );
*/
} }
private void PlayQueueDidChange() private void PlayQueueDidChange()
{ {
bool autoPlay = PlayQueue.Count() == 0; bool autoPlay = PlayQueue.Count() == 0;
var response = _client.Get(PlayQueuePath); var response = _client.Get(PlayQueuePath);
var dict = response.ResultAs<Dictionary<string, FirebaseSong>>(); var dict = response.ResultAs<Dictionary<string, Song>>();
PlayQueue.Clear(); PlayQueue.Clear();
if (dict != null && dict.Count() > 0) if (dict != null && dict.Count() > 0)
{ {
var array = dict.Values.OrderBy(s => s.Order).ToArray(); var array = dict.Values.ToArray();
PlayQueue.AddRange(array); PlayQueue.AddRange(array);
if (autoPlay) if (autoPlay)
{ {
@ -209,11 +223,11 @@ namespace KaraokePlayer.Classes
private void CurrentSongDidChange() private void CurrentSongDidChange()
{ {
var response = _client.Get(CurrentSongPath); var response = _client.Get(CurrentSongPath);
var song = response.ResultAs<FirebaseSong>(); var item = response.ResultAs<QueueItem>();
if (song != null) if (item != null)
{ {
CurrentSong = song; CurrentSong = item.Song;
_songChanged(new ControllerSongChangedEventArgs(false, song)); _songChanged(new ControllerSongChangedEventArgs(item.Song));
} }
} }
@ -233,7 +247,7 @@ namespace KaraokePlayer.Classes
{ {
s = PlayerState.Next; s = PlayerState.Next;
} }
_stateChanged(new ControllerStateChangedEventArgs(s)); //_stateChanged(new ControllerStateChangedEventArgs(s));
} }
} }

View File

@ -51,6 +51,7 @@
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Net" /> <Reference Include="System.Net" />
<Reference Include="System.Net.Http.Extensions, Version=2.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="System.Net.Http.Extensions, Version=2.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@ -73,7 +74,6 @@
<Compile Include="Enums.cs" /> <Compile Include="Enums.cs" />
<Compile Include="Extensions.cs" /> <Compile Include="Extensions.cs" />
<Compile Include="FirebaseController.cs" /> <Compile Include="FirebaseController.cs" />
<Compile Include="Interfaces.cs" />
<Compile Include="PlayerDelegates.cs" /> <Compile Include="PlayerDelegates.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>

View File

@ -1,36 +0,0 @@
using KaraokePlayer.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KaraokePlayer.Interfaces
{
public interface ISong
{
Guid Id { get; set; }
int Order { get; set; }
string Title { get; set; }
string Artist { get; set; }
FileType FileType { get; set; }
string Path { get; set; }
string Description { get; }
}
public interface IController
{
Guid Id { get; set; }
ISong CurrentSong { get; set; }
string State { get; set; }
List<ISong> PlayQueue { get; set; }
void NextSong();
void RemoveSong(ISong song);
void AddSong(ISong song);
void SkipSong();
void Play();
void Pause();
void Stop();
void Next();
}
}

View File

@ -1,5 +1,4 @@
using KaraokePlayer.Enums; using KaraokePlayer.Enums;
using KaraokePlayer.Interfaces;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -18,17 +17,17 @@ namespace KaraokePlayer.Classes
} }
public class ControllerSongChangedEventArgs public class ControllerSongChangedEventArgs
{ {
public ControllerSongChangedEventArgs(ISong song) public ControllerSongChangedEventArgs(Song song)
{ {
ShouldPlay = true; ShouldPlay = true;
Song = song; Song = song;
} }
public ControllerSongChangedEventArgs(bool shouldPlay, ISong song) public ControllerSongChangedEventArgs(bool shouldPlay, Song song)
{ {
ShouldPlay = shouldPlay; ShouldPlay = shouldPlay;
Song = song; Song = song;
} }
public ISong Song { get; } public Song Song { get; }
public bool ShouldPlay { get; } public bool ShouldPlay { get; }
} }

View File

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 14
VisualStudioVersion = 14.0.24720.0 VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CdgLib", "CdgLib\CdgLib.csproj", "{3203DFD2-DA5B-47B3-B009-18DD9C401FC3}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CdgLib", "CdgLib\CdgLib.csproj", "{3203DFD2-DA5B-47B3-B009-18DD9C401FC3}"
EndProject EndProject
@ -13,10 +13,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KaraokePlayer", "KaraokePla
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CdgPlayer", "CdgPlayer\CdgPlayer.csproj", "{A5324295-6BD2-4415-92CD-6EA77D708E00}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CdgPlayer", "CdgPlayer\CdgPlayer.csproj", "{A5324295-6BD2-4415-92CD-6EA77D708E00}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSelector", "TestSelector\TestSelector.csproj", "{B81665BC-A207-47F5-BBF4-2DE59965325F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FirebaseKaraoke", "FirebaseKaraoke\FirebaseKaraoke.csproj", "{4FE25E6D-1BEB-4902-9815-C2B421233BD7}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FirebaseKaraoke", "FirebaseKaraoke\FirebaseKaraoke.csproj", "{4FE25E6D-1BEB-4902-9815-C2B421233BD7}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SongCrawler", "SongCrawler\SongCrawler.csproj", "{82F60DD0-80EC-49C8-9E7C-95A250783E68}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Herse.Models", "herse.models\Herse.Models.csproj", "{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -35,14 +37,18 @@ Global
{A5324295-6BD2-4415-92CD-6EA77D708E00}.Debug|Any CPU.Build.0 = Debug|Any CPU {A5324295-6BD2-4415-92CD-6EA77D708E00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5324295-6BD2-4415-92CD-6EA77D708E00}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5324295-6BD2-4415-92CD-6EA77D708E00}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5324295-6BD2-4415-92CD-6EA77D708E00}.Release|Any CPU.Build.0 = Release|Any CPU {A5324295-6BD2-4415-92CD-6EA77D708E00}.Release|Any CPU.Build.0 = Release|Any CPU
{B81665BC-A207-47F5-BBF4-2DE59965325F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B81665BC-A207-47F5-BBF4-2DE59965325F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B81665BC-A207-47F5-BBF4-2DE59965325F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B81665BC-A207-47F5-BBF4-2DE59965325F}.Release|Any CPU.Build.0 = Release|Any CPU
{4FE25E6D-1BEB-4902-9815-C2B421233BD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4FE25E6D-1BEB-4902-9815-C2B421233BD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4FE25E6D-1BEB-4902-9815-C2B421233BD7}.Debug|Any CPU.Build.0 = Debug|Any CPU {4FE25E6D-1BEB-4902-9815-C2B421233BD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FE25E6D-1BEB-4902-9815-C2B421233BD7}.Release|Any CPU.ActiveCfg = Release|Any CPU {4FE25E6D-1BEB-4902-9815-C2B421233BD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4FE25E6D-1BEB-4902-9815-C2B421233BD7}.Release|Any CPU.Build.0 = Release|Any CPU {4FE25E6D-1BEB-4902-9815-C2B421233BD7}.Release|Any CPU.Build.0 = Release|Any CPU
{82F60DD0-80EC-49C8-9E7C-95A250783E68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82F60DD0-80EC-49C8-9E7C-95A250783E68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82F60DD0-80EC-49C8-9E7C-95A250783E68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82F60DD0-80EC-49C8-9E7C-95A250783E68}.Release|Any CPU.Build.0 = Release|Any CPU
{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -3,10 +3,13 @@
<configSections> <configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<connectionStrings> </configSections>
<add providerName="System.Data.SqlClient" connectionString="Data Source=tcp:herse.database.windows.net,1433;Initial Catalog=herse;Persist Security Info=True;User ID=herse;password=94diablo!" name="HerseDb" /> <appSettings>
</connectionStrings> <add key="Firebase.Secret" value="9BQHUEJhScgK2FP10hvlToxTlGQpXT94Cvx01piO"/>
<add key="Firebase.Path" value="https://herse.firebaseio.com/"/>
<add key="KaraokePlayer.ControllerId" value="archer1"/>
</appSettings>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup> </startup>

View File

@ -79,6 +79,7 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing.Design" /> <Reference Include="System.Drawing.Design" />
<Reference Include="System.IO.Compression" /> <Reference Include="System.IO.Compression" />

View File

@ -7,9 +7,9 @@ using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.IO.Compression; using System.IO.Compression;
using System.Windows.Forms; using System.Windows.Forms;
using KaraokePlayer.Interfaces;
using KaraokePlayer.Classes; using KaraokePlayer.Classes;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Configuration;
namespace KaraokePlayer namespace KaraokePlayer
{ {
@ -18,8 +18,8 @@ namespace KaraokePlayer
private SongInfoForm songInfoForm = new SongInfoForm(); private SongInfoForm songInfoForm = new SongInfoForm();
private delegate void Action(); private delegate void Action();
private KaraokeVideoPlayer currentPlayer = null; private KaraokeVideoPlayer currentPlayer = null;
private IController controller; private FirebaseController controller;
private ISong currentSong; private Song currentSong;
public MainForm() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
@ -35,7 +35,7 @@ namespace KaraokePlayer
karaokeMP4Player.Dock = DockStyle.Fill; karaokeMP4Player.Dock = DockStyle.Fill;
controller = new FirebaseController( controller = new FirebaseController(
clientId: FirebaseController.TestGuid, clientId: ConfigurationManager.AppSettings["KaraokePlayer.ControllerId"],
stateChanged: (args) => stateChanged: (args) =>
{ {
if (args.State == Enums.PlayerState.Play) if (args.State == Enums.PlayerState.Play)
@ -70,7 +70,8 @@ namespace KaraokePlayer
songInfoForm.Update(currentSong); songInfoForm.Update(currentSong);
songInfoForm.Show(); songInfoForm.Show();
await Task.Delay(TimeSpan.FromSeconds(5)); await Task.Delay(TimeSpan.FromSeconds(5));
controller.Play(); //controller.Play();
play();
songInfoForm.Hide(); songInfoForm.Hide();
} }
@ -81,7 +82,6 @@ namespace KaraokePlayer
private void next() private void next()
{ {
controller.RemoveSong(currentSong);
controller.NextSong(); controller.NextSong();
} }

View File

@ -1,6 +1,4 @@
using KaraokePlayer.Interfaces; namespace KaraokePlayer
namespace KaraokePlayer
{ {
partial class SongInfoForm partial class SongInfoForm
{ {

View File

@ -1,4 +1,4 @@
using KaraokePlayer.Interfaces; using KaraokePlayer.Classes;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -21,7 +21,7 @@ namespace KaraokePlayer
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
} }
public void Update(ISong song) public void Update(Song song)
{ {
previewLabel.Text = "Up Next:" + "\r\n\r\n" + song.Artist + "\r\n\r\n\r\n" + song.Title; previewLabel.Text = "Up Next:" + "\r\n\r\n" + song.Artist + "\r\n\r\n\r\n" + song.Title;
} }

14
SongCrawler/App.config Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

40
SongCrawler/Program.cs Normal file
View File

@ -0,0 +1,40 @@
using FireSharp.Config;
using FireSharp.Interfaces;
using FireSharp.Response;
using Herse.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SongCrawler
{
class Program
{
static void Main(string[] args)
{
string controller = args[0];
string songpath = args[1];
IFirebaseConfig config = new FirebaseConfig
{
AuthSecret = "9BQHUEJhScgK2FP10hvlToxTlGQpXT94Cvx01piO",
BasePath = "https://herse.firebaseio.com/"
};
FireSharp.FirebaseClient client = new FireSharp.FirebaseClient(config);
string firepath = string.Format("controllers/{0}/songs", controller);
string[] files = Directory.GetFiles(songpath, "*.mp3");
List<Song> songs = new List<Song>();
foreach (string file in files)
{
TagLib.File tagFile = TagLib.File.Create(file);
songs.Add(new Song() { Title = tagFile.Tag.Title, Artist = tagFile.Tag.FirstPerformer, Path = file, Genre = tagFile.Tag.FirstGenre, Year = (int)tagFile.Tag.Year });
}
SetResponse response = client.Set(firepath, songs);
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SongCrawler")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SongCrawler")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("82f60dd0-80ec-49c8-9e7c-95a250783e68")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{82F60DD0-80EC-49C8-9E7C-95A250783E68}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SongCrawler</RootNamespace>
<AssemblyName>SongCrawler</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="FireSharp, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FireSharp.2.0.4\lib\portable-net45+sl5+wp8+win8\FireSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http.Extensions, Version=2.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=4.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="taglib-sharp, Version=2.1.0.0, Culture=neutral, PublicKeyToken=db62eba44689b5b0, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>libs\taglib-sharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\herse.models\Herse.Models.csproj">
<Project>{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}</Project>
<Name>Herse.Models</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="libs\taglib-sharp.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<!-- 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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FireSharp" version="2.0.4" targetFramework="net452" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net452" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net452" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net452" />
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="TagLib.Portable" version="1.0.4" targetFramework="net452" />
</packages>

View File

@ -83,7 +83,6 @@ namespace TestSelector
_fileList = filtered.Select(file => new FileInfo(file)).ToList(); _fileList = filtered.Select(file => new FileInfo(file)).ToList();
listBox1.DataSource = _fileList; listBox1.DataSource = _fileList;
listBox1.DisplayMember = "Name"; listBox1.DisplayMember = "Name";
} }
} }
private static string[] GetFiles(string path, string searchPattern, SearchOption searchOption) private static string[] GetFiles(string path, string searchPattern, SearchOption searchOption)

BIN
TestSongs/SF365/Thumbs.db Normal file

Binary file not shown.

1
herse.models Submodule

@ -0,0 +1 @@
Subproject commit bb1162615a259730c3c5786142525060bc1a3128