diff --git a/CdgLib/Graphic.cs b/CdgLib/Graphic.cs index df1dad9..17da6a4 100644 --- a/CdgLib/Graphic.cs +++ b/CdgLib/Graphic.cs @@ -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 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; } diff --git a/KaraokePlayer.sln b/KaraokePlayer.sln index 250c386..d0af5c0 100644 --- a/KaraokePlayer.sln +++ b/KaraokePlayer.sln @@ -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 diff --git a/KaraokePlayer/KaraokeVideoPlayer.cs b/KaraokePlayer/KaraokeVideoPlayer.cs index e09dc83..8e482c5 100644 --- a/KaraokePlayer/KaraokeVideoPlayer.cs +++ b/KaraokePlayer/KaraokeVideoPlayer.cs @@ -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)