refactored dupe code into assembly
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
b39a3b5972
commit
e1e2977511
@ -20,6 +20,7 @@ namespace KaraokePlayer.Classes
|
||||
public string Artist { get; set; }
|
||||
public FileType FileType { get; set; }
|
||||
public string Path { get; set; }
|
||||
|
||||
public string Description { get { return Artist + " - " + Title; } }
|
||||
}
|
||||
|
||||
@ -163,7 +164,7 @@ namespace KaraokePlayer.Classes
|
||||
var dict = response.ResultAs<Dictionary<string, FirebaseSong>>();
|
||||
|
||||
PlayQueue.Clear();
|
||||
if (dict.Count() > 0)
|
||||
if (dict != null && dict.Count() > 0)
|
||||
{
|
||||
foreach (KeyValuePair<string, FirebaseSong> entry in dict)
|
||||
{
|
||||
@ -178,18 +179,21 @@ namespace KaraokePlayer.Classes
|
||||
}
|
||||
}
|
||||
if (PlayQueueChanged != null) { PlayQueueChanged(); }
|
||||
PlayQueueChanged();
|
||||
}
|
||||
|
||||
private void CurrentSongChanged()
|
||||
{
|
||||
var response = client.Get("controller/currentSong");
|
||||
var dict = response.ResultAs<Dictionary<string, FirebaseSong>>();
|
||||
|
||||
var song = dict.Values.FirstOrDefault();
|
||||
if (song != null)
|
||||
if (dict != null)
|
||||
{
|
||||
CurrentSong = song;
|
||||
SongChanged(new ControllerSongChangedEventArgs(false, song));
|
||||
var song = dict.Values.FirstOrDefault();
|
||||
if (song != null)
|
||||
{
|
||||
CurrentSong = song;
|
||||
SongChanged(new ControllerSongChangedEventArgs(false, song));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
95
FirebaseKaraoke/FirebaseKaraoke.csproj
Normal file
95
FirebaseKaraoke/FirebaseKaraoke.csproj
Normal file
@ -0,0 +1,95 @@
|
||||
<?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>{4FE25E6D-1BEB-4902-9815-C2B421233BD7}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>FirebaseKaraoke</RootNamespace>
|
||||
<AssemblyName>FirebaseKaraoke</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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' ">
|
||||
<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=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.6.0.4\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" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="FirebaseController.cs" />
|
||||
<Compile Include="Interfaces.cs" />
|
||||
<Compile Include="PlayerDelegates.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</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>
|
||||
36
FirebaseKaraoke/Properties/AssemblyInfo.cs
Normal file
36
FirebaseKaraoke/Properties/AssemblyInfo.cs
Normal 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("FirebaseKaraoke")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("FirebaseKaraoke")]
|
||||
[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("4fe25e6d-1beb-4902-9815-c2b421233bd7")]
|
||||
|
||||
// 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")]
|
||||
9
FirebaseKaraoke/packages.config
Normal file
9
FirebaseKaraoke/packages.config
Normal file
@ -0,0 +1,9 @@
|
||||
<?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="6.0.4" targetFramework="net452" />
|
||||
</packages>
|
||||
@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication1", "Cons
|
||||
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}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -43,6 +45,10 @@ Global
|
||||
{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.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.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@ -57,10 +57,6 @@
|
||||
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<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="MaterialSkin, Version=0.0.3.3, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>lib\MaterialSkin.dll</HintPath>
|
||||
@ -108,10 +104,6 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Classes\Enums.cs" />
|
||||
<Compile Include="Classes\FirebaseController.cs" />
|
||||
<Compile Include="Classes\Interfaces.cs" />
|
||||
<Compile Include="Classes\PlayerDelegates.cs" />
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -470,6 +462,10 @@
|
||||
<Project>{a5324295-6bd2-4415-92cd-6ea77d708e00}</Project>
|
||||
<Name>CdgPlayer</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\FirebaseKaraoke\FirebaseKaraoke.csproj">
|
||||
<Project>{4fe25e6d-1beb-4902-9815-c2b421233bd7}</Project>
|
||||
<Name>FirebaseKaraoke</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.6">
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EntityFramework" version="6.1.3" targetFramework="net46" />
|
||||
<package id="FireSharp" version="2.0.4" targetFramework="net46" />
|
||||
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net46" />
|
||||
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net46" />
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net46" />
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KaraokePlayer.Enums
|
||||
{
|
||||
public enum PlayerState
|
||||
{
|
||||
Play,
|
||||
Stop,
|
||||
Pause,
|
||||
Next
|
||||
}
|
||||
|
||||
public enum FileType
|
||||
{
|
||||
CDG, MP4, ZIP
|
||||
}
|
||||
}
|
||||
@ -1,216 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using KaraokePlayer.Interfaces;
|
||||
using KaraokePlayer.Enums;
|
||||
using FireSharp.Interfaces;
|
||||
using FireSharp.Config;
|
||||
using FireSharp;
|
||||
|
||||
namespace KaraokePlayer.Classes
|
||||
{
|
||||
public class FirebaseSong : ISong
|
||||
{
|
||||
public string FirebaseId { get; set; }
|
||||
public int Id { get; set; }
|
||||
public int Order { 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
|
||||
{
|
||||
private IFirebaseConfig config = new FirebaseConfig
|
||||
{
|
||||
AuthSecret = "wj0ERDFZqNSysTtIXcCgCr8Itahr6pJOBeqCjvDF",
|
||||
BasePath = "https://karaokecontroller.firebaseio.com/"
|
||||
};
|
||||
private IFirebaseClient client;
|
||||
private ControllerStateChangedEventHandler StateChanged;
|
||||
private ControllerSongChangedEventHandler SongChanged;
|
||||
private ControllerPlayQueueChangedEventHandler PlayQueueChanged;
|
||||
public FirebaseController(ControllerStateChangedEventHandler stateChanged, ControllerSongChangedEventHandler songChanged, ControllerPlayQueueChangedEventHandler playQueueChanged)
|
||||
{
|
||||
StateChanged = stateChanged;
|
||||
SongChanged = songChanged;
|
||||
PlayQueueChanged = playQueueChanged;
|
||||
PlayQueue = new List<ISong>();
|
||||
client = new FirebaseClient(config);
|
||||
client.DeleteAsync("controller/state");
|
||||
client.PushAsync("controller/state", "stop");
|
||||
client.DeleteAsync("controller/playQueue");
|
||||
client.DeleteAsync("controller/currentSong");
|
||||
ListenToStream();
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public ISong CurrentSong { get; set; }
|
||||
public List<ISong> PlayQueue { get; set; }
|
||||
public void GetNextSong()
|
||||
{
|
||||
ISong song = PlayQueue.FirstOrDefault();
|
||||
Stop();
|
||||
client.DeleteAsync("controller/currentSong");
|
||||
client.PushAsync("controller/currentSong", song);
|
||||
}
|
||||
|
||||
public void PlaySong(ISong song)
|
||||
{
|
||||
client.DeleteAsync("controller/currentSong");
|
||||
client.PushAsync("controller/currentSong", song);
|
||||
}
|
||||
public void AddSongToQueue(ISong song)
|
||||
{
|
||||
client.PushAsync("controller/playQueue", song);
|
||||
}
|
||||
|
||||
public void RemoveSong(ISong song)
|
||||
{
|
||||
ISong found = PlayQueue.FirstOrDefault(s => s.Id == song.Id);
|
||||
if (found != null)
|
||||
{
|
||||
PlayQueue.Remove(found);
|
||||
client.DeleteAsync("controller/playQueue/" + ((FirebaseSong)song).FirebaseId);
|
||||
}
|
||||
}
|
||||
public void Next()
|
||||
{
|
||||
client.DeleteAsync("controller/state");
|
||||
client.PushAsync("controller/state", "next");
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
client.DeleteAsync("controller/state");
|
||||
client.PushAsync("controller/state", "play");
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
client.DeleteAsync("controller/state");
|
||||
client.PushAsync("controller/state", "stop");
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
client.DeleteAsync("controller/state");
|
||||
client.PushAsync("controller/state", "pause");
|
||||
}
|
||||
|
||||
private async void ListenToStream()
|
||||
{
|
||||
await client.OnAsync("controller/currentSong",
|
||||
added: (s, args, obj) =>
|
||||
{
|
||||
if (args.Path.Contains("Id"))
|
||||
{
|
||||
CurrentSongChanged();
|
||||
}
|
||||
},
|
||||
changed: (s, args, obj) =>
|
||||
{
|
||||
if (args.Path.Contains("Id"))
|
||||
{
|
||||
CurrentSongChanged();
|
||||
}
|
||||
},
|
||||
removed: null
|
||||
);
|
||||
|
||||
await client.OnAsync("controller/playQueue",
|
||||
added: (s, args, obj) =>
|
||||
{
|
||||
if (args.Path.Contains("Id"))
|
||||
{
|
||||
ReloadPlayQueue();
|
||||
}
|
||||
},
|
||||
changed: (s, args, obj) =>
|
||||
{
|
||||
if (args.Path.Contains("Id"))
|
||||
{
|
||||
ReloadPlayQueue();
|
||||
}
|
||||
},
|
||||
removed: (s, args, obj) =>
|
||||
{
|
||||
ReloadPlayQueue();
|
||||
}
|
||||
);
|
||||
|
||||
await client.OnAsync("controller/state",
|
||||
added: (s, args, obj) =>
|
||||
{
|
||||
RemoteStateChanged(args.Data);
|
||||
},
|
||||
changed: (s, args, obj) =>
|
||||
{
|
||||
RemoteStateChanged(args.Data);
|
||||
},
|
||||
removed: null
|
||||
);
|
||||
}
|
||||
|
||||
private void ReloadPlayQueue()
|
||||
{
|
||||
bool autoPlay = PlayQueue.Count() == 0;
|
||||
var response = client.Get("controller/playQueue");
|
||||
var dict = response.ResultAs<Dictionary<string, FirebaseSong>>();
|
||||
|
||||
PlayQueue.Clear();
|
||||
if (dict.Count() > 0)
|
||||
{
|
||||
foreach (KeyValuePair<string, FirebaseSong> entry in dict)
|
||||
{
|
||||
entry.Value.FirebaseId = entry.Key;
|
||||
}
|
||||
|
||||
var array = dict.Values.OrderBy(s => s.Order).ToArray();
|
||||
PlayQueue.AddRange(array);
|
||||
if (autoPlay)
|
||||
{
|
||||
GetNextSong();
|
||||
}
|
||||
}
|
||||
PlayQueueChanged();
|
||||
}
|
||||
|
||||
private void CurrentSongChanged()
|
||||
{
|
||||
var response = client.Get("controller/currentSong");
|
||||
var dict = response.ResultAs<Dictionary<string, FirebaseSong>>();
|
||||
|
||||
var song = dict.Values.FirstOrDefault();
|
||||
if (song != null)
|
||||
{
|
||||
CurrentSong = song;
|
||||
SongChanged(new ControllerSongChangedEventArgs(false, song));
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoteStateChanged(string state)
|
||||
{
|
||||
PlayerState s = PlayerState.Play;
|
||||
if(state.ToLower() == "pause")
|
||||
{
|
||||
s = PlayerState.Pause;
|
||||
}
|
||||
else if (state.ToLower() == "stop")
|
||||
{
|
||||
s = PlayerState.Stop;
|
||||
}
|
||||
else if (state == "next")
|
||||
{
|
||||
s = PlayerState.Next;
|
||||
}
|
||||
StateChanged(new ControllerStateChangedEventArgs(s));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,32 +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
|
||||
{
|
||||
int 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
|
||||
{
|
||||
int Id { get; set; }
|
||||
List<ISong> PlayQueue { get; set; }
|
||||
void GetNextSong();
|
||||
void RemoveSong(ISong song);
|
||||
void Play();
|
||||
void Pause();
|
||||
void Stop();
|
||||
void Next();
|
||||
}
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
using KaraokePlayer.Enums;
|
||||
using KaraokePlayer.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KaraokePlayer.Classes
|
||||
{
|
||||
public class ControllerStateChangedEventArgs: EventArgs
|
||||
{
|
||||
public ControllerStateChangedEventArgs(PlayerState state )
|
||||
{
|
||||
State = state;
|
||||
}
|
||||
public PlayerState State { get; }
|
||||
}
|
||||
public class ControllerSongChangedEventArgs
|
||||
{
|
||||
public ControllerSongChangedEventArgs(ISong song)
|
||||
{
|
||||
ShouldPlay = true;
|
||||
Song = song;
|
||||
}
|
||||
public ControllerSongChangedEventArgs(bool shouldPlay, ISong song)
|
||||
{
|
||||
ShouldPlay = shouldPlay;
|
||||
Song = song;
|
||||
}
|
||||
public ISong Song { get; }
|
||||
public bool ShouldPlay { get; }
|
||||
}
|
||||
|
||||
public delegate void ControllerStateChangedEventHandler(ControllerStateChangedEventArgs args);
|
||||
public delegate void ControllerSongChangedEventHandler(ControllerSongChangedEventArgs args);
|
||||
public delegate void ControllerPlayQueueChangedEventHandler();
|
||||
|
||||
}
|
||||
@ -1,7 +1,4 @@
|
||||
using FireSharp;
|
||||
using FireSharp.Config;
|
||||
using FireSharp.Interfaces;
|
||||
using KaraokePlayer.Classes;
|
||||
using KaraokePlayer.Classes;
|
||||
using KaraokePlayer.Enums;
|
||||
using KaraokePlayer.Interfaces;
|
||||
using System;
|
||||
@ -117,7 +114,7 @@ namespace TestSelector
|
||||
song.Id = new Random().Next(0, 50000);
|
||||
song.Title = tag.Tag.Title;
|
||||
song.Artist = tag.Tag.Performers[0];
|
||||
song.Path = file.FullName;
|
||||
song.Path = file.FullName.Replace(@"D:\KaraokeData\", @"Z:\");
|
||||
controller.AddSongToQueue(song);
|
||||
}
|
||||
|
||||
|
||||
@ -33,10 +33,6 @@
|
||||
<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>
|
||||
@ -79,10 +75,6 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Classes\Enums.cs" />
|
||||
<Compile Include="Classes\FirebaseController.cs" />
|
||||
<Compile Include="Classes\Interfaces.cs" />
|
||||
<Compile Include="Classes\PlayerDelegates.cs" />
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -117,6 +109,12 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FirebaseKaraoke\FirebaseKaraoke.csproj">
|
||||
<Project>{4fe25e6d-1beb-4902-9815-c2b421233bd7}</Project>
|
||||
<Name>FirebaseKaraoke</Name>
|
||||
</ProjectReference>
|
||||
</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)' == ''">
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?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" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user