Refactoring

Refactoring
This commit is contained in:
Brett Sanderson 2016-03-06 17:12:02 -05:00
parent deade2f47d
commit 1d6a879e34
3 changed files with 13 additions and 27 deletions

View File

@ -23,7 +23,7 @@ namespace CdgLib
private readonly int[] _colourTable = new int[ColourTableSize];
private readonly byte[,] _pixelColours = new byte[FullHeight, FullWidth];
private int[,] _graphicData = new int[FullHeight, FullWidth];
private readonly int[,] _graphicData = new int[FullHeight, FullWidth];
public Graphic(IEnumerable<Packet> packets)
{
@ -163,7 +163,7 @@ namespace CdgLib
_pixelColours[rowIndex, columnIndex] = (byte)colour;
}
for (rowIndex = _pixelColours.GetLength(1) - 12; rowIndex < _pixelColours.GetLength(1); rowIndex++)
for (rowIndex = _pixelColours.GetLength(0) - 12; rowIndex < _pixelColours.GetLength(0); rowIndex++)
{
_pixelColours[rowIndex, columnIndex] = (byte)colour;
}

View File

@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CdgLib", "CdgLib\CdgLib.csp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KaraokePlayer", "KaraokePlayer\KaraokePlayer.csproj", "{2CF318E2-04B5-40FC-9577-6DAC62B86FB2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KaraokeConverter", "KaraokeConverter\KaraokeConverter.csproj", "{2821C26D-52D8-43D9-BEF4-7CE4DFA60776}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -23,10 +21,6 @@ Global
{2CF318E2-04B5-40FC-9577-6DAC62B86FB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CF318E2-04B5-40FC-9577-6DAC62B86FB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CF318E2-04B5-40FC-9577-6DAC62B86FB2}.Release|Any CPU.Build.0 = Release|Any CPU
{2821C26D-52D8-43D9-BEF4-7CE4DFA60776}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2821C26D-52D8-43D9-BEF4-7CE4DFA60776}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2821C26D-52D8-43D9-BEF4-7CE4DFA60776}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2821C26D-52D8-43D9-BEF4-7CE4DFA60776}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -26,41 +26,33 @@ namespace KaraokePlayer
public KaraokeVideoPlayer()
{
InitializeComponent();
_lyricTimer.Interval = 500;
_lyricTimer.Interval = 30;
_lyricTimer.Elapsed += LyricTimerOnElapsed;
}
private async void LyricTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
private void LyricTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
{
var picture = _cdgFile.RenderAtTime((long)(DateTime.Now - _startTime).TotalMilliseconds);
_lyrics.Image = picture;
}
public async void Play(Uri file)
{
vlcPlayer.SetMedia(file);
_cdgFile = await GraphicsFile.LoadAsync(Path.ChangeExtension(file.LocalPath, "cdg"));
_cdgFile = await GraphicsFile.LoadAsync(Path.ChangeExtension(file.LocalPath, "cdg"));
vlcPlayer.Play();
}
private async void vlcPlayer_Playing(object sender, VlcMediaPlayerPlayingEventArgs e)
private void vlcPlayer_Playing(object sender, VlcMediaPlayerPlayingEventArgs e)
{
_startTime = DateTime.Now;
_lyricTimer.Start();
while (vlcPlayer.IsPlaying)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
var picture = _cdgFile.RenderAtTime((long) (DateTime.Now - _startTime).TotalMilliseconds);
stopwatch.Reset();
Debug.Print(stopwatch.ElapsedMilliseconds.ToString());
_lyrics.Image = picture;
}
}
private void vlcPlayer_TimeChanged(object sender, VlcMediaPlayerTimeChangedEventArgs e)